open-vault/ui/app/templates/components/secret-edit-toolbar.hbs

110 lines
3.9 KiB
Handlebars

{{! template-lint-configure simple-unless "warn" }}
<Toolbar>
{{#unless (and (eq @mode "show") @isWriteWithoutRead)}}
<ToolbarFilters>
<Toggle
@name="json"
@status="success"
@size="small"
@disabled={{and (eq @mode "show") @secretDataIsAdvanced}}
@checked={{@showAdvancedMode}}
@onChange={{action @editActions.toggleAdvanced}}
>
<span class="has-text-grey">JSON</span>
</Toggle>
</ToolbarFilters>
{{/unless}}
<ToolbarActions>
{{#if (eq @mode "show")}}
<SecretDeleteMenu
@modelForData={{@modelForData}}
@model={{@model}}
@isV2={{@isV2}}
@refresh={{action @editActions.refresh}}
@canReadSecretMetadata={{@canReadSecretMetadata}}
/>
{{/if}}
{{#if (and (eq @mode "show") @canUpdateSecretData)}}
{{#unless (and @isV2 (or @isWriteWithoutRead @modelForData.destroyed @modelForData.deleted))}}
<BasicDropdown
@class="popup-menu"
@horizontalPosition="auto-right"
@verticalPosition="below"
@onClose={{action "clearWrappedData"}}
as |D|
>
<D.Trigger
data-test-popup-menu-trigger="true"
class={{concat "toolbar-link" (if D.isOpen " is-active")}}
@htmlTag="button"
>
Copy
<Chevron @direction="down" @isButton={{true}} />
</D.Trigger>
<D.Content @defaultClass="popup-menu-content is-wide">
<nav class="box menu">
<ul class="menu-list">
<li class="action">
<CopyButton
@class="link link-plain has-text-weight-semibold is-ghost"
@clipboardText={{stringify @modelForData.secretData}}
@success={{action (set-flash-message "JSON Copied!")}}
data-test-copy-button
>
Copy JSON
</CopyButton>
</li>
<li class="action">
{{#if this.showWrapButton}}
<button
class="link link-plain has-text-weight-semibold is-ghost {{if this.isWrapping 'is-loading'}}"
type="button"
{{on "click" this.handleWrapClick}}
data-test-wrap-button
disabled={{this.isWrapping}}
>
Wrap secret
</button>
{{else}}
<MaskedInput
@class="has-padding"
@displayOnly={{true}}
@allowCopy={{true}}
@value={{this.wrappedData}}
/>
{{/if}}
</li>
</ul>
</nav>
</D.Content>
</BasicDropdown>
{{/unless}}
{{/if}}
{{#if (and (eq @mode "show") @isV2 (not @model.failedServerRead))}}
<SecretVersionMenu @version={{@modelForData}} @onRefresh={{action @editActions.refresh}} @model={{@model}} />
{{/if}}
{{#if (and (eq @mode "show") @canUpdateSecretData)}}
{{#let (concat "vault.cluster.secrets.backend." (if (eq @mode "show") "edit" "show")) as |targetRoute|}}
{{#if @isV2}}
<ToolbarLink
{{! Always create new version from latest if no metadata read access }}
@route={{targetRoute}}
@model={{@model.id}}
@query={{hash version=(if @model.canReadMetadata @modelForData.version "")}}
@replace={{true}}
@type="add"
data-test-secret-edit="true"
>
Create new version
</ToolbarLink>
{{else}}
<ToolbarLink @route={{targetRoute}} @model={{@model.id}} @replace={{true}} data-test-secret-edit="true">
Edit secret
</ToolbarLink>
{{/if}}
{{/let}}
{{/if}}
</ToolbarActions>
</Toolbar>