vault/ui/lib/sync/addon/components/secrets/destination-header.ts
claire bontempo 1fbbf9d76b
UI: Ember-data upgrade 5.3.2 prep: use custom service instead of extending ember-data store (#28695)
* rename store to pagination, remove store extension

* initial update of service test

* remove superfluous helper

* replace store with pagination service in main app

* update kmip engine syntax

* add pagination to kmip engine

* update to pagination in config-ui engine

* update sync engine to use pagination service

* use pagination service in kv engine

* use pagination service in ldap engine

* use pagination in pki engine

* update renaming clearDataset functions

* link to jira VAULT-31721

* remove comment
2024-10-17 10:00:57 -07:00

39 lines
1.3 KiB
TypeScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { service } from '@ember/service';
import errorMessage from 'vault/utils/error-message';
import type SyncDestinationModel from 'vault/models/sync/destination';
import type RouterService from '@ember/routing/router-service';
import type PaginationService from 'vault/services/pagination';
import type FlashMessageService from 'vault/services/flash-messages';
interface Args {
destination: SyncDestinationModel;
}
export default class DestinationsTabsToolbar extends Component<Args> {
@service('app-router') declare readonly router: RouterService;
@service declare readonly pagination: PaginationService;
@service declare readonly flashMessages: FlashMessageService;
@action
async deleteDestination() {
try {
const { destination } = this.args;
const message = `Destination ${destination.name} has been queued for deletion.`;
await destination.destroyRecord();
this.pagination.clearDataset('sync/destination');
this.router.transitionTo('vault.cluster.sync.secrets.overview');
this.flashMessages.success(message);
} catch (error) {
this.flashMessages.danger(`Error deleting destination \n ${errorMessage(error)}`);
}
}
}