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))}} + + {{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 @@ />
- {{#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 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))}} - - {{else}} - - {{/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 @@

{{/if}} - - {{partial "partials/secret-edit-display"}} - +
-
- {{/if}} - {{/unless}} +
+ +
{{#secret-link - mode=(if key.isFolder "list" "show") - secret=key.id + mode="show" + secret=model.id class="button" }} Cancel {{/secret-link}}
- {{#if capabilities.canDelete}} - {{#confirm-action - buttonClasses="button" - onConfirmAction=(action "deleteKey") - confirmMessage=(if key.isFolder - (concat "Are you sure you want to delete " key.id " and all its contents?") - (concat "Are you sure you want to delete " key.id "?") - ) - cancelButtonText="Cancel" - data-test-secret-delete="true" - }} - {{#if key.isFolder}} - Delete folder - {{else}} - Delete secret - {{/if}} - {{/confirm-action}} - {{/if}}