open-vault/ui/app/templates/components/secret-edit-display.hbs
2018-10-18 14:55:50 -05:00

71 lines
2.2 KiB
Handlebars

{{#if (and (or @model.isNew @canEditV2Secret) @isV2)}}
<div class="form-section box is-shadowless is-fullwidth">
<label class="title is-5">
Secret Metadata
</label>
{{#each @model.fields as |attr|}}
<FormField data-test-field @attr={{attr}} @model={{this.model}} />
{{/each}}
</div>
{{/if}}
{{#if @showAdvancedMode}}
<JsonEditor
@value={{@codemirrorString}}
@valueUpdated={{@editActions.codemirrorUpdated}}
@onFocusOut={{@editActions.formatJSON}}
/>
{{else}}
<div class="form-section">
<label class="title is-5">
{{#if isV2}}
Version Data
{{else}}
Secret Data
{{/if}}
</label>
{{#each @secretData as |secret index|}}
<div class="info-table-row">
<div class="column is-one-quarter info-table-row-edit">
{{input
data-test-secret-key=true
value=secret.name
placeholder="key"
change=(action @editActions.handleChange)
class="input"
}}
</div>
<div class="column info-table-row-edit">
<MaskedInput
@name={{secret.name}}
@onKeyDown={{@editActions.handleKeyDown}}
@onChange={{@editActions.handleChange}}
@value={{secret.value}}
data-test-secret-value="true"
/>
</div>
<div class="column is-narrow info-table-row-edit">
{{#if (eq @secretData.length (inc index))}}
<button type="button" {{action @editActions.addRow}} class="button is-outlined is-primary" data-test-secret-add-row="true">
Add
</button>
{{else}}
<button
class="button has-text-grey is-expanded is-icon"
type="button"
{{action @editActions.deleteRow secret.name}}
aria-label="Delete row"
>
<ICon
@size="22"
@glyph="trash-a"
@excludeIconClass={{true}}
class="is-large has-text-grey-light"
/>
</button>
{{/if}}
</div>
</div>
{{/each}}
</div>
{{/if}}