mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-16 19:47:02 +02:00
* initial setup * form field editType kv is very helpful * setting up things * setup two routes for metadata * routing * clean up routing * meh router changes not my favorite but its working * show metadata * add controller for backendCrumb mixin * setting up edit metadata and trimming SecretEditMetadata component * add edit metadata save functionality * create new version work * setup model and formfieldgroups for added config data. * add config network request to secret-engine * fix validations on config * add config rows * breaking up secret edit * add validation for metadata on create * stuff, but broken now on metadata tab * fix metadata route error * permissions * saving small text changes * permissions * cleanup * some test fixes and convert secret create or update to glimmer * all these changes fix secret create kv test * remove alert banners per design request * fix error for array instead of object in jsonEditor * add changelog * styling * turn into glimmer component * cleanup * test failure fix * add delete or * clean up * remove all hardcoded for api integration * add helper and fix create mode on create new version * address chelseas pr comments * add jsdocs to helper * fix test
109 lines
3.4 KiB
JavaScript
109 lines
3.4 KiB
JavaScript
/**
|
|
* @module SecretEditToolbar
|
|
* SecretEditToolbar component is the toolbar component displaying the JSON toggle and the actions like delete in the show mode.
|
|
*
|
|
* @example
|
|
* ```js
|
|
* <SecretEditToolbar
|
|
* @mode={{mode}}
|
|
* @model={{this.model}}
|
|
* @isV2={{isV2}}
|
|
* @isWriteWithoutRead={{isWriteWithoutRead}}
|
|
* @secretDataIsAdvanced={{secretDataIsAdvanced}}
|
|
* @showAdvancedMode={{showAdvancedMode}}
|
|
* @modelForData={{this.modelForData}}
|
|
* @navToNearestAncestor={{this.navToNearestAncestor}}
|
|
* @canUpdateSecretData={{canUpdateSecretData}}
|
|
* @codemirrorString={{codemirrorString}}
|
|
* @wrappedData={{wrappedData}}
|
|
* @editActions={{hash
|
|
toggleAdvanced=(action "toggleAdvanced")
|
|
refresh=(action "refresh")
|
|
}}
|
|
* />
|
|
* ```
|
|
|
|
* @param {string} mode - show, create, edit. The view.
|
|
* @param {object} model - the model passed from the parent secret-edit
|
|
* @param {boolean} isV2 - KV type
|
|
* @param {boolean} isWriteWithoutRead - boolean describing permissions
|
|
* @param {boolean} secretDataIsAdvanced - used to determine if show JSON toggle
|
|
* @param {boolean} showAdvacnedMode - used for JSON toggle
|
|
* @param {object} modelForData - a modified version of the model with secret data
|
|
* @param {string} navToNearestAncestor - route to nav to if press cancel
|
|
* @param {boolean} canUpdateSecretData - permissions that show the create new version button or not.
|
|
* @param {string} codemirrorString - used to copy the JSON
|
|
* @param {object} wrappedData - when copy the data it's the token of the secret returned.
|
|
* @param {object} editActions - actions passed from parent to child
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { action } from '@ember/object';
|
|
import { not } from '@ember/object/computed';
|
|
import { inject as service } from '@ember/service';
|
|
import { tracked } from '@glimmer/tracking';
|
|
|
|
export default class SecretEditToolbar extends Component {
|
|
@service store;
|
|
@service flashMessages;
|
|
|
|
@tracked wrappedData = null;
|
|
@tracked isWrapping = false;
|
|
@not('wrappedData') showWrapButton;
|
|
|
|
@action
|
|
clearWrappedData() {
|
|
this.wrappedData = null;
|
|
}
|
|
|
|
@action
|
|
handleCopyError() {
|
|
this.flashMessages.danger('Could Not Copy Wrapped Data');
|
|
this.send('clearWrappedData');
|
|
}
|
|
|
|
@action
|
|
handleCopySuccess() {
|
|
this.flashMessages.success('Copied Wrapped Data!');
|
|
this.send('clearWrappedData');
|
|
}
|
|
|
|
@action
|
|
handleWrapClick() {
|
|
this.isWrapping = true;
|
|
if (this.args.isV2) {
|
|
this.store
|
|
.adapterFor('secret-v2-version')
|
|
.queryRecord(this.args.modelForData.id, { wrapTTL: 1800 })
|
|
.then(resp => {
|
|
this.wrappedData = resp.wrap_info.token;
|
|
this.flashMessages.success('Secret Successfully Wrapped!');
|
|
})
|
|
.catch(() => {
|
|
this.flashMessages.danger('Could Not Wrap Secret');
|
|
})
|
|
.finally(() => {
|
|
this.isWrapping = false;
|
|
});
|
|
} else {
|
|
this.store
|
|
.adapterFor('secret')
|
|
.queryRecord(null, null, {
|
|
backend: this.args.model.backend,
|
|
id: this.args.modelForData.id,
|
|
wrapTTL: 1800,
|
|
})
|
|
.then(resp => {
|
|
this.wrappedData = resp.wrap_info.token;
|
|
this.flashMessages.success('Secret Successfully Wrapped!');
|
|
})
|
|
.catch(() => {
|
|
this.flashMessages.danger('Could Not Wrap Secret');
|
|
})
|
|
.finally(() => {
|
|
this.isWrapping = false;
|
|
});
|
|
}
|
|
}
|
|
}
|