mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-19 13:41:10 +02:00
* rename wrap test * refactor tool hash component * whoops fix component syntax * random refactor * rewrap component * unwrap component * lookup refactor * wrap refactor * update selectors * delete tool action form component * co-locate templates * Revert "co-locate templates" This reverts commit c52bb9875284a4ee78c773c794f4fe572ae7a7f4. * fix component jsdoc syntax * rename tracked property * rename rewrap token input selector * remove parseint now that input is typed as a number * nvm convert to number * co-locate templates * move to tools/ folder * add flash message to test
57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* 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 errorMessage from 'vault/utils/error-message';
|
|
|
|
/**
|
|
* @module ToolsUnwrap
|
|
* ToolsUnwrap components are components that sys/wrapping/rewrap functionality
|
|
*
|
|
* @example
|
|
* <Tools::Unwrap />
|
|
*/
|
|
|
|
export default class ToolsUnwrap extends Component {
|
|
@service store;
|
|
@service flashMessages;
|
|
|
|
@tracked token = '';
|
|
@tracked unwrapData = '';
|
|
@tracked unwrapDetails = {};
|
|
@tracked errorMessage = '';
|
|
|
|
@action
|
|
reset() {
|
|
this.token = '';
|
|
this.unwrapData = '';
|
|
this.unwrapDetails = {};
|
|
this.errorMessage = '';
|
|
}
|
|
|
|
@action
|
|
async handleSubmit(evt) {
|
|
evt.preventDefault();
|
|
const data = { token: this.token.trim() };
|
|
|
|
try {
|
|
const resp = await this.store.adapterFor('tools').toolAction('unwrap', data);
|
|
this.unwrapData = (resp && resp.data) || resp.auth;
|
|
this.unwrapDetails = {
|
|
'Request ID': resp.request_id,
|
|
'Lease ID': resp.lease_id || 'None',
|
|
Renewable: resp.renewable,
|
|
'Lease Duration': resp.lease_duration || 'None',
|
|
};
|
|
this.flashMessages.success('Unwrap was successful.');
|
|
} catch (error) {
|
|
this.errorMessage = errorMessage(error);
|
|
}
|
|
}
|
|
}
|