open-vault/ui/lib/pki/addon/components/page/pki-key-details.ts
claire bontempo 04396e5f9c
UI/pki key workflow tests (#18496)
* 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
2023-01-03 18:00:29 -08:00

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));
}
}
}