Files
nomad/ui/app/controllers/administration/tokens/token.js
Phil Renaud 86c858cdc3 [ui] Sentinel Policies CRUD UI (#20483)
* 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>
2024-05-22 16:41:50 -04:00

43 lines
1.1 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 { alias } from '@ember/object/computed';
import { task } from 'ember-concurrency';
export default class AccessControlTokensTokenController extends Controller {
@service notifications;
@service router;
@service store;
@alias('model.roles') roles;
@alias('model.token') activeToken; // looks like .token is an Ember reserved name?
@alias('model.policies') policies;
@task(function* () {
try {
yield this.activeToken.deleteRecord();
yield this.activeToken.save();
this.notifications.add({
title: 'Token Deleted',
color: 'success',
type: `success`,
destroyOnClick: false,
});
this.router.transitionTo('administration.tokens');
} catch (err) {
this.notifications.add({
title: `Error deleting Token ${this.activeToken.name}`,
message: err,
color: 'critical',
sticky: true,
});
}
})
deleteToken;
}