From ad2e40212b27dd03d790331ac16531bf8e358e45 Mon Sep 17 00:00:00 2001 From: Matthew Irish Date: Wed, 17 Oct 2018 23:07:32 -0500 Subject: [PATCH] add necessary computed macros and template for contextual menus for v1 and v2 secrets --- ui/app/models/secret.js | 6 ++ .../templates/partials/secret-list/item.hbs | 96 ++++++++++++++++--- 2 files changed, 91 insertions(+), 11 deletions(-) diff --git a/ui/app/models/secret.js b/ui/app/models/secret.js index 3e4174ebb..36fc8eeea 100644 --- a/ui/app/models/secret.js +++ b/ui/app/models/secret.js @@ -1,7 +1,9 @@ import { computed } from '@ember/object'; +import { alias } from '@ember/object/computed'; import DS from 'ember-data'; import KeyMixin from 'vault/mixins/key-mixin'; const { attr } = DS; +import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; export default DS.Model.extend(KeyMixin, { auth: attr('string'), @@ -23,4 +25,8 @@ export default DS.Model.extend(KeyMixin, { helpText: attr('string'), // TODO this needs to be a relationship like `engine` on kv-v2 backend: attr('string'), + secretPath: lazyCapabilities(apiPath`${'backend'}/${'id'}`, 'backend', 'id'), + canEdit: alias('secretPath.canUpdate'), + canDelete: alias('secretPath.canUpdate'), + canRead: alias('secretPath.canRead'), }); diff --git a/ui/app/templates/partials/secret-list/item.hbs b/ui/app/templates/partials/secret-list/item.hbs index bd1c67cfe..d718ee43d 100644 --- a/ui/app/templates/partials/secret-list/item.hbs +++ b/ui/app/templates/partials/secret-list/item.hbs @@ -10,19 +10,93 @@ }}
- {{#secret-link - mode=(if item.isFolder "list" "show") - secret=item.id - class="has-text-black has-text-weight-semibold" - }} - {{i-con - glyph=(if item.isFolder 'folder' 'file') - size=14 - class="has-text-grey-light" - }}{{if (eq item.id ' ') '(self)' (or item.keyWithoutParent item.id)}} - {{/secret-link}} + + {{if (eq item.id ' ') '(self)' (or item.keyWithoutParent item.id)}} +
+ + +
{{/linked-block}}