open-vault/ui/app/templates/partials/secret-list/item.hbs
Joshua Ogle 7eff7b51aa
UI: Confirm Action as a popover
* Refactors ConfirmAction implementation as a popover
* Improves copy surrounding consequences of destructive actions
* Moves 'Delete' buttons to Toolbar
2019-05-17 11:29:21 -06:00

103 lines
3.4 KiB
Handlebars

{{#linked-block
(concat
"vault.cluster.secrets.backend."
(if item.isFolder "list" "show")
(if (not item.id) "-root")
)
item.id
class="list-item-row"
data-test-secret-link=item.id
encode=true
}}
<div class="columns is-mobile">
<div class="column is-10">
<SecretLink
@mode={{if item.isFolder "list" "show" }}
@secret={{item.id}}
@class="has-text-black has-text-weight-semibold"
><Icon
@glyph={{if item.isFolder 'folder-outline' 'file-outline' }}
@class="has-text-grey-light"
/>{{if (eq item.id ' ') '(self)' (or item.keyWithoutParent item.id)}}
</SecretLink>
</div>
<div class="column has-text-right">
<PopupMenu name="secret-menu">
<nav class="menu">
<ul class="menu-list">
{{#if item.isFolder}}
<SecretLink
@mode="list"
@secret={{item.id}}
@class="has-text-black has-text-weight-semibold"
>
Contents
</SecretLink>
{{else}}
{{#if (or item.versionPath.isLoading item.secretPath.isLoading)}}
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
{{else}}
{{#if item.canRead}}
<li class="action">
<SecretLink
@mode="show"
@secret={{item.id}}
@class="has-text-black has-text-weight-semibold"
>
Details
</SecretLink>
</li>
{{#if backendModel.isV2KV}}
<li class="action">
<SecretLink
@mode="versions"
@secret={{item.id}}
@class="has-text-black has-text-weight-semibold"
>
View version history
</SecretLink>
</li>
{{/if}}
{{/if}}
{{#if item.canEdit}}
<li class="action">
<SecretLink
@mode="edit"
@secret={{item.id}}
@class="has-text-black has-text-weight-semibold"
>
{{if backendModel.isV2KV
"Create new version"
"Edit"
}}
</SecretLink>
</li>
{{/if}}
{{#if item.canDelete}}
<li class="action">
<ConfirmAction
@buttonClasses="link is-destroy"
@confirmMessage="This will permanently delete this secret and all its versions."
@onConfirmAction={{action "delete" item "secret"}}
data-test-v2-kv-delete={{item.id}}
>
{{if backendModel.isV2KV
"Permanently delete"
"Delete"
}}
</ConfirmAction>
</li>
{{/if}}
{{/if}}
{{/if}}
</ul>
</nav>
</PopupMenu>
</div>
</div>
{{/linked-block}}