From b31a513ec1dd8e9a8198b1ad4b88728df6e596ac Mon Sep 17 00:00:00 2001 From: Dharini Jeeva Date: Thu, 21 Jul 2022 10:03:13 -0700 Subject: [PATCH] Create static credentials tab (#1203) Create static credentials tab (#1203) --- addons/core/translations/resources/en-us.yaml | 4 +++ .../credential-store/nav/index.hbs | 15 +++++++--- ui/admin/app/router.js | 8 +++++ .../credential-store/credentials.js | 30 +++++++++++++++++++ .../credential-store/credentials/index.js | 13 ++++++++ .../credential-store/credentials.hbs | 3 ++ .../credential-store/credentials/index.hbs | 3 ++ .../credential-store/credentials-test.js | 16 ++++++++++ 8 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials.js create mode 100644 ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials/index.js create mode 100644 ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credentials.hbs create mode 100644 ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credentials/index.hbs create mode 100644 ui/admin/tests/unit/routes/scopes/scope/credential-stores/credential-store/credentials-test.js diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index a0387018b..ebf0d5177 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -374,6 +374,10 @@ credential-library: help: The body of the HTTP request the library sends to Vault when requesting credentials. Only allowed when HTTP method is set to POST. types: vault: Vault + static: Static +credential: + title: Credential + title_plural: Credentials scope: title: Scope title_plural: Scopes diff --git a/ui/admin/app/components/credential-stores/credential-store/nav/index.hbs b/ui/admin/app/components/credential-stores/credential-store/nav/index.hbs index 5a5c32543..e9ecfac0a 100644 --- a/ui/admin/app/components/credential-stores/credential-store/nav/index.hbs +++ b/ui/admin/app/components/credential-stores/credential-store/nav/index.hbs @@ -2,12 +2,19 @@ {{t 'titles.details'}} - {{#if (can 'navigate model' @model collection='credential-libraries')}} - + {{#if @model.isVault}} + {{#if (can 'navigate model' @model collection='credential-libraries')}} + + {{t 'resources.credential-library.title_plural'}} + + {{/if}} + {{else}} - {{t 'resources.credential-library.title_plural'}} + {{t 'resources.credential.title_plural'}} {{/if}} \ No newline at end of file diff --git a/ui/admin/app/router.js b/ui/admin/app/router.js index 9a036c377..dd32f9c13 100644 --- a/ui/admin/app/router.js +++ b/ui/admin/app/router.js @@ -113,6 +113,14 @@ Router.map(function () { function () {} ); }); + this.route('credentials', function () { + this.route('new'); + this.route( + 'credential', + { path: ':credential_id' }, + function () {} + ); + }); } ); this.route('new'); diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials.js b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials.js new file mode 100644 index 000000000..6fe1ecf81 --- /dev/null +++ b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials.js @@ -0,0 +1,30 @@ +import Route from '@ember/routing/route'; + +import { inject as service } from '@ember/service'; + +export default class ScopesScopeCredentialStoresCredentialStoreCredentialsRoute extends Route { + // =services + + @service can; + @service router; + + // =methods + + /** + * Loads all credentials under the current credential store. + * @return {Promise{[CredentialModel]}} + */ + model() { + const credentialStore = this.modelFor( + 'scopes.scope.credential-stores.credential-store' + ); + const { id: credential_store_id } = credentialStore; + if ( + this.can.can('list model', credentialStore, { + collection: 'credentials', + }) + ) { + return this.store.query('credential', { credential_store_id }); + } + } +} diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials/index.js b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials/index.js new file mode 100644 index 000000000..77efc33ac --- /dev/null +++ b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credentials/index.js @@ -0,0 +1,13 @@ +import Route from '@ember/routing/route'; + +export default class ScopesScopeCredentialStoresCredentialStoreCredentialsIndexRoute extends Route { + // =methods + + setupController(controller) { + const credentialStore = this.modelFor( + 'scopes.scope.credential-stores.credential-store' + ); + super.setupController(...arguments); + controller.setProperties({ credentialStore }); + } +} diff --git a/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credentials.hbs b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credentials.hbs new file mode 100644 index 000000000..2721e31a3 --- /dev/null +++ b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credentials.hbs @@ -0,0 +1,3 @@ +{{page-title (t 'resources.credential.title_plural')}} + +{{outlet}} \ No newline at end of file diff --git a/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credentials/index.hbs b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credentials/index.hbs new file mode 100644 index 000000000..2721e31a3 --- /dev/null +++ b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credentials/index.hbs @@ -0,0 +1,3 @@ +{{page-title (t 'resources.credential.title_plural')}} + +{{outlet}} \ No newline at end of file diff --git a/ui/admin/tests/unit/routes/scopes/scope/credential-stores/credential-store/credentials-test.js b/ui/admin/tests/unit/routes/scopes/scope/credential-stores/credential-store/credentials-test.js new file mode 100644 index 000000000..dcedf98a1 --- /dev/null +++ b/ui/admin/tests/unit/routes/scopes/scope/credential-stores/credential-store/credentials-test.js @@ -0,0 +1,16 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module( + 'Unit | Route | scopes/scope/credential-stores/credential-store/credentials', + function (hooks) { + setupTest(hooks); + + test('it exists', function (assert) { + let route = this.owner.lookup( + 'route:scopes/scope/credential-stores/credential-store/credentials' + ); + assert.ok(route); + }); + } +);