open-vault/ui/app/templates/components/secret-form-show.hbs
Angel Garbarino 1d18b0a7fa
UI/kv creation time (#12663)
* add created time for secret version view

* complete functionality

* test coverage

* changelog

* version per list item

* clean up
2021-09-28 13:15:43 -06:00

82 lines
3 KiB
Handlebars

{{#if (and @isV2 @modelForData.destroyed)}}
<EmptyState
@title="Version {{@modelForData.version}} of this secret has been permanently destroyed"
@message="A version that has been permanently deleted cannot be restored. You can see other versions of this secret in the History menu."
>
<DocLink @path="/docs/secrets/kv/kv-v2.html">
Learn more
</DocLink>
</EmptyState>
{{else if (and @isV2 @modelForData.deleted)}}
<EmptyState
@title="Version {{@modelForData.version}} of this secret has been deleted"
@message="A version that has been deleted but can be undeleted using the Version {{@modelForData.version}} menu above.
You can also see other versions of this secret in the History menu."
>
<DocLink @path="/docs/secrets/kv/kv-v2.html">
Learn more
</DocLink>
</EmptyState>
{{else if @isWriteWithoutRead}}
<EmptyState
data-test-write-without-read-empty-message
@title="You do not have permission to read this secret."
@message={{if @isV2
"Your policies permit you to write a new version of this secret, but do not allow you to read its current contents."
"Your policies permit you to overwrite this secret, but do not allow you to read it."
}}
>
</EmptyState>
{{else}}
{{#if @showAdvancedMode}}
<div class="has-top-margin-s">
<JsonEditor
@title={{if @isV2 "Version Data" "Secret Data"}}
@value={{@modelForData.dataAsJSONString}}
@options={{hash
readOnly=true
}}
/>
</div>
{{else}}
<div class="table info-table-row-header">
<div class="info-table-row thead">
<div class="th column is-one-quarter">
Key
</div>
<div class="th column">
Value
</div>
<div class="th column justify-right" data-test-created-time>
<ToolTip @verticalPosition="above" @horizontalPosition="center" as |T|>
<T.trigger data-test-tooltip-trigger tabindex="-1" data-test-created-time>
Version created {{date-format @modelForData.createdTime 'MMM dd, yyyy hh:mm a'}}
</T.trigger>
<T.content @class="tool-tip smaller-font">
<div class="box" data-test-hover-copy-tooltip-text>
{{@modelForData.createdTime}}
</div>
</T.content>
</ToolTip>
</div>
</div>
</div>
{{#if @modelForData.secretKeyAndValue}}
{{#each @modelForData.secretKeyAndValue as |secret|}}
<InfoTableRow @label={{secret.key}} @value={{secret.value}} @alwaysRender={{true}}>
{{#if secret.value}}
<MaskedInput @value={{secret.value}} @displayOnly={{true}} @allowCopy={{true}}/>
{{else}}
<Icon @size="s" @glyph="minus-plain"/>
{{/if}}
</InfoTableRow>
{{/each}}
{{else}}
{{!-- In the case of no key or value <InfoTableRow> will still render --}}
<InfoTableRow @label="" @value="" @alwaysRender={{true}}>
<Icon @size="s" @glyph="minus-plain"/>
</InfoTableRow>
{{/if}}
{{/if}}
{{/if}}