mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
* Gallery allows picking stuff * Small fixes * added sentinel templates * Can set enforcement level on policies * Working on the interactive sentinel dev mode * Very rough development flow on FE * Changed position in gutter menu * More sentinel stuff * PR cleanup: removed testmode, removed unneeded mixins and deps * Heliosification * Index-level sentinel policy deletion and page title fixes * Makes the Canaries sentinel policy real and then comments out the unfinished ones * rename Access Control to Administration in prep for moving Sentinel Policies and Node Pool admin there * Sentinel policies moved within the Administration section * Mirage fixture for sentinel policy endpoints * Description length check and 500 prevention * Sync review PR feedback addressed, implied butons on radio cards * Cull un-used sentinel policies --------- Co-authored-by: Mike Nomitch <mail@mikenomitch.com>
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
// @ts-check
|
|
import Controller from '@ember/controller';
|
|
import { inject as service } from '@ember/service';
|
|
import { task } from 'ember-concurrency';
|
|
import rollbackWithoutChangedAttrs from 'nomad-ui/utils/rollback-without-changed-attrs';
|
|
import messageFromAdapterError from 'nomad-ui/utils/message-from-adapter-error';
|
|
|
|
export default class SentinelPoliciesPolicyController extends Controller {
|
|
@service notifications;
|
|
@service router;
|
|
|
|
@task(function* () {
|
|
try {
|
|
yield this.model.destroyRecord();
|
|
this.notifications.add({
|
|
title: 'Policy Deleted',
|
|
color: 'success',
|
|
type: `success`,
|
|
destroyOnClick: false,
|
|
});
|
|
this.router.transitionTo('administration.sentinel-policies.index');
|
|
} catch (err) {
|
|
// A failed delete resulted in errors when you then navigated away and back
|
|
// to the show page rollbackWithoutChangedAttrs fixes it, but there might
|
|
// be a more idiomatic way
|
|
rollbackWithoutChangedAttrs(this.model);
|
|
|
|
let message = err.errors?.length
|
|
? messageFromAdapterError(err)
|
|
: err.message || 'Unknown Error';
|
|
|
|
this.notifications.add({
|
|
title: `Error deleting Policy ${this.model.name}`,
|
|
message,
|
|
color: 'critical',
|
|
sticky: true,
|
|
});
|
|
}
|
|
})
|
|
deletePolicy;
|
|
}
|