open-vault/ui/app/templates/components/secret-edit.hbs
Matthew Irish 6e0a43ae95
UI - kv v2 versions page (#5563)
* add versions routes

* move commands and permissions check to stand-alone menu component

* add versions template

* make list-item component more flexible and use hasMenu to optionally render the menu

* move current check next to the version

* fix linting

* remove is-wide from secret list popup
2018-10-19 17:24:57 -05:00

131 lines
4.3 KiB
Handlebars

<PageHeader as |p|>
<p.top>
{{key-value-header
baseKey=baseKey
path="vault.cluster.secrets.backend.list"
mode=mode
root=root
showCurrent=true
}}
</p.top>
<p.levelLeft>
<h1 class="title is-3">
{{#if (eq mode "create") }}
Create Secret
{{else if (and isV2 (eq mode 'edit'))}}
Create New Version
{{else if (eq mode 'edit')}}
Edit Secret
{{else}}
{{key.id}}
{{/if}}
</h1>
</p.levelLeft>
<p.levelRight>
{{#if canDelete}}
<ConfirmAction
@buttonClasses="button is-compact is-ghost has-icon-right"
@onConfirmAction={{action "deleteKey"}}
@confirmMessage={{if isV2
(concat "This will permanently delete " model.id " and all its versions. Are you sure you want to do this?")
(concat "Are you sure you want to delete " model.id "?")
}}
@cancelButtonText="Cancel"
data-test-secret-delete="true"
>
Delete secret <ICon @glyph="chevron-right" @size="11" />
</ConfirmAction>
{{/if}}
</p.levelRight>
</PageHeader>
<div class="secret-control-bar">
<div class="control">
<input
data-test-secret-json-toggle=true
id="json"
type="checkbox"
name="json"
class="switch is-rounded is-success is-small"
checked={{showAdvancedMode}}
onchange={{action "toggleAdvanced" value="target.checked"}}
disabled={{and (eq mode 'show') secretDataIsAdvanced}}
/>
<label for="json" class="has-text-grey">JSON</label>
</div>
{{#if (and (eq mode 'show') (or canEditV2Secret canEdit))}}
<div class="control">
{{#let (concat 'vault.cluster.secrets.backend.' (if (eq mode 'show') 'edit' 'show')) as |targetRoute|}}
{{#if isV2}}
<LinkTo
@params={{array targetRoute model.id (query-params version=this.modelForData.version)}}
@replace={{true}}
class="link link-plain has-text-weight-semibold"
>
Create new version
</LinkTo>
{{else}}
<LinkTo
@params={{array targetRoute model.id}}
@replace={{true}}
class="link link-plain has-text-weight-semibold"
>
Edit Secret
</LinkTo>
{{/if}}
{{/let}}
</div>
{{/if}}
{{#if (and (eq @mode "show") this.isV2)}}
<div class="control">
<SecretVersionMenu @version={{this.modelForData}} />
</div>
<div class="control">
<BasicDropdown
@class="popup-menu"
@horizontalPosition="auto-right"
@verticalPosition="below"
as |D|
>
<D.trigger
data-test-popup-menu-trigger="true"
@class={{concat "popup-menu-trigger button is-ghost has-text-grey" (if D.isOpen " is-active")}}
@tagName="button"
>
History <ICon @glyph="chevron-right" @size="11" />
</D.trigger>
<D.content @class="popup-menu-content ">
<nav class="box menu">
<ul class="menu-list">
<li class="action">
<SecretLink
@mode="versions"
@secret={{this.model.id}}
@class="has-text-black has-text-weight-semibold has-bottom-shadow"
>
View version history
</SecretLink>
</li>
</ul>
<h5 class="list-header">Versions</h5>
<ul class="menu-list">
{{#each (reverse this.model.versions) as |secretVersion|}}
<li class="action">
<LinkTo class="link" @params={{array (query-params version=secretVersion.version)}}>
Version {{secretVersion.version}}
{{#if (eq secretVersion.version this.model.currentVersion)}}
<ICon @glyph="checkmark-circled-outline" @excludeIconClass={{true}} @size="13" @class="has-text-success is-pulled-right" />
{{else if secretVersion.deleted}}
<ICon @glyph="cancel-square-outline" @size="13" @excludeIconClass={{true}} @class="has-text-grey is-pulled-right" />
{{/if}}
</LinkTo>
</li>
{{/each}}
</ul>
</nav>
</D.content>
</BasicDropdown>
</div>
{{/if}}
</div>
{{partial partialName}}