04396e5f9c
* wip tests * fix links * Revert "wip tests" This reverts commit aed9bb9b8fffb1b4d52d9c27644033ff3d983fff. * wip tests * add policy generator * add workflow tests for key * change apostrophe -___- * fix workflow tests * add update to key form tests * fix capability check for read * finish tests * fix flash messages; * rename policy generator file, update tests
33 lines
1,011 B
TypeScript
33 lines
1,011 B
TypeScript
import { action } from '@ember/object';
|
|
import Component from '@glimmer/component';
|
|
import RouterService from '@ember/routing/router-service';
|
|
import FlashMessageService from 'vault/services/flash-messages';
|
|
import { inject as service } from '@ember/service';
|
|
import errorMessage from 'vault/utils/error-message';
|
|
interface Args {
|
|
key: {
|
|
rollbackAttributes: () => void;
|
|
destroyRecord: () => void;
|
|
backend: string;
|
|
keyName: string;
|
|
keyId: string;
|
|
};
|
|
}
|
|
|
|
export default class PkiKeyDetails extends Component<Args> {
|
|
@service declare readonly router: RouterService;
|
|
@service declare readonly flashMessages: FlashMessageService;
|
|
|
|
@action
|
|
async deleteKey() {
|
|
try {
|
|
await this.args.key.destroyRecord();
|
|
this.flashMessages.success('Key deleted successfully.');
|
|
this.router.transitionTo('vault.cluster.secrets.backend.pki.keys.index');
|
|
} catch (error) {
|
|
this.args.key.rollbackAttributes();
|
|
this.flashMessages.danger(errorMessage(error));
|
|
}
|
|
}
|
|
}
|