diff --git a/ui/app/components/list-item.js b/ui/app/components/list-item.js index e4f1f0c0fa4e..c0a4396d1110 100644 --- a/ui/app/components/list-item.js +++ b/ui/app/components/list-item.js @@ -7,7 +7,7 @@ export default Component.extend({ tagName: '', linkParams: null, componentName: null, - hasMenu: false, + hasMenu: true, callMethod: task(function*(method, model, successMessage, failureMessage, successCallback = () => {}) { let flash = this.get('flashMessages'); diff --git a/ui/app/components/list-item/popup-menu.js b/ui/app/components/list-item/popup-menu.js index 4798652642ba..b1f4a59f1d96 100644 --- a/ui/app/components/list-item/popup-menu.js +++ b/ui/app/components/list-item/popup-menu.js @@ -2,4 +2,6 @@ import Component from '@ember/component'; export default Component.extend({ tagName: '', + item: null, + hasMenu: null, }); diff --git a/ui/app/components/secret-edit.js b/ui/app/components/secret-edit.js index b83d451ee622..4b0e684778a3 100644 --- a/ui/app/components/secret-edit.js +++ b/ui/app/components/secret-edit.js @@ -1,9 +1,8 @@ -import { or } from '@ember/object/computed'; import { isBlank, isNone } from '@ember/utils'; import { inject as service } from '@ember/service'; import Component from '@ember/component'; import { computed, set } from '@ember/object'; -import { alias } from '@ember/object/computed'; +import { alias, or } from '@ember/object/computed'; import { task, waitForEvent } from 'ember-concurrency'; import FocusOnInsertMixin from 'vault/mixins/focus-on-insert'; import keys from 'vault/lib/keycodes'; @@ -127,49 +126,6 @@ export default Component.extend(FocusOnInsertMixin, { ), canEditV2Secret: alias('v2UpdatePath.canUpdate'), - deleteVersionPath: maybeQueryRecord( - 'capabilities', - context => { - let backend = context.get('model.engine.id'); - let id = context.model.id; - return { - id: `${backend}/delete/${id}`, - }; - }, - 'model.id' - ), - canDeleteVersion: alias('deleteVersionPath.canUpdate'), - destroyVersionPath: maybeQueryRecord( - 'capabilities', - context => { - let backend = context.get('model.engine.id'); - let id = context.model.id; - return { - id: `${backend}/destroy/${id}`, - }; - }, - 'model.id' - ), - canDestroyVersion: alias('destroyVersionPath.canUpdate'), - undeleteVersionPath: maybeQueryRecord( - 'capabilities', - context => { - let backend = context.get('model.engine.id'); - let id = context.model.id; - return { - id: `${backend}/undelete/${id}`, - }; - }, - 'model.id' - ), - canUndeleteVersion: alias('undeleteVersionPath.canUpdate'), - - isFetchingVersionCapabilities: or( - 'deleteVersionPath.isPending', - 'destroyVersionPath.isPending', - 'undeleteVersionPath.isPending' - ), - requestInFlight: or('model.isLoading', 'model.isReloading', 'model.isSaving'), buttonDisabled: or( @@ -299,11 +255,6 @@ export default Component.extend(FocusOnInsertMixin, { }); }, - deleteVersion(deleteType = 'destroy') { - let id = this.modelForData.id; - return this.store.adapterFor('secret-v2-version').v2DeleteOperation(this.store, id, deleteType); - }, - refresh() { this.onRefresh(); }, diff --git a/ui/app/components/secret-version-menu.js b/ui/app/components/secret-version-menu.js new file mode 100644 index 000000000000..5b13c6cd214b --- /dev/null +++ b/ui/app/components/secret-version-menu.js @@ -0,0 +1,58 @@ +import { maybeQueryRecord } from 'vault/macros/maybe-query-record'; +import Component from '@ember/component'; +import { inject as service } from '@ember/service'; +import { alias, or } from '@ember/object/computed'; + +export default Component.extend({ + tagName: '', + store: service(), + version: null, + useDefaultTrigger: false, + + deleteVersionPath: maybeQueryRecord( + 'capabilities', + context => { + let [backend, id] = JSON.parse(context.version.id); + return { + id: `${backend}/delete/${id}`, + }; + }, + 'version.id' + ), + canDeleteVersion: alias('deleteVersionPath.canUpdate'), + destroyVersionPath: maybeQueryRecord( + 'capabilities', + context => { + let [backend, id] = JSON.parse(context.version.id); + return { + id: `${backend}/destroy/${id}`, + }; + }, + 'version.id' + ), + canDestroyVersion: alias('destroyVersionPath.canUpdate'), + undeleteVersionPath: maybeQueryRecord( + 'capabilities', + context => { + let [backend, id] = JSON.parse(context.version.id); + return { + id: `${backend}/undelete/${id}`, + }; + }, + 'version.id' + ), + canUndeleteVersion: alias('undeleteVersionPath.canUpdate'), + + isFetchingVersionCapabilities: or( + 'deleteVersionPath.isPending', + 'destroyVersionPath.isPending', + 'undeleteVersionPath.isPending' + ), + actions: { + deleteVersion(deleteType = 'destroy') { + return this.store + .adapterFor('secret-v2-version') + .v2DeleteOperation(this.store, this.version.id, deleteType); + }, + }, +}); diff --git a/ui/app/router.js b/ui/app/router.js index 5660a3e2c228..1301330180d4 100644 --- a/ui/app/router.js +++ b/ui/app/router.js @@ -92,6 +92,10 @@ Router.map(function() { this.route('credentials-root', { path: '/credentials/' }); this.route('credentials', { path: '/credentials/*secret' }); + // kv v2 versions + this.route('versions-root', { path: '/versions/' }); + this.route('versions', { path: '/versions/*secret' }); + // ssh sign this.route('sign-root', { path: '/sign/' }); this.route('sign', { path: '/sign/*secret' }); diff --git a/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js b/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js index 42da97bf16c3..873fc305f6bb 100644 --- a/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js +++ b/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js @@ -140,7 +140,7 @@ export default Route.extend(UnloadModelRoute, { }, willTransition(transition) { - let model = this.controller.model; + let { mode, model } = this.controller; let version = model.get('selectedVersion'); let changed = model.changedAttributes(); let changedKeys = Object.keys(changed); @@ -148,8 +148,8 @@ export default Route.extend(UnloadModelRoute, { // it's going to dirty the model state, so we need to look for it // and explicity ignore it here if ( - (changedKeys.length && changedKeys[0] !== 'backend') || - (version && Object.keys(version.changedAttributes()).length) + (mode !== 'show' && (changedKeys.length && changedKeys[0] !== 'backend')) || + (mode !== 'show' && version && Object.keys(version.changedAttributes()).length) ) { if ( window.confirm( diff --git a/ui/app/routes/vault/cluster/secrets/backend/versions-root.js b/ui/app/routes/vault/cluster/secrets/backend/versions-root.js new file mode 100644 index 000000000000..69de93ac8a8a --- /dev/null +++ b/ui/app/routes/vault/cluster/secrets/backend/versions-root.js @@ -0,0 +1 @@ +export { default } from './version'; diff --git a/ui/app/routes/vault/cluster/secrets/backend/versions.js b/ui/app/routes/vault/cluster/secrets/backend/versions.js new file mode 100644 index 000000000000..da1d44097e81 --- /dev/null +++ b/ui/app/routes/vault/cluster/secrets/backend/versions.js @@ -0,0 +1,27 @@ +import Route from '@ember/routing/route'; +import utils from 'vault/lib/key-utils'; +import UnloadModelRoute from 'vault/mixins/unload-model-route'; + +export default Route.extend(UnloadModelRoute, { + templateName: 'vault/cluster/secrets/backend/versions', + + beforeModel() { + let backendModel = this.modelFor('vault.cluster.secrets.backend'); + const { secret } = this.paramsFor(this.routeName); + const parentKey = utils.parentKeyForKey(secret); + if (backendModel.get('isV2KV')) { + return; + } + if (parentKey) { + return this.transitionTo('vault.cluster.secrets.backend.list', parentKey); + } else { + return this.transitionTo('vault.cluster.secrets.backend.list-root'); + } + }, + + model(params) { + let { secret } = params; + const { backend } = this.paramsFor('vault.cluster.secrets.backend'); + return this.store.queryRecord('secret-v2', { id: secret, backend }); + }, +}); diff --git a/ui/app/serializers/secret-v2.js b/ui/app/serializers/secret-v2.js index e1d7fc7f6cec..0be535c778a5 100644 --- a/ui/app/serializers/secret-v2.js +++ b/ui/app/serializers/secret-v2.js @@ -38,6 +38,7 @@ export default ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, { return body; }); } + payload.data.engine_id = payload.backend; payload.data.id = payload.id; return requestType === 'queryRecord' ? payload.data : [payload.data]; }, diff --git a/ui/app/styles/core/helpers.scss b/ui/app/styles/core/helpers.scss index b45b46732d80..3f94d9115af2 100644 --- a/ui/app/styles/core/helpers.scss +++ b/ui/app/styles/core/helpers.scss @@ -4,12 +4,18 @@ .is-underline { text-decoration: underline; } +.is-no-underline { + text-decoration: none; +} .is-sideless { box-shadow: 0 2px 0 -1px $grey-light, 0 -2px 0 -1px $grey-light; } .is-bottomless { box-shadow: 0 -1px 0 0 $grey-light; } +.has-bottom-shadow { + box-shadow: $box-shadow !important; +} .is-borderless { border: none !important; } diff --git a/ui/app/templates/components/list-item.hbs b/ui/app/templates/components/list-item.hbs index dbb4e13072b8..fa760d3c567c 100644 --- a/ui/app/templates/components/list-item.hbs +++ b/ui/app/templates/components/list-item.hbs @@ -3,18 +3,14 @@ {{else if linkParams}}
-
-
- {{#link-to params=linkParams class="has-text-weight-semibold"}} - {{yield (hash content=(component "list-item/content"))}} - {{/link-to}} -
-
+
+ {{#link-to params=linkParams class="has-text-weight-semibold has-text-black is-display-flex is-flex-1 is-no-underline"}} + {{yield (hash content=(component "list-item/content"))}} + {{/link-to}} +
- {{#if hasBlock}} - {{yield (hash callMethod=callMethod menu=(component "list-item/popup-menu"))}} - {{/if}} + {{yield (hash callMethod=callMethod menu=(component "list-item/popup-menu" item=item hasMenu=hasMenu))}}
@@ -22,14 +18,12 @@ {{else}}
-
-
- {{yield (hash content=(component "list-item/content"))}} -
+
+ {{yield (hash content=(component "list-item/content"))}}
- {{yield (hash callMethod=callMethod menu=(component "list-item/popup-menu"))}} + {{yield (hash callMethod=callMethod menu=(component "list-item/popup-menu" item=item hasMenu=hasMenu))}}
diff --git a/ui/app/templates/components/list-item/popup-menu.hbs b/ui/app/templates/components/list-item/popup-menu.hbs index c45c50ca9640..9823c5e91c61 100644 --- a/ui/app/templates/components/list-item/popup-menu.hbs +++ b/ui/app/templates/components/list-item/popup-menu.hbs @@ -1,7 +1,11 @@ - - - +{{#if hasMenu}} + + + +{{else}} + {{yield item}} +{{/if}} diff --git a/ui/app/templates/components/secret-edit.hbs b/ui/app/templates/components/secret-edit.hbs index 582a6fc9fcb1..d814e73c2218 100644 --- a/ui/app/templates/components/secret-edit.hbs +++ b/ui/app/templates/components/secret-edit.hbs @@ -77,130 +77,53 @@ {{/if}} {{#if (and (eq @mode "show") this.isV2)}}
- - - Version {{this.modelForData.version}} - - - - - - +
- - - History - - - - - + + History + + + + +
{{/if}}
diff --git a/ui/app/templates/components/secret-version-menu.hbs b/ui/app/templates/components/secret-version-menu.hbs new file mode 100644 index 000000000000..60e94794bf4d --- /dev/null +++ b/ui/app/templates/components/secret-version-menu.hbs @@ -0,0 +1,96 @@ + + + {{#if useDefaultTrigger}} + + {{else}} + Version {{this.version.version}} + + {{/if}} + + + + + \ No newline at end of file diff --git a/ui/app/templates/partials/secret-list/item.hbs b/ui/app/templates/partials/secret-list/item.hbs index 8c60ef3844f0..0363fe2b52a8 100644 --- a/ui/app/templates/partials/secret-list/item.hbs +++ b/ui/app/templates/partials/secret-list/item.hbs @@ -23,7 +23,7 @@
- +