mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 20:36:26 +02:00
* VAULT-41962 Updated tools sidebar * Fix failing tests and add copyright header * Update capitailization of nav item titles * Update tools breadcrumbs * Add comments * Fix failing tests! * Update ui/tests/acceptance/config-ui/messages/messages-test.js * Update ui/lib/core/addon/components/sidebar/nav/tools.ts * Add more nav tests for custom messages * Update test name --------- Co-authored-by: Kianna <30884335+kiannaquach@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { service } from '@ember/service';
|
|
import { action } from '@ember/object';
|
|
import { tracked } from '@glimmer/tracking';
|
|
|
|
import type ApiService from 'vault/services/api';
|
|
import type FlashMessageService from 'vault/services/flash-messages';
|
|
import type { HTMLElementEvent } from 'vault/forms';
|
|
|
|
/**
|
|
* @module ToolsRewrap
|
|
* ToolsRewrap components are components that sys/wrapping/rewrap functionality
|
|
*
|
|
* @example
|
|
* <Tools::Rewrap />
|
|
*/
|
|
|
|
export default class ToolsRewrap extends Component {
|
|
@service declare readonly api: ApiService;
|
|
@service declare readonly flashMessages: FlashMessageService;
|
|
|
|
@tracked originalToken = '';
|
|
@tracked rewrappedToken = '';
|
|
@tracked errorMessage = '';
|
|
|
|
get breadcrumbs() {
|
|
return [{ label: 'Vault', route: 'vault.cluster.dashboard', icon: 'vault' }, { label: 'Rewrap token' }];
|
|
}
|
|
|
|
@action
|
|
reset() {
|
|
this.originalToken = '';
|
|
this.rewrappedToken = '';
|
|
this.errorMessage = '';
|
|
}
|
|
|
|
@action
|
|
async handleSubmit(evt: HTMLElementEvent<HTMLFormElement>) {
|
|
evt.preventDefault();
|
|
const data = { token: this.originalToken.trim() };
|
|
|
|
try {
|
|
const { wrap_info } = await this.api.sys.rewrap(data);
|
|
this.rewrappedToken = wrap_info?.token || '';
|
|
this.flashMessages.success('Rewrap was successful.');
|
|
} catch (error) {
|
|
const { message } = await this.api.parseError(error);
|
|
this.errorMessage = message;
|
|
}
|
|
}
|
|
}
|