open-vault/ui/app/templates/components/secret-edit-display.hbs
Matthew Irish af8eda9322
UI - kv v2 graceful degrade (#5879)
* turns out sourcemaps are useful

* add test for restricted policy in kv v2

* only include version param on fetch if it's encoded in the id

* rename some vars for clarity and use model.id when persisting a secret

* fix delete attributes on the models

* allow data edit when there's metadata access is disallowed

* add tests for edit with restricted policy

* hide metadata fields if you can't edit them
2018-12-03 08:22:13 -06:00

82 lines
2.4 KiB
Handlebars

{{#if (and (or @model.isNew @canEditV2Secret) @isV2 (not @model.isStub))}}
<div data-test-metadata-fields 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}}
<div class="form-section">
<label class="title is-5">
{{#if isV2}}
Version Data
{{else}}
Secret Data
{{/if}}
</label>
<JsonEditor
@value={{@codemirrorString}}
@valueUpdated={{@editActions.codemirrorUpdated}}
@onFocusOut={{@editActions.formatJSON}}
/>
</div>
{{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"
autocomplete="off"
}}
</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}}