From 4893ed3ff30a99da570cc044a0a6671982da0376 Mon Sep 17 00:00:00 2001 From: Matthew Irish Date: Mon, 8 Oct 2018 23:22:29 -0500 Subject: [PATCH] use new local capabilities, move secret-edit-display partial to a component --- .../components/secret-edit-display.hbs | 51 ++++++++++++ ui/app/templates/components/secret-edit.hbs | 31 ++++--- .../partials/secret-edit-display.hbs | 46 ----------- .../templates/partials/secret-form-create.hbs | 16 +++- .../templates/partials/secret-form-edit.hbs | 80 ++++++------------- 5 files changed, 111 insertions(+), 113 deletions(-) create mode 100644 ui/app/templates/components/secret-edit-display.hbs delete mode 100644 ui/app/templates/partials/secret-edit-display.hbs diff --git a/ui/app/templates/components/secret-edit-display.hbs b/ui/app/templates/components/secret-edit-display.hbs new file mode 100644 index 000000000..4065ce10b --- /dev/null +++ b/ui/app/templates/components/secret-edit-display.hbs @@ -0,0 +1,51 @@ + {{#if @showAdvancedMode}} + + {{else}} + {{#each @secretData as |secret index|}} + + + {{input + data-test-secret-key=true + value=secret.name + placeholder="key" + change="handleChange" + class="input" + }} + + + + + + {{#if (eq @secretData.length (inc index))}} + + Add + + {{else}} + + + + {{/if}} + + + {{/each}} + {{/if}} \ No newline at end of file diff --git a/ui/app/templates/components/secret-edit.hbs b/ui/app/templates/components/secret-edit.hbs index 218ba3b43..18e2f0f66 100644 --- a/ui/app/templates/components/secret-edit.hbs +++ b/ui/app/templates/components/secret-edit.hbs @@ -19,6 +19,19 @@ {{/if}} + + {{#if canDelete}} + {{#confirm-action + buttonClasses="button is-compact is-ghost has-icon-right" + onConfirmAction=(action "deleteKey") + confirmMessage=(concat "Are you sure you want to delete " model.id "?") + cancelButtonText="Cancel" + data-test-secret-delete="true" + }} + Delete secret + {{/confirm-action}} + {{/if}} + @@ -39,17 +52,15 @@ /> JSON - {{#if (and (not-eq mode 'create') (or capabilities.canUpdate capabilities.canDelete))}} + {{#if (and (eq mode 'show') canEdit)}} - {{input - id="edit" - type="checkbox" - name="navToEdit" - class="switch is-rounded is-success is-small" - checked=(eq mode 'edit') - change=(action (nav-to-route (concat 'vault.cluster.secrets.backend.' (if (eq mode 'show') 'edit' 'show')) key.id replace=true) ) - }} - Edit + + Edit Secret + {{/if}} diff --git a/ui/app/templates/partials/secret-edit-display.hbs b/ui/app/templates/partials/secret-edit-display.hbs deleted file mode 100644 index aad4f6716..000000000 --- a/ui/app/templates/partials/secret-edit-display.hbs +++ /dev/null @@ -1,46 +0,0 @@ - {{#if showAdvancedMode}} - {{json-editor - value=codemirrorString - valueUpdated=(action "codemirrorUpdated") - onFocusOut=(action "formatJSON") - }} - {{else}} - {{#each secretData as |secret index|}} - - - {{input - data-test-secret-key=true - value=secret.name - placeholder="key" - change="handleChange" - class="input" - }} - - - {{masked-input - data-test-secret-value=true - name=secret.name - onKeyDown=(action "handleKeyDown") - onChange=(action "handleChange") - value=secret.value - }} - - - {{#if (eq secretData.length (inc index))}} - - Add - - {{else}} - - {{i-con size=22 glyph='trash-a' excludeIconClass=true class="is-large has-text-grey-light"}} - - {{/if}} - - - {{/each}} - {{/if}} \ No newline at end of file diff --git a/ui/app/templates/partials/secret-form-create.hbs b/ui/app/templates/partials/secret-form-create.hbs index 1eef75afa..0b699251b 100644 --- a/ui/app/templates/partials/secret-form-create.hbs +++ b/ui/app/templates/partials/secret-form-create.hbs @@ -12,9 +12,19 @@
Your current token does not have capabilities to update this secret.
- {{#secret-link - mode=(if key.isFolder "list" "show") - secret=key.id - class="button" - }} - Back to {{key.id}} - {{/secret-link}} -
{{key.id}}