UI: Add engine disable functionality to delete dropdown option (#9235) (#9249)

* mimic engine disable function from list view into dropdown option

* add line

Co-authored-by: Dan Rivera <dan.rivera@hashicorp.com>
This commit is contained in:
Vault Automation 2025-09-10 10:19:27 -06:00 committed by GitHub
parent ba4b639445
commit 72d941454f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 35 additions and 2 deletions

View file

@ -11,9 +11,12 @@ import BackendCrumbMixin from 'vault/mixins/backend-crumb';
import ListController from 'core/mixins/list-controller';
import { keyIsFolder } from 'core/utils/key-utils';
import engineDisplayData from 'vault/helpers/engines-display-data';
import { task } from 'ember-concurrency';
export default Controller.extend(ListController, BackendCrumbMixin, {
flashMessages: service(),
api: service(),
router: service(),
queryParams: ['page', 'pageFilter', 'tab'],
tab: '',
@ -71,4 +74,20 @@ export default Controller.extend(ListController, BackendCrumbMixin, {
});
},
},
disableEngine: task(function* (engine) {
const { engineType, id, path } = engine;
try {
yield this.api.sys.mountsDisableSecretsEngine(id);
this.flashMessages.success(`The ${engineType} Secrets Engine at ${path} has been disabled.`);
this.router.transitionTo('vault.cluster.secrets.backends');
} catch (err) {
const { message } = yield this.api.parseError(err);
this.flashMessages.danger(
`There was an error disabling the ${engineType} Secrets Engines at ${path}: ${message}.`
);
} finally {
this.engineToDisable = null;
}
}).drop(),
});

View file

@ -64,7 +64,11 @@
<Hds::Dropdown as |D|>
<D.ToggleButton @text="Manage" @color="secondary" data-test-manage-dropdown />
<D.Interactive @icon="settings" @route="vault.cluster.secrets.backend.configuration.index">Configure</D.Interactive>
<D.Interactive {{on "click" D.close}} @color="critical" @icon="trash">Delete</D.Interactive>
<D.Interactive
{{on "click" (fn (mut this.engineToDisable) this.backendModel)}}
@color="critical"
@icon="trash"
>Delete</D.Interactive>
</Hds::Dropdown>
<Hds::Button
@ -153,4 +157,14 @@
{{/if}}
{{/if}}
{{/if}}
{{/let}}
{{/let}}
{{#if this.engineToDisable}}
<ConfirmModal
@color="critical"
@confirmMessage="Any data in this engine will be permanently deleted."
@confirmTitle="Disable engine?"
@onClose={{fn (mut this.engineToDisable) null}}
@onConfirm={{perform this.disableEngine this.engineToDisable}}
/>
{{/if}}