From 45fc58fe757b53980848389d3b0bdfb2ec759ec8 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Sun, 18 Jul 2021 14:31:45 -0400 Subject: [PATCH 01/12] feat: Init credential library creation --- addons/api/addon/models/credential-library.js | 13 ++- addons/api/mirage/config.js | 10 +- addons/core/translations/form/en-us.yaml | 9 ++ addons/core/translations/resources/en-us.yaml | 2 + .../form/credential-library/index.hbs | 105 ++++++++++++++++++ .../form/credential-library/index.js | 20 ++++ ui/admin/app/router.js | 4 +- .../credential-stores/credential-store.js | 7 +- .../credential-store/credential-libraries.js | 37 ++++++ .../credential-libraries/new.js | 45 ++++++++ .../credential-stores/credential-store.hbs | 2 +- .../credential-store/-actions.hbs | 12 ++ .../credential-libraries/new.hbs | 7 ++ .../credential-libraries/new/-header.hbs | 3 + .../form/credential-library/index-test.js | 29 +++++ .../credential-libraries/new-test.js | 16 +++ 16 files changed, 316 insertions(+), 5 deletions(-) create mode 100644 ui/admin/app/components/form/credential-library/index.hbs create mode 100644 ui/admin/app/components/form/credential-library/index.js create mode 100644 ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries/new.js create mode 100644 ui/admin/app/templates/scopes/scope/credential-stores/credential-store/-actions.hbs create mode 100644 ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credential-libraries/new.hbs create mode 100644 ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credential-libraries/new/-header.hbs create mode 100644 ui/admin/tests/integration/components/form/credential-library/index-test.js create mode 100644 ui/admin/tests/unit/routes/scopes/scope/credential-stores/credential-store/credential-libraries/new-test.js diff --git a/addons/api/addon/models/credential-library.js b/addons/api/addon/models/credential-library.js index c95b9f73e..4ca321a18 100644 --- a/addons/api/addon/models/credential-library.js +++ b/addons/api/addon/models/credential-library.js @@ -2,13 +2,24 @@ import GeneratedCredentialLibraryModel from '../generated/models/credential-libr import { attr } from '@ember-data/model'; import { fragment } from 'ember-data-model-fragments/attributes'; +/** + * Enum options for credential library. + */ +export const options = { + http_methods: ['GET', 'POST'], +}; + export default class CredentialLibraryModel extends GeneratedCredentialLibraryModel { // =error attributes // These attributes exist solely to capture errors on nested fields. // See the application adapter's error normalization method for // more information. - @attr('string', { readOnly: true }) attributes_http_method; + @attr('string', { + readOnly: true, + defaultValue: options.http_methods[0], + }) + attributes_http_method; @attr('string', { readOnly: true }) attributes_http_request_body; @attr('string', { readOnly: true }) attributes_path; diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index 1fd364182..a45cd1bab 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -478,7 +478,15 @@ export default function () { ) => credentialLibraries.where({ credentialStoreId }) ); this.get('/credential-libraries/:id'); - this.post('/credential-libraries/:id'); + this.post( + '/credential-libraries', + function ({ credentialStores, credentialLibraries }) { + const attrs = this.normalizedRequestAttrs(); + const credentialStore = credentialStores.find(attrs.credentialStoreId); + attrs.scopeId = credentialStore.scope.id; + return credentialLibraries.create(attrs); + } + ); this.del('/credential-libraries/:id'); this.patch('/credential-libraries/:id'); diff --git a/addons/core/translations/form/en-us.yaml b/addons/core/translations/form/en-us.yaml index cb7b69832..b59b55b91 100644 --- a/addons/core/translations/form/en-us.yaml +++ b/addons/core/translations/form/en-us.yaml @@ -115,3 +115,12 @@ value: callback_url: label: Callback URL help: The URL to which the third-party provider sends the authentication response. Paste this into the provider configuration. +vault_path: + label: Vault Path + help: The path in Vault to request credentials from. +http_method: + label: HTTP Method + help: The HTTP method the library uses when requesting credentials from Vault. +http_request_body: + label: HTTP Request Body + help: The body of the HTTP request the library sends to Vault when requesting credentials. diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index cc9fed978..9468e3500 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -275,6 +275,8 @@ credential-library: title: Credential Library title_plural: Credential Libraries description: A credential library is a resource that provides credentials. + actions: + create: New Credential Library messages: none: title: No Credential Libraries Available diff --git a/ui/admin/app/components/form/credential-library/index.hbs b/ui/admin/app/components/form/credential-library/index.hbs new file mode 100644 index 000000000..f5bd6c4eb --- /dev/null +++ b/ui/admin/app/components/form/credential-library/index.hbs @@ -0,0 +1,105 @@ + + + {{#if @model.errors.name}} + + {{#each @model.errors.name as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + {{#if @model.errors.description}} + + {{#each @model.errors.description as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + {{#if @model.errors.name}} + + {{#each @model.errors.name as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + {{#each this.httpMethods as |httpMethod|}} + + {{/each}} + + + {{#if this.isHttpRequestBodyAllowed}} + + {{#if @model.errors.description}} + + {{#each @model.errors.description as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + {{/if}} + + + \ No newline at end of file diff --git a/ui/admin/app/components/form/credential-library/index.js b/ui/admin/app/components/form/credential-library/index.js new file mode 100644 index 000000000..69427c13b --- /dev/null +++ b/ui/admin/app/components/form/credential-library/index.js @@ -0,0 +1,20 @@ +import Component from '@glimmer/component'; +import { options } from 'api/models/credential-library'; +import { computed } from '@ember/object'; + +export default class FormCredentialLibraryIndexComponent extends Component { + // =properties + /** + * @type {object} + */ + httpMethods = options.http_methods; + + /** + * Only allow HTTP request body field if http_method is set to POST. + * @type {boolean} + */ + @computed('args.model.attributes_http_method') + get isHttpRequestBodyAllowed() { + return this.args.model.attributes_http_method?.match(/post/i); + } +} diff --git a/ui/admin/app/router.js b/ui/admin/app/router.js index 4012791b2..3c359e268 100644 --- a/ui/admin/app/router.js +++ b/ui/admin/app/router.js @@ -91,7 +91,9 @@ Router.map(function () { 'credential-store', { path: ':credential_store_id' }, function () { - this.route('credential-libraries', function () {}); + this.route('credential-libraries', function () { + this.route('new'); + }); } ); this.route('new'); diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store.js b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store.js index 307c11079..fa5b56baf 100644 --- a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store.js +++ b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store.js @@ -10,7 +10,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreRoute extends Rou } /** - * Render credential store header and navigation page sections. + * Render credential store header, navigation, and actions page sections. * @override */ renderTemplate() { @@ -25,5 +25,10 @@ export default class ScopesScopeCredentialStoresCredentialStoreRoute extends Rou into: 'scopes/scope/credential-stores/credential-store', outlet: 'navigation', }); + + this.render('scopes/scope/credential-stores/credential-store/-actions', { + into: 'scopes/scope/credential-stores/credential-store', + outlet: 'actions', + }); } } diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries.js b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries.js index 7c8ade755..fa54e9691 100644 --- a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries.js +++ b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries.js @@ -1,4 +1,7 @@ import Route from '@ember/routing/route'; +import { action } from '@ember/object'; +import loading from 'ember-loading/decorator'; +import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrariesRoute extends Route { // =methods @@ -13,4 +16,38 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari ); return this.store.query('credential-library', { credential_store_id }); } + + // =actions + + /** + * Rollback changes on a credential library. + * @param {CredentialLibraryModel} credentialLibrary + */ + @action + cancel(credentialLibrary) { + const { isNew } = credentialLibrary; + credentialLibrary.rollbackAttributes(); + if (isNew) + this.transitionTo( + 'scopes.scope.credential-stores.credential-store.credential-libraries' + ); + } + + /** + * Handle save of a credential library + * @param {CredentialLibraryModel} credentialLibrary + */ + @action + @loading + @notifyError(({ message }) => message) + @notifySuccess(({ isNew }) => + isNew ? 'notifications.create-success' : 'notifications.save-success' + ) + async save(credentialLibrary) { + await credentialLibrary.save(); + await this.transitionTo( + 'scopes.scope.credential-stores.credential-store.credential-libraries' + ); + this.refresh(); + } } diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries/new.js b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries/new.js new file mode 100644 index 000000000..d83109dda --- /dev/null +++ b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries/new.js @@ -0,0 +1,45 @@ +import Route from '@ember/routing/route'; + +export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrariesNewRoute extends Route { + // =methods + + /** + * Creates a new unsaved credential library in current credential store. + * @return {CredentialLibraryModel} + */ + model() { + const { id: credential_store_id } = this.modelFor( + 'scopes.scope.credential-stores.credential-store' + ); + return this.store.createRecord('credential-library', { + credential_store_id, + }); + } + + /** + * Renders new credential library specific templates for header, navigation, + * and action page sections. + * @override + */ + renderTemplate() { + super.renderTemplate(...arguments); + + this.render( + 'scopes/scope/credential-stores/credential-store/credential-libraries/new/-header', + { + into: 'scopes/scope/credential-stores/credential-store', + outlet: 'header', + } + ); + + this.render('_empty', { + into: 'scopes/scope/credential-stores/credential-store', + outlet: 'navigation', + }); + + this.render('_empty', { + into: 'scopes/scope/credential-stores/credential-store', + outlet: 'actions', + }); + } +} diff --git a/ui/admin/app/templates/scopes/scope/credential-stores/credential-store.hbs b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store.hbs index a6ecd7f81..efc46641a 100644 --- a/ui/admin/app/templates/scopes/scope/credential-stores/credential-store.hbs +++ b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store.hbs @@ -15,7 +15,7 @@ - {{!-- {{outlet 'actions'}} --}} + {{outlet 'actions'}} diff --git a/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/-actions.hbs b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/-actions.hbs new file mode 100644 index 000000000..587d095db --- /dev/null +++ b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/-actions.hbs @@ -0,0 +1,12 @@ + + + {{t 'resources.credential-library.actions.create'}} + + \ No newline at end of file diff --git a/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credential-libraries/new.hbs b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credential-libraries/new.hbs new file mode 100644 index 000000000..5d03e5b9f --- /dev/null +++ b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credential-libraries/new.hbs @@ -0,0 +1,7 @@ +{{page-title (t 'titles.new')}} + + \ No newline at end of file diff --git a/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credential-libraries/new/-header.hbs b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credential-libraries/new/-header.hbs new file mode 100644 index 000000000..51755b136 --- /dev/null +++ b/ui/admin/app/templates/scopes/scope/credential-stores/credential-store/credential-libraries/new/-header.hbs @@ -0,0 +1,3 @@ +

+ {{t 'titles.new'}} +

\ No newline at end of file diff --git a/ui/admin/tests/integration/components/form/credential-library/index-test.js b/ui/admin/tests/integration/components/form/credential-library/index-test.js new file mode 100644 index 000000000..e0d24a8c2 --- /dev/null +++ b/ui/admin/tests/integration/components/form/credential-library/index-test.js @@ -0,0 +1,29 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module( + 'Integration | Component | form/credential-library/index', + function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.set('myAction', function(val) { ... }); + + await render(hbs``); + + assert.equal(this.element.textContent.trim(), ''); + + // Template block usage: + await render(hbs` + + template block text + + `); + + assert.equal(this.element.textContent.trim(), 'template block text'); + }); + } +); diff --git a/ui/admin/tests/unit/routes/scopes/scope/credential-stores/credential-store/credential-libraries/new-test.js b/ui/admin/tests/unit/routes/scopes/scope/credential-stores/credential-store/credential-libraries/new-test.js new file mode 100644 index 000000000..3c4efdd66 --- /dev/null +++ b/ui/admin/tests/unit/routes/scopes/scope/credential-stores/credential-store/credential-libraries/new-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/credential-libraries/new', + function (hooks) { + setupTest(hooks); + + test('it exists', function (assert) { + let route = this.owner.lookup( + 'route:scopes/scope/credential-stores/credential-store/credential-libraries/new' + ); + assert.ok(route); + }); + } +); From 98e14a642fe13c7e514d49b2d8b810f144da8b19 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Mon, 19 Jul 2021 12:05:40 -0400 Subject: [PATCH 02/12] fix: Treat credential library attributes as an object --- addons/api/mirage/config.js | 1 + .../form/credential-library/index.hbs | 8 ++--- .../form/credential-library/index.js | 4 +-- .../credential-libraries/index.hbs | 6 ++++ .../form/credential-library/index-test.js | 29 ------------------- 5 files changed, 13 insertions(+), 35 deletions(-) delete mode 100644 ui/admin/tests/integration/components/form/credential-library/index-test.js diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index a45cd1bab..5d9ddaf8e 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -484,6 +484,7 @@ export default function () { const attrs = this.normalizedRequestAttrs(); const credentialStore = credentialStores.find(attrs.credentialStoreId); attrs.scopeId = credentialStore.scope.id; + console.log(attrs); return credentialLibraries.create(attrs); } ); diff --git a/ui/admin/app/components/form/credential-library/index.hbs b/ui/admin/app/components/form/credential-library/index.hbs index f5bd6c4eb..35aa5c339 100644 --- a/ui/admin/app/components/form/credential-library/index.hbs +++ b/ui/admin/app/components/form/credential-library/index.hbs @@ -47,7 +47,7 @@ {{#each this.httpMethods as |httpMethod|}} @@ -78,7 +78,7 @@ {{t 'resources.credential-library.messages.none.description'}} + + + {{t 'titles.new'}} + diff --git a/ui/admin/tests/integration/components/form/credential-library/index-test.js b/ui/admin/tests/integration/components/form/credential-library/index-test.js deleted file mode 100644 index e0d24a8c2..000000000 --- a/ui/admin/tests/integration/components/form/credential-library/index-test.js +++ /dev/null @@ -1,29 +0,0 @@ -import { module, test } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; -import { render } from '@ember/test-helpers'; -import { hbs } from 'ember-cli-htmlbars'; - -module( - 'Integration | Component | form/credential-library/index', - function (hooks) { - setupRenderingTest(hooks); - - test('it renders', async function (assert) { - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.set('myAction', function(val) { ... }); - - await render(hbs``); - - assert.equal(this.element.textContent.trim(), ''); - - // Template block usage: - await render(hbs` - - template block text - - `); - - assert.equal(this.element.textContent.trim(), 'template block text'); - }); - } -); From 59818fa24d8d53338450f49e92839a0cfdf8e11f Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Mon, 19 Jul 2021 13:13:35 -0400 Subject: [PATCH 03/12] feat: Add credential libraries breadcrumbs --- .../credential-store/credential-libraries.js | 18 ++++++++++++++++++ .../credential-libraries/new.js | 18 ++++++++++++++++++ .../credential-libraries-test.js | 17 +++++++++++++++++ .../credential-libraries/new-test.js | 17 +++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries.js create mode 100644 ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/new.js create mode 100644 ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries-test.js create mode 100644 ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/new-test.js diff --git a/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries.js b/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries.js new file mode 100644 index 000000000..fe9084ea7 --- /dev/null +++ b/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries.js @@ -0,0 +1,18 @@ +import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; + +export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrariesController extends Controller { + // =services + + @service intl; + + // =attributes + + /** + * Translated credential libraries breadcrumb + * @type {string} + */ + get breadCrumb() { + return this.intl.t('resources.credential-library.title_plural'); + } +} diff --git a/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/new.js b/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/new.js new file mode 100644 index 000000000..ff4053f92 --- /dev/null +++ b/ui/admin/app/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/new.js @@ -0,0 +1,18 @@ +import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; + +export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrariesNewController extends Controller { + // =services + + @service intl; + + // =attributes + + /** + * Translated new credential libraries breadcrumb + * @type {string} + */ + get breadCrumb() { + return this.intl.t('titles.new'); + } +} diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries-test.js new file mode 100644 index 000000000..944329525 --- /dev/null +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries-test.js @@ -0,0 +1,17 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module( + 'Unit | Controller | scopes/scope/credential-stores/credential-store/credential-libraries', + function (hooks) { + setupTest(hooks); + + // TODO: Replace this with your real tests. + test('it exists', function (assert) { + let controller = this.owner.lookup( + 'controller:scopes/scope/credential-stores/credential-store/credential-libraries' + ); + assert.ok(controller); + }); + } +); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/new-test.js new file mode 100644 index 000000000..2dce4303a --- /dev/null +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/new-test.js @@ -0,0 +1,17 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module( + 'Unit | Controller | scopes/scope/credential-stores/credential-store/credential-libraries/new', + function (hooks) { + setupTest(hooks); + + // TODO: Replace this with your real tests. + test('it exists', function (assert) { + let controller = this.owner.lookup( + 'controller:scopes/scope/credential-stores/credential-store/credential-libraries/new' + ); + assert.ok(controller); + }); + } +); From dd96423ead34e4793b636d1c1015a0743b7b18fc Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Tue, 20 Jul 2021 09:32:41 -0400 Subject: [PATCH 04/12] fix: Disable credential library request body in form --- addons/core/translations/form/en-us.yaml | 2 +- .../form/credential-library/index.hbs | 42 +++++++++---------- .../form/credential-library/index.js | 8 ++-- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/addons/core/translations/form/en-us.yaml b/addons/core/translations/form/en-us.yaml index b59b55b91..171011a4a 100644 --- a/addons/core/translations/form/en-us.yaml +++ b/addons/core/translations/form/en-us.yaml @@ -123,4 +123,4 @@ http_method: help: The HTTP method the library uses when requesting credentials from Vault. http_request_body: label: HTTP Request Body - help: The body of the HTTP request the library sends to Vault when requesting credentials. + help: The body of the HTTP request the library sends to Vault when requesting credentials. Only allowed when http_method is set to POST. diff --git a/ui/admin/app/components/form/credential-library/index.hbs b/ui/admin/app/components/form/credential-library/index.hbs index 35aa5c339..d45f78b58 100644 --- a/ui/admin/app/components/form/credential-library/index.hbs +++ b/ui/admin/app/components/form/credential-library/index.hbs @@ -31,7 +31,7 @@ @label={{t 'form.description.label'}} @error={{@model.errors.description}} @helperText={{t 'form.description.help'}} - disabled={{@model.isSaving}} + @disabled={{@model.isSaving}} readonly={{false}} as |field| > @@ -74,27 +74,25 @@ {{/each}} - {{#if this.isHttpRequestBodyAllowed}} - - {{#if @model.errors.description}} - - {{#each @model.errors.description as |error|}} - {{error.message}} - {{/each}} - - {{/if}} - - {{/if}} + + {{#if @model.errors.description}} + + {{#each @model.errors.description as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + Date: Thu, 22 Jul 2021 09:37:41 -0700 Subject: [PATCH 05/12] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20add=20fieldset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/credential-library/index.hbs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ui/admin/app/components/form/credential-library/index.hbs b/ui/admin/app/components/form/credential-library/index.hbs index d45f78b58..0e9e69e7c 100644 --- a/ui/admin/app/components/form/credential-library/index.hbs +++ b/ui/admin/app/components/form/credential-library/index.hbs @@ -74,6 +74,23 @@ {{/each}} + + <:title>{{t 'form.http_method.label'}} + <:description>{{t 'form.http_method.help'}} + <:body> + + {{#each this.httpMethods as |httpMethod|}} + + {{/each}} + + + Date: Thu, 22 Jul 2021 09:45:45 -0700 Subject: [PATCH 06/12] =?UTF-8?q?fix:=20=F0=9F=90=9B=20space?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/admin/app/components/form/credential-library/index.hbs | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/admin/app/components/form/credential-library/index.hbs b/ui/admin/app/components/form/credential-library/index.hbs index 0e9e69e7c..6a5395f4e 100644 --- a/ui/admin/app/components/form/credential-library/index.hbs +++ b/ui/admin/app/components/form/credential-library/index.hbs @@ -91,6 +91,7 @@ + Date: Thu, 22 Jul 2021 10:13:33 -0700 Subject: [PATCH 07/12] =?UTF-8?q?fix:=20=F0=9F=90=9B=20update=20to=20semi?= =?UTF-8?q?=20bold=20to=20match=20labels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/rose/addon/styles/rose/components/form/_fieldset.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/rose/addon/styles/rose/components/form/_fieldset.scss b/addons/rose/addon/styles/rose/components/form/_fieldset.scss index f35d3755c..c01a77a60 100644 --- a/addons/rose/addon/styles/rose/components/form/_fieldset.scss +++ b/addons/rose/addon/styles/rose/components/form/_fieldset.scss @@ -5,7 +5,7 @@ margin-bottom: sizing.rems(m); .rose-form-fieldset-title { - @include type.type(s, bold); + @include type.type(s, semibold); } .rose-form-fieldset-description { From 8b9d945efbce37a6b06c983e9e126ebbfff6b283 Mon Sep 17 00:00:00 2001 From: dharini Date: Thu, 22 Jul 2021 10:24:56 -0700 Subject: [PATCH 08/12] =?UTF-8?q?fix:=20=F0=9F=90=9B=20use=20named=20block?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/admin/app/components/form/credential-library/index.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/admin/app/components/form/credential-library/index.hbs b/ui/admin/app/components/form/credential-library/index.hbs index 6a5395f4e..a3c7acbae 100644 --- a/ui/admin/app/components/form/credential-library/index.hbs +++ b/ui/admin/app/components/form/credential-library/index.hbs @@ -74,7 +74,7 @@ {{/each}} - + <:title>{{t 'form.http_method.label'}} <:description>{{t 'form.http_method.help'}} <:body> @@ -90,7 +90,7 @@ {{/each}} - + Date: Thu, 22 Jul 2021 16:26:05 -0400 Subject: [PATCH 09/12] fix: Surface fieldset as a form component --- addons/rose/addon/components/rose/form/index.hbs | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/rose/addon/components/rose/form/index.hbs b/addons/rose/addon/components/rose/form/index.hbs index 8c545ec22..e23e52c0b 100644 --- a/addons/rose/addon/components/rose/form/index.hbs +++ b/addons/rose/addon/components/rose/form/index.hbs @@ -20,6 +20,7 @@ input=(component 'rose/form/input' disabled=this.disabled) select=(component 'rose/form/select' disabled=this.disabled) textarea=(component 'rose/form/textarea' disabled=this.disabled) + fieldset=(component 'rose/form/fieldset') actions=(component (if this.showEditToggleButton 'rose/form/actions/edit-toggle' From 03ce6be3ee09c0b6996f41b2d3c2775ec92ea395 Mon Sep 17 00:00:00 2001 From: dharini Date: Thu, 22 Jul 2021 13:44:02 -0700 Subject: [PATCH 10/12] =?UTF-8?q?fix:=20=F0=9F=90=9B=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/components/form/credential-library/index.hbs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/ui/admin/app/components/form/credential-library/index.hbs b/ui/admin/app/components/form/credential-library/index.hbs index a3c7acbae..322c35965 100644 --- a/ui/admin/app/components/form/credential-library/index.hbs +++ b/ui/admin/app/components/form/credential-library/index.hbs @@ -63,17 +63,6 @@ {{/if}} - - {{#each this.httpMethods as |httpMethod|}} - - {{/each}} - - <:title>{{t 'form.http_method.label'}} <:description>{{t 'form.http_method.help'}} From a6be658aa58c19672e5cfa5cef98094af9c634a0 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Thu, 22 Jul 2021 17:42:37 -0400 Subject: [PATCH 11/12] fix: Add error handling to credential-library creation form --- addons/api/addon/models/credential-library.js | 8 +-- .../fragment-credential-library-attributes.js | 2 + addons/api/mirage/config.js | 1 - addons/core/translations/form/en-us.yaml | 9 --- addons/core/translations/resources/en-us.yaml | 15 +++- .../form/credential-library/index.hbs | 72 ++++++++++++------- .../form/credential-library/index.js | 10 ++- 7 files changed, 67 insertions(+), 50 deletions(-) diff --git a/addons/api/addon/models/credential-library.js b/addons/api/addon/models/credential-library.js index 4ca321a18..a77e605ba 100644 --- a/addons/api/addon/models/credential-library.js +++ b/addons/api/addon/models/credential-library.js @@ -6,7 +6,7 @@ import { fragment } from 'ember-data-model-fragments/attributes'; * Enum options for credential library. */ export const options = { - http_methods: ['GET', 'POST'], + http_method: ['GET', 'POST'], }; export default class CredentialLibraryModel extends GeneratedCredentialLibraryModel { @@ -15,11 +15,7 @@ export default class CredentialLibraryModel extends GeneratedCredentialLibraryMo // See the application adapter's error normalization method for // more information. - @attr('string', { - readOnly: true, - defaultValue: options.http_methods[0], - }) - attributes_http_method; + @attr('string', { readOnly: true }) attributes_http_method; @attr('string', { readOnly: true }) attributes_http_request_body; @attr('string', { readOnly: true }) attributes_path; diff --git a/addons/api/addon/models/fragment-credential-library-attributes.js b/addons/api/addon/models/fragment-credential-library-attributes.js index dd6138199..582922601 100644 --- a/addons/api/addon/models/fragment-credential-library-attributes.js +++ b/addons/api/addon/models/fragment-credential-library-attributes.js @@ -1,5 +1,6 @@ import Fragment from 'ember-data-model-fragments/fragment'; import { attr } from '@ember-data/model'; +import { options } from './credential-library'; export default class FragmentCredentialLibraryAttributesModel extends Fragment { //= attributes (vault) @@ -7,6 +8,7 @@ export default class FragmentCredentialLibraryAttributesModel extends Fragment { @attr('string', { description: 'The HTTP method the library uses when requesting credentials from Vault.', + defaultValue: () => options.http_method[0], }) http_method; diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index 5d9ddaf8e..a45cd1bab 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -484,7 +484,6 @@ export default function () { const attrs = this.normalizedRequestAttrs(); const credentialStore = credentialStores.find(attrs.credentialStoreId); attrs.scopeId = credentialStore.scope.id; - console.log(attrs); return credentialLibraries.create(attrs); } ); diff --git a/addons/core/translations/form/en-us.yaml b/addons/core/translations/form/en-us.yaml index 171011a4a..cb7b69832 100644 --- a/addons/core/translations/form/en-us.yaml +++ b/addons/core/translations/form/en-us.yaml @@ -115,12 +115,3 @@ value: callback_url: label: Callback URL help: The URL to which the third-party provider sends the authentication response. Paste this into the provider configuration. -vault_path: - label: Vault Path - help: The path in Vault to request credentials from. -http_method: - label: HTTP Method - help: The HTTP method the library uses when requesting credentials from Vault. -http_request_body: - label: HTTP Request Body - help: The body of the HTTP request the library sends to Vault when requesting credentials. Only allowed when http_method is set to POST. diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index 9468e3500..d889b0975 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -280,4 +280,17 @@ credential-library: messages: none: title: No Credential Libraries Available - description: No Credential Libraries available in this credential store. \ No newline at end of file + description: No Credential Libraries available in this credential store. + form: + vault_path: + label: Vault Path + help: The path the library uses when requesting credentials from Vault. + http_method: + label: HTTP Method + help: The HTTP method the library uses when requesting credentials from Vault. + http_request_body: + label: HTTP Request Body + help: The body of the HTTP request the library sends to Vault when requesting credentials. Only allowed when HTTP method is set to POST. + http_post_method_options: + label: HTTP Method POST Options + help: The options available for when HTTP method is set to POST. \ No newline at end of file diff --git a/ui/admin/app/components/form/credential-library/index.hbs b/ui/admin/app/components/form/credential-library/index.hbs index 322c35965..f55445503 100644 --- a/ui/admin/app/components/form/credential-library/index.hbs +++ b/ui/admin/app/components/form/credential-library/index.hbs @@ -48,15 +48,15 @@ @name='vault_path' @type='text' @value={{@model.attributes.path}} - @label={{t 'form.vault_path.label'}} - @error={{@model.errors.name}} - @helperText={{t 'form.vault_path.help'}} + @label={{t 'resources.credential-library.form.vault_path.label'}} + @error={{@model.errors.attributes_path}} + @helperText={{t 'resources.credential-library.form.vault_path.help'}} readonly={{false}} as |field| > - {{#if @model.errors.name}} + {{#if @model.errors.attributes_path}} - {{#each @model.errors.name as |error|}} + {{#each @model.errors.attributes_path as |error|}} {{error.message}} {{/each}} @@ -64,8 +64,10 @@ - <:title>{{t 'form.http_method.label'}} - <:description>{{t 'form.http_method.help'}} + <:title>{{t 'resources.credential-library.form.http_method.label'}} + <:description>{{t + 'resources.credential-library.form.http_method.help' + }} <:body> - {{#each this.httpMethods as |httpMethod|}} + {{#each this.httpMethodOptions as |httpMethod|}} {{/each}} - - {{#if @model.errors.description}} - - {{#each @model.errors.description as |error|}} - {{error.message}} - {{/each}} - - {{/if}} - + {{#if this.isHttpRequestBodyAllowed}} + + <:title>{{t + 'resources.credential-library.form.http_post_method_options.label' + }} + <:description>{{t + 'resources.credential-library.form.http_post_method_options.help' + }} + <:body> + + {{#if @model.errors.attributes_http_request_body}} + + {{#each @model.errors.attributes_http_request_body as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + {{/if}} Date: Fri, 23 Jul 2021 09:29:42 -0400 Subject: [PATCH 12/12] fix: Shorten credential library POST form area --- addons/core/translations/resources/en-us.yaml | 5 +- .../form/credential-library/index.hbs | 54 ++++++++----------- 2 files changed, 22 insertions(+), 37 deletions(-) diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index b2ec4d304..8094abf9e 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -291,8 +291,5 @@ credential-library: label: HTTP Method help: The HTTP method the library uses when requesting credentials from Vault. http_request_body: - label: HTTP Request Body + label: HTTP Method POST Request Body help: The body of the HTTP request the library sends to Vault when requesting credentials. Only allowed when HTTP method is set to POST. - http_post_method_options: - label: HTTP Method POST Options - help: The options available for when HTTP method is set to POST. \ No newline at end of file diff --git a/ui/admin/app/components/form/credential-library/index.hbs b/ui/admin/app/components/form/credential-library/index.hbs index f55445503..beef7e8c6 100644 --- a/ui/admin/app/components/form/credential-library/index.hbs +++ b/ui/admin/app/components/form/credential-library/index.hbs @@ -84,39 +84,27 @@ {{#if this.isHttpRequestBodyAllowed}} - - <:title>{{t - 'resources.credential-library.form.http_post_method_options.label' - }} - <:description>{{t - 'resources.credential-library.form.http_post_method_options.help' - }} - <:body> - - {{#if @model.errors.attributes_http_request_body}} - - {{#each @model.errors.attributes_http_request_body as |error|}} - {{error.message}} - {{/each}} - - {{/if}} - - - + + {{#if @model.errors.attributes_http_request_body}} + + {{#each @model.errors.attributes_http_request_body as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + {{/if}}