open-vault/ui/app/templates/components/secret-form-show.hbs
claire bontempo b05ffa88d5
Improve Secret Empty States (#12084)
* adds conditional to render 'minus plain' icon when key doesn't exist

* shows a hyphen when KV secret doesn't have a key and/or value

* fixes tests
2021-07-21 12:47:52 -07:00

70 lines
2.4 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>
</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}}