mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-22 15:11:07 +02:00
* updates api client vars to snake_case for custom messages * updates api client vars to snake_case for tools * updates api client vars to snake_case for sync * updates api client vars to snake_case for secrets engine * updates api client vars to snake_case for auth * updates api client vars to snake_case for usage * updates api client dep to point to gh repo * fixes custom-messages service unit tests * fixes configure-ssh test * fixes configure-ssh test...again
58 lines
2.1 KiB
TypeScript
58 lines
2.1 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 apiMethodResolver from 'sync/utils/api-method-resolver';
|
|
|
|
import type RouterService from '@ember/routing/router-service';
|
|
import type PaginationService from 'vault/services/pagination';
|
|
import type FlashMessageService from 'vault/services/flash-messages';
|
|
import type ApiService from 'vault/services/api';
|
|
import type CapabilitiesService from 'vault/services/capabilities';
|
|
import type { Destination } from 'vault/sync';
|
|
import type { CapabilitiesMap } from 'vault/app-types';
|
|
|
|
interface Args {
|
|
destination: Destination;
|
|
capabilities: CapabilitiesMap;
|
|
}
|
|
|
|
export default class DestinationsTabsToolbar extends Component<Args> {
|
|
@service('app-router') declare readonly router: RouterService;
|
|
@service declare readonly pagination: PaginationService;
|
|
@service declare readonly flashMessages: FlashMessageService;
|
|
@service declare readonly api: ApiService;
|
|
@service declare readonly capabilities: CapabilitiesService;
|
|
|
|
get showSyncBtn() {
|
|
const { destination, capabilities } = this.args;
|
|
const path = this.capabilities.pathFor('syncSetAssociation', destination);
|
|
return capabilities[path]?.canUpdate && !destination.purge_initiated_at;
|
|
}
|
|
|
|
get showEditBtn() {
|
|
const { destination, capabilities } = this.args;
|
|
const path = this.capabilities.pathFor('syncDestination', destination);
|
|
return capabilities[path]?.canUpdate && !destination.purge_initiated_at;
|
|
}
|
|
|
|
@action
|
|
async deleteDestination() {
|
|
try {
|
|
const { destination } = this.args;
|
|
const message = `Destination ${destination.name} has been queued for deletion.`;
|
|
const method = apiMethodResolver('delete', destination.type);
|
|
await this.api.sys[method](destination.name, {});
|
|
this.router.transitionTo('vault.cluster.sync.secrets.overview');
|
|
this.flashMessages.success(message);
|
|
} catch (error) {
|
|
const { message } = await this.api.parseError(error);
|
|
this.flashMessages.danger(`Error deleting destination \n ${message}`);
|
|
}
|
|
}
|
|
}
|