From c2fe7355f67a91004815f66396ce02d726208afe Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 5 Aug 2020 09:57:53 -0600 Subject: [PATCH 01/17] add conditional for masking vs tweak source based on type, and update text for create transformation --- ui/app/models/transform.js | 7 +++++-- ui/app/templates/components/transform-edit-form.hbs | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/app/models/transform.js b/ui/app/models/transform.js index 77360af2582b..a600d50065b8 100644 --- a/ui/app/models/transform.js +++ b/ui/app/models/transform.js @@ -81,10 +81,13 @@ export default DS.Model.extend({ models: ['transform/role'], subText: 'Search for an existing role, type a new role to create it, or use a wildcard (*).', }), - transformAttrs: computed(function() { + transformAttrs: computed('type', function() { // TODO: group them into sections/groups. Right now, we don't different between required and not required as we do by hiding options. // will default to design mocks on how to handle as it will likely be a different pattern using client-side validation, which we have not done before - return ['name', 'type', 'template', 'tweak_source', 'masking_characters', 'allowed_roles']; + if (this.type === 'masking') { + return ['name', 'type', 'template', 'masking_character', 'allowed_roles']; + } + return ['name', 'type', 'template', 'tweak_source', 'allowed_roles']; }), transformFieldAttrs: computed('transformAttrs', function() { return expandAttributeMeta(this, this.get('transformAttrs')); diff --git a/ui/app/templates/components/transform-edit-form.hbs b/ui/app/templates/components/transform-edit-form.hbs index f693b79aa7d9..9f559fe4dd1a 100644 --- a/ui/app/templates/components/transform-edit-form.hbs +++ b/ui/app/templates/components/transform-edit-form.hbs @@ -10,7 +10,7 @@ @model={{model}} /> {{/each}} - + {{!-- --}}
@@ -21,7 +21,7 @@ data-test-role-ssh-create=true > {{#if (eq mode 'create')}} - Create role + Create transformation {{else if (eq mode 'edit')}} Save {{/if}} From 71d6423a65f3a2facdd91ba78e2cf7010daa6102 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 5 Aug 2020 10:18:23 -0600 Subject: [PATCH 02/17] change order --- ui/app/models/transform.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/ui/app/models/transform.js b/ui/app/models/transform.js index a600d50065b8..8db0f0fe4478 100644 --- a/ui/app/models/transform.js +++ b/ui/app/models/transform.js @@ -55,15 +55,6 @@ export default DS.Model.extend({ subText: 'Vault provides two types of transformations: Format Preserving Encryption (FPE) is reversible, while Masking is not.', }), - template: attr('stringArray', { - label: 'Template', // TODO: make this required for making a transformation - subLabel: 'Template Name', - subText: - 'Templates allow Vault to determine what and how to capture the value to be transformed. Type to use an existing template or create a new one.', - editType: 'searchSelect', - fallbackComponent: 'string-list', - models: ['transform/template'], - }), tweak_source: attr('string', { defaultValue: 'supplied', label: 'Tweak source', @@ -74,6 +65,16 @@ export default DS.Model.extend({ label: 'Masking character', subText: 'Specify which character you’d like to mask your data.', }), + + template: attr('stringArray', { + label: 'Template', // TODO: make this required for making a transformation + subLabel: 'Template Name', + subText: + 'Templates allow Vault to determine what and how to capture the value to be transformed. Type to use an existing template or create a new one.', + editType: 'searchSelect', + fallbackComponent: 'string-list', + models: ['transform/template'], + }), allowed_roles: attr('stringArray', { label: 'Allowed roles', editType: 'searchSelect', @@ -85,9 +86,9 @@ export default DS.Model.extend({ // TODO: group them into sections/groups. Right now, we don't different between required and not required as we do by hiding options. // will default to design mocks on how to handle as it will likely be a different pattern using client-side validation, which we have not done before if (this.type === 'masking') { - return ['name', 'type', 'template', 'masking_character', 'allowed_roles']; + return ['name', 'type', 'masking_character', 'template', 'allowed_roles']; } - return ['name', 'type', 'template', 'tweak_source', 'allowed_roles']; + return ['name', 'type', 'tweak_source', 'template', 'allowed_roles']; }), transformFieldAttrs: computed('transformAttrs', function() { return expandAttributeMeta(this, this.get('transformAttrs')); From d25a15f37cd7977ce65f550d9e62a384b01ac41c Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 5 Aug 2020 10:54:04 -0600 Subject: [PATCH 03/17] fix error with stringArray --- ui/app/models/transform.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/app/models/transform.js b/ui/app/models/transform.js index 8db0f0fe4478..f0ec09320708 100644 --- a/ui/app/models/transform.js +++ b/ui/app/models/transform.js @@ -65,8 +65,7 @@ export default DS.Model.extend({ label: 'Masking character', subText: 'Specify which character you’d like to mask your data.', }), - - template: attr('stringArray', { + template: attr('string', { label: 'Template', // TODO: make this required for making a transformation subLabel: 'Template Name', subText: @@ -75,7 +74,7 @@ export default DS.Model.extend({ fallbackComponent: 'string-list', models: ['transform/template'], }), - allowed_roles: attr('stringArray', { + allowed_roles: attr('string', { label: 'Allowed roles', editType: 'searchSelect', fallbackComponent: 'string-list', From 929b574338231099c7cd73eefbc821d71cbff87a Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 5 Aug 2020 11:00:30 -0600 Subject: [PATCH 04/17] setup the edit/delete transformation view --- .../templates/components/transform-edit.hbs | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/ui/app/templates/components/transform-edit.hbs b/ui/app/templates/components/transform-edit.hbs index aaef3777369c..28054ccd7a85 100644 --- a/ui/app/templates/components/transform-edit.hbs +++ b/ui/app/templates/components/transform-edit.hbs @@ -15,7 +15,7 @@ {{else if (eq mode 'edit')}} Edit Transformation {{else}} - SSH role {{model.id}} + Transformation {{model.id}} {{/if}} @@ -51,7 +51,7 @@ @buttonClasses="toolbar-link" @onConfirmAction={{action "delete"}} > - Delete role + Delete transformation {{/if}} {{#if (or model.canUpdate model.canDelete)}} @@ -61,18 +61,25 @@ @data-test-edit-link=true @replace=true > - Edit role + Edit transformation {{/if}} {{/if}} - -{{!-- TODO: keeping here for now to remind us what other component we need to add --}} -{{!-- TODO: not following partial pattern in Transform, this comes from SSH --}} -{{!-- {{#if (or (eq mode 'edit') (eq mode 'create'))}} - {{partial 'partials/role-ssh/form'}} +{{#if (or (eq mode 'edit') (eq mode 'create'))}} + {{else}} - {{partial 'partials/role-ssh/show'}} -{{/if}} --}} +{{!-- TODO eventually turn this into a component once it's fleshed out --}} +
+ {{log model}} + {{#each model.transformFieldAttrs as |attr|}} + {{#if (eq attr.type "object")}} + {{info-table-row label=(capitalize (or attr.options.label (humanize (dasherize attr.name)))) value=(stringify (get model attr.name))}} + {{else}} + {{info-table-row label=(capitalize (or attr.options.label (humanize (dasherize attr.name)))) value=(get model attr.name)}} + {{/if}} + {{/each}} +
+{{/if}} From adeef54959f5730bc9b97c8d1dd1193ce386e743 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 5 Aug 2020 11:01:42 -0600 Subject: [PATCH 05/17] clean up toolbar links --- .../templates/components/transform-edit.hbs | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/ui/app/templates/components/transform-edit.hbs b/ui/app/templates/components/transform-edit.hbs index 28054ccd7a85..daa7e326d494 100644 --- a/ui/app/templates/components/transform-edit.hbs +++ b/ui/app/templates/components/transform-edit.hbs @@ -24,25 +24,7 @@ {{#if (eq mode "show")}} - {{#if (eq model.keyType "otp")}} - - Generate Credential - - {{else}} - - Sign Keys - - {{/if}} + {{!-- TODO: update these actions, show delete grey out if not allowed --}} {{#if (or model.canUpdate model.canDelete)}}
{{/if}} From ac7403b23c59af3af9fb444d6127241641544916 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 5 Aug 2020 13:24:02 -0600 Subject: [PATCH 06/17] setup serializer to change response of mask character from keycode to character --- ui/app/adapters/transform.js | 7 ++++--- ui/app/models/transform.js | 1 + ui/app/serializers/transform.js | 11 +++++++++++ ui/app/templates/components/transform-edit.hbs | 1 - 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 ui/app/serializers/transform.js diff --git a/ui/app/adapters/transform.js b/ui/app/adapters/transform.js index ffc6f3820164..9f0c7a1a0424 100644 --- a/ui/app/adapters/transform.js +++ b/ui/app/adapters/transform.js @@ -63,9 +63,10 @@ export default ApplicationAdapter.extend({ const { id, backend } = query; let zeroAddressAjax = resolve(); const queryAjax = this.ajax(this.urlForTransformations(backend, id), 'GET', this.optionsForQuery(id)); - if (!id) { - zeroAddressAjax = this.findAllZeroAddress(store, query); - } + // TODO: come back to why you need this, carry over. + // if (!id) { + // zeroAddressAjax = this.findAllZeroAddress(store, query); + // } return allSettled([queryAjax, zeroAddressAjax]).then(results => { // query result 404d, so throw the adapterError diff --git a/ui/app/models/transform.js b/ui/app/models/transform.js index f0ec09320708..7c85ed7646c9 100644 --- a/ui/app/models/transform.js +++ b/ui/app/models/transform.js @@ -62,6 +62,7 @@ export default DS.Model.extend({ subText: `A tweak value is used when performing FPE transformations. This can be supplied, generated, or internal.`, // TODO: I do not include the link here. Need to figure out the best way to approach this. }), masking_character: attr('string', { + defaultValue: '*', label: 'Masking character', subText: 'Specify which character you’d like to mask your data.', }), diff --git a/ui/app/serializers/transform.js b/ui/app/serializers/transform.js new file mode 100644 index 000000000000..45ded11c7011 --- /dev/null +++ b/ui/app/serializers/transform.js @@ -0,0 +1,11 @@ +import ApplicationSerializer from './application'; + +export default ApplicationSerializer.extend({ + normalizeResponse(store, primaryModelClass, payload, id, requestType) { + if (payload.data.masking_character) { + // TODO: provide catch for when the entered something that is not UTF-16, see slack discussion on FE channel + payload.data.masking_character = String.fromCharCode(payload.data.masking_character); + } + return this._super(store, primaryModelClass, payload, id, requestType); + }, +}); diff --git a/ui/app/templates/components/transform-edit.hbs b/ui/app/templates/components/transform-edit.hbs index daa7e326d494..e677bee9a8d9 100644 --- a/ui/app/templates/components/transform-edit.hbs +++ b/ui/app/templates/components/transform-edit.hbs @@ -55,7 +55,6 @@ {{else}} {{!-- TODO eventually turn this into a component once it's fleshed out --}}
- {{log model}} {{#each model.transformFieldAttrs as |attr|}} {{#if (eq attr.type "object")}} {{info-table-row label=(capitalize (or attr.options.label (humanize (dasherize attr.name)))) value=(stringify (get model attr.name))}} From aea22a36262e8d64f879f165c614f79c76837cee Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Thu, 6 Aug 2020 10:56:20 -0600 Subject: [PATCH 07/17] change styling of label and sub-text size, confirmed with design --- ui/app/styles/core/forms.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/app/styles/core/forms.scss b/ui/app/styles/core/forms.scss index 113576c374da..c5ca31916dcd 100644 --- a/ui/app/styles/core/forms.scss +++ b/ui/app/styles/core/forms.scss @@ -21,7 +21,7 @@ label { .b-checkbox .is-label { color: $grey-darker; display: inline-block; - font-size: $size-small; + font-size: $body-size; // 14px to match designs font-weight: $font-weight-bold; &:not(:last-child) { @@ -73,6 +73,7 @@ label { .sub-text { color: $grey; margin-bottom: 0.25rem; + font-size: 12px; } .input, .textarea, From 1cad8d2bb6c3a651a3e60d75a44d895c7d3de893 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Thu, 6 Aug 2020 13:13:38 -0600 Subject: [PATCH 08/17] temp fix on templates vs template --- ui/app/components/role-edit.js | 2 +- ui/app/models/transform.js | 12 ++++++------ ui/app/serializers/transform.js | 1 + ui/app/templates/components/transform-edit.hbs | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ui/app/components/role-edit.js b/ui/app/components/role-edit.js index 88270bc367d6..f2f27cc93ac5 100644 --- a/ui/app/components/role-edit.js +++ b/ui/app/components/role-edit.js @@ -89,7 +89,7 @@ export default Component.extend(FocusOnInsertMixin, { createOrUpdate(type, event) { event.preventDefault(); - const modelId = this.get('model.id') || this.get('model.name'); //ARG TODO this is not okay + const modelId = this.get('model.id') || this.get('model.name'); // ARG TODO this is not okay // prevent from submitting if there's no key // maybe do something fancier later if (type === 'create' && isBlank(modelId)) { diff --git a/ui/app/models/transform.js b/ui/app/models/transform.js index 7c85ed7646c9..1ef3e835212b 100644 --- a/ui/app/models/transform.js +++ b/ui/app/models/transform.js @@ -39,7 +39,6 @@ export default DS.Model.extend({ // TODO: for now, commenting out openApi info, but keeping here just in case we end up using it. // useOpenAPI: true, // getHelpUrl: function(backend) { - // console.log(backend, 'Backend'); // return `/v1/${backend}?help=1`; // }, name: attr('string', { @@ -67,14 +66,15 @@ export default DS.Model.extend({ subText: 'Specify which character you’d like to mask your data.', }), template: attr('string', { + editType: 'searchSelect', + fallbackComponent: 'string-list', label: 'Template', // TODO: make this required for making a transformation + models: ['transform/template'], subLabel: 'Template Name', subText: 'Templates allow Vault to determine what and how to capture the value to be transformed. Type to use an existing template or create a new one.', - editType: 'searchSelect', - fallbackComponent: 'string-list', - models: ['transform/template'], }), + templates: attr('array'), // TODO: remove once BE changes the returned property to a singular template on the GET request. allowed_roles: attr('string', { label: 'Allowed roles', editType: 'searchSelect', @@ -86,9 +86,9 @@ export default DS.Model.extend({ // TODO: group them into sections/groups. Right now, we don't different between required and not required as we do by hiding options. // will default to design mocks on how to handle as it will likely be a different pattern using client-side validation, which we have not done before if (this.type === 'masking') { - return ['name', 'type', 'masking_character', 'template', 'allowed_roles']; + return ['name', 'type', 'masking_character', 'template', 'templates', 'allowed_roles']; } - return ['name', 'type', 'tweak_source', 'template', 'allowed_roles']; + return ['name', 'type', 'tweak_source', 'template', 'templates', 'allowed_roles']; }), transformFieldAttrs: computed('transformAttrs', function() { return expandAttributeMeta(this, this.get('transformAttrs')); diff --git a/ui/app/serializers/transform.js b/ui/app/serializers/transform.js index 45ded11c7011..400d46f65eba 100644 --- a/ui/app/serializers/transform.js +++ b/ui/app/serializers/transform.js @@ -6,6 +6,7 @@ export default ApplicationSerializer.extend({ // TODO: provide catch for when the entered something that is not UTF-16, see slack discussion on FE channel payload.data.masking_character = String.fromCharCode(payload.data.masking_character); } + return this._super(store, primaryModelClass, payload, id, requestType); }, }); diff --git a/ui/app/templates/components/transform-edit.hbs b/ui/app/templates/components/transform-edit.hbs index e677bee9a8d9..ed12eb4dc18d 100644 --- a/ui/app/templates/components/transform-edit.hbs +++ b/ui/app/templates/components/transform-edit.hbs @@ -54,7 +54,7 @@ {{else}} {{!-- TODO eventually turn this into a component once it's fleshed out --}} -
+
{{#each model.transformFieldAttrs as |attr|}} {{#if (eq attr.type "object")}} {{info-table-row label=(capitalize (or attr.options.label (humanize (dasherize attr.name)))) value=(stringify (get model attr.name))}} From 33f2924a23d2dde20b83179fc558b569538c897a Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Thu, 6 Aug 2020 15:26:03 -0600 Subject: [PATCH 09/17] add clickable list item --- ui/app/adapters/transform.js | 2 +- ui/app/helpers/options-for-backend.js | 2 +- .../transform-transformations-item.hbs | 95 +++++++++++++++++++ 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 ui/app/templates/partials/secret-list/transform-transformations-item.hbs diff --git a/ui/app/adapters/transform.js b/ui/app/adapters/transform.js index 9f0c7a1a0424..e1c2ad888b70 100644 --- a/ui/app/adapters/transform.js +++ b/ui/app/adapters/transform.js @@ -28,7 +28,7 @@ export default ApplicationAdapter.extend({ deleteRecord(store, type, snapshot) { const { id } = snapshot; - return this.ajax(this.urlForRole(snapshot.record.get('backend'), id), 'DELETE'); + return this.ajax(this.urlForTransformations(snapshot.record.get('backend'), id), 'DELETE'); }, pathForType() { diff --git a/ui/app/helpers/options-for-backend.js b/ui/app/helpers/options-for-backend.js index e1c4a868cc47..03c458c5a57c 100644 --- a/ui/app/helpers/options-for-backend.js +++ b/ui/app/helpers/options-for-backend.js @@ -62,7 +62,7 @@ const SECRET_BACKENDS = { item: 'transform', create: 'Create Transformation', editComponent: 'transform-edit', - listItemPartial: 'partials/secret-list/ssh-role-item', + listItemPartial: 'partials/secret-list/transform-transformations-item', }, transit: { searchPlaceholder: 'Filter keys', diff --git a/ui/app/templates/partials/secret-list/transform-transformations-item.hbs b/ui/app/templates/partials/secret-list/transform-transformations-item.hbs new file mode 100644 index 000000000000..de0041a02b26 --- /dev/null +++ b/ui/app/templates/partials/secret-list/transform-transformations-item.hbs @@ -0,0 +1,95 @@ +{{!-- ARG TODO: come back and clean this up, should only see details and should click --}} +{{#linked-block + (concat + "vault.cluster.secrets.backend." + (if item.isFolder "list" "show") + (if (not item.id) "-root") + ) + item.id + class="list-item-row" + data-test-secret-link=item.id + encode=true + queryParams=(secret-query-params backendModel.type) +}} +
+
+ {{if (eq item.id ' ') '(self)' (or item.keyWithoutParent item.id)}} + +
+
+ + + + + +
+
+{{/linked-block}} From fb58b2a041960ec85841c7be7958f99aa9ab326f Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Fri, 7 Aug 2020 11:28:03 -0600 Subject: [PATCH 10/17] add space between template list --- ui/app/serializers/transform.js | 10 +++++++++- ui/app/styles/core.scss | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ui/app/serializers/transform.js b/ui/app/serializers/transform.js index 400d46f65eba..a9fe0a6793f3 100644 --- a/ui/app/serializers/transform.js +++ b/ui/app/serializers/transform.js @@ -3,10 +3,18 @@ import ApplicationSerializer from './application'; export default ApplicationSerializer.extend({ normalizeResponse(store, primaryModelClass, payload, id, requestType) { if (payload.data.masking_character) { - // TODO: provide catch for when the entered something that is not UTF-16, see slack discussion on FE channel payload.data.masking_character = String.fromCharCode(payload.data.masking_character); } + if (payload.data.templates && payload.data.templates.length === 1) { + // add space after comma in returned array length one of a string of templates + payload.data.templates[0] = payload.data.templates[0].replace(/,/g, ', '); + } + + // TODO: something similar her for roles, however it's a little tough because each role comes back as an item in an array. + // Also note, the BE is working on a ticket to amend these response, so revisit. + // TODO: QA to make sure this is only normalizing the response and not changing data on edit (e.g. add a space after the comma when rePOST on edit) + return this._super(store, primaryModelClass, payload, id, requestType); }, }); diff --git a/ui/app/styles/core.scss b/ui/app/styles/core.scss index 62d76be84129..2e684cfd7df8 100644 --- a/ui/app/styles/core.scss +++ b/ui/app/styles/core.scss @@ -103,6 +103,7 @@ @import './components/token-expire-warning'; @import './components/toolbar'; @import './components/tool-tip'; +@import './components/transform-edit.scss'; @import './components/transit-card'; @import './components/ttl-picker2'; @import './components/unseal-warning'; From 495802f577fa2b683dc77a06b8dbb6cba442078b Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Fri, 7 Aug 2020 11:28:40 -0600 Subject: [PATCH 11/17] setup styling and structure for the rest of the show transformation. TODO: turn into components. --- ui/app/styles/components/transform-edit.scss | 8 +++++ ui/app/styles/core/forms.scss | 2 +- ui/app/styles/core/helpers.scss | 4 +++ .../templates/components/transform-edit.hbs | 35 +++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 ui/app/styles/components/transform-edit.scss diff --git a/ui/app/styles/components/transform-edit.scss b/ui/app/styles/components/transform-edit.scss new file mode 100644 index 000000000000..57400100420a --- /dev/null +++ b/ui/app/styles/components/transform-edit.scss @@ -0,0 +1,8 @@ +.copy-text { + background: $ui-gray-010; + + & > code { + color: $ui-gray-800; + padding: 14px; + } +} diff --git a/ui/app/styles/core/forms.scss b/ui/app/styles/core/forms.scss index c5ca31916dcd..1105180c1d85 100644 --- a/ui/app/styles/core/forms.scss +++ b/ui/app/styles/core/forms.scss @@ -21,7 +21,7 @@ label { .b-checkbox .is-label { color: $grey-darker; display: inline-block; - font-size: $body-size; // 14px to match designs + font-size: 14px; font-weight: $font-weight-bold; &:not(:last-child) { diff --git a/ui/app/styles/core/helpers.scss b/ui/app/styles/core/helpers.scss index ecc7bd6ad1da..a9c76e02f2e9 100644 --- a/ui/app/styles/core/helpers.scss +++ b/ui/app/styles/core/helpers.scss @@ -168,6 +168,10 @@ .has-top-margin-xl { margin-top: $spacing-xl; } +.has-border-bottom-light { + border-radius: 0; + border-bottom: 1px solid $grey-light; +} .has-border-danger { border: 1px solid $danger; } diff --git a/ui/app/templates/components/transform-edit.hbs b/ui/app/templates/components/transform-edit.hbs index ed12eb4dc18d..1fcdee101ea6 100644 --- a/ui/app/templates/components/transform-edit.hbs +++ b/ui/app/templates/components/transform-edit.hbs @@ -63,4 +63,39 @@ {{/if}} {{/each}}
+ +
+ + {{!-- ARG TODO make these components? --}} +
+

Encode

+
+ + To test the encoding capability of your transformation, use the following command. It will output an encoded_value. + +
+
+ vault write transform/encode/payments value=<enter your value here> + + + +
+
+
+

Decode

+
+ + To test decoding capability of your transformation, use the encoded_value in the following command. It should return your original input. + +
+
+ vault write transform/decode/payments value=<enter your value here> + + + +
+
+
{{/if}} From 72943610b18623454e2f142e97904f78db7be314 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Fri, 7 Aug 2020 11:48:33 -0600 Subject: [PATCH 12/17] create transform-show-transformation component --- .../transform-show-transformation.js | 8 +++ .../templates/components/transform-edit.hbs | 51 +++---------------- .../transform-show-transformation.hbs | 44 ++++++++++++++++ 3 files changed, 58 insertions(+), 45 deletions(-) create mode 100644 ui/app/components/transform-show-transformation.js create mode 100644 ui/app/templates/components/transform-show-transformation.hbs diff --git a/ui/app/components/transform-show-transformation.js b/ui/app/components/transform-show-transformation.js new file mode 100644 index 000000000000..d15a8a29f2e1 --- /dev/null +++ b/ui/app/components/transform-show-transformation.js @@ -0,0 +1,8 @@ +import RoleEdit from './role-edit'; + +export default RoleEdit.extend({ + init() { + this._super(...arguments); + this.set('backendType', 'transform'); + }, +}); diff --git a/ui/app/templates/components/transform-edit.hbs b/ui/app/templates/components/transform-edit.hbs index 1fcdee101ea6..dc68427fe5d6 100644 --- a/ui/app/templates/components/transform-edit.hbs +++ b/ui/app/templates/components/transform-edit.hbs @@ -29,9 +29,12 @@
{{/if}} {{#if model.canDelete}} + {{!-- TODO only allow deletion when not in use by a role --}} Delete transformation @@ -53,49 +56,7 @@ {{#if (or (eq mode 'edit') (eq mode 'create'))}} {{else}} -{{!-- TODO eventually turn this into a component once it's fleshed out --}} -
- {{#each model.transformFieldAttrs as |attr|}} - {{#if (eq attr.type "object")}} - {{info-table-row label=(capitalize (or attr.options.label (humanize (dasherize attr.name)))) value=(stringify (get model attr.name))}} - {{else}} - {{info-table-row label=(capitalize (or attr.options.label (humanize (dasherize attr.name)))) value=(get model attr.name)}} - {{/if}} - {{/each}} -
- -
- - {{!-- ARG TODO make these components? --}} -
-

Encode

-
- - To test the encoding capability of your transformation, use the following command. It will output an encoded_value. - -
-
- vault write transform/encode/payments value=<enter your value here> - - - -
-
-
-

Decode

-
- - To test decoding capability of your transformation, use the encoded_value in the following command. It should return your original input. - -
-
- vault write transform/decode/payments value=<enter your value here> - - - -
-
-
+ {{/if}} diff --git a/ui/app/templates/components/transform-show-transformation.hbs b/ui/app/templates/components/transform-show-transformation.hbs new file mode 100644 index 000000000000..cee7a10053b3 --- /dev/null +++ b/ui/app/templates/components/transform-show-transformation.hbs @@ -0,0 +1,44 @@ +
+ {{#each model.transformFieldAttrs as |attr|}} + {{#if (eq attr.type "object")}} + {{info-table-row label=(capitalize (or attr.options.label (humanize (dasherize attr.name)))) value=(stringify (get model attr.name))}} + {{else}} + {{info-table-row label=(capitalize (or attr.options.label (humanize (dasherize attr.name)))) value=(get model attr.name)}} + {{/if}} + {{/each}} +
+ +
+ + {{!-- ARG TODO make these components? --}} +
+

Encode

+
+ + To test the encoding capability of your transformation, use the following command. It will output an encoded_value. + +
+
+ vault write transform/encode/payments value=<enter your value here> + + + +
+
+
+

Decode

+
+ + To test decoding capability of your transformation, use the encoded_value in the following command. It should return your original input. + +
+
+ vault write transform/decode/payments value=<enter your value here> + + + +
+
+
From 1cafa55096d75c3b0338e884542090dabdff3427 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Mon, 10 Aug 2020 11:26:01 -0600 Subject: [PATCH 13/17] add attachCapabilities to transform model and update transform-transformation-itme list accordingly --- ui/app/helpers/options-for-backend.js | 2 +- ui/app/models/transform.js | 21 ++-- .../transform-transformation-item.hbs | 65 +++++++++++++ .../transform-transformations-item.hbs | 95 ------------------- 4 files changed, 74 insertions(+), 109 deletions(-) create mode 100644 ui/app/templates/partials/secret-list/transform-transformation-item.hbs delete mode 100644 ui/app/templates/partials/secret-list/transform-transformations-item.hbs diff --git a/ui/app/helpers/options-for-backend.js b/ui/app/helpers/options-for-backend.js index 03c458c5a57c..09210d3742b0 100644 --- a/ui/app/helpers/options-for-backend.js +++ b/ui/app/helpers/options-for-backend.js @@ -62,7 +62,7 @@ const SECRET_BACKENDS = { item: 'transform', create: 'Create Transformation', editComponent: 'transform-edit', - listItemPartial: 'partials/secret-list/transform-transformations-item', + listItemPartial: 'partials/secret-list/transform-transformation-item', }, transit: { searchPlaceholder: 'Filter keys', diff --git a/ui/app/models/transform.js b/ui/app/models/transform.js index 1ef3e835212b..ee587e84d1f9 100644 --- a/ui/app/models/transform.js +++ b/ui/app/models/transform.js @@ -3,6 +3,7 @@ import { computed } from '@ember/object'; import DS from 'ember-data'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; +import attachCapabilities from 'vault/lib/attach-capabilities'; const { attr } = DS; @@ -35,7 +36,8 @@ const TWEAK_SOURCE = [ }, ]; -export default DS.Model.extend({ +// export default DS.Model.extend({ +const Model = DS.Model.extend({ // TODO: for now, commenting out openApi info, but keeping here just in case we end up using it. // useOpenAPI: true, // getHelpUrl: function(backend) { @@ -93,17 +95,10 @@ export default DS.Model.extend({ transformFieldAttrs: computed('transformAttrs', function() { return expandAttributeMeta(this, this.get('transformAttrs')); }), - updatePath: lazyCapabilities(apiPath`${'backend'}/transforms/${'id'}`, 'backend', 'id'), - canDelete: alias('updatePath.canDelete'), - canEdit: alias('updatePath.canUpdate'), - canRead: alias('updatePath.canRead'), - - generatePath: lazyCapabilities(apiPath`${'backend'}/creds/${'id'}`, 'backend', 'id'), - canGenerate: alias('generatePath.canUpdate'), - - signPath: lazyCapabilities(apiPath`${'backend'}/sign/${'id'}`, 'backend', 'id'), - canSign: alias('signPath.canUpdate'), + // zeroAddressPath: lazyCapabilities(apiPath`${'backend'}/config/zeroaddress`, 'backend'), + // canEditZeroAddress: alias('zeroAddressPath.canUpdate'), +}); - zeroAddressPath: lazyCapabilities(apiPath`${'backend'}/config/zeroaddress`, 'backend'), - canEditZeroAddress: alias('zeroAddressPath.canUpdate'), +export default attachCapabilities(Model, { + updatePath: apiPath`transform/transformation/${'id'}`, }); diff --git a/ui/app/templates/partials/secret-list/transform-transformation-item.hbs b/ui/app/templates/partials/secret-list/transform-transformation-item.hbs new file mode 100644 index 000000000000..21987c0f6400 --- /dev/null +++ b/ui/app/templates/partials/secret-list/transform-transformation-item.hbs @@ -0,0 +1,65 @@ +{{#linked-block + (concat + "vault.cluster.secrets.backend." + "show" + ) + item.id + class="list-item-row" + data-test-secret-link=item.id + encode=true + queryParams=(secret-query-params backendModel.type) +}} +
+
+ + + {{if (eq item.id ' ') '(self)' (or item.keyWithoutParent item.id)}} + +
+
+ + + + + +
+
+{{/linked-block}} diff --git a/ui/app/templates/partials/secret-list/transform-transformations-item.hbs b/ui/app/templates/partials/secret-list/transform-transformations-item.hbs deleted file mode 100644 index de0041a02b26..000000000000 --- a/ui/app/templates/partials/secret-list/transform-transformations-item.hbs +++ /dev/null @@ -1,95 +0,0 @@ -{{!-- ARG TODO: come back and clean this up, should only see details and should click --}} -{{#linked-block - (concat - "vault.cluster.secrets.backend." - (if item.isFolder "list" "show") - (if (not item.id) "-root") - ) - item.id - class="list-item-row" - data-test-secret-link=item.id - encode=true - queryParams=(secret-query-params backendModel.type) -}} -
-
- {{if (eq item.id ' ') '(self)' (or item.keyWithoutParent item.id)}} - -
-
- - - - - -
-
-{{/linked-block}} From a3de72a115e79cc0c3ad01af6e8994bf3ccb9623 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Mon, 10 Aug 2020 11:32:37 -0600 Subject: [PATCH 14/17] clean up liniting errors --- ui/app/models/transform.js | 3 +- .../transform-transformation-item.hbs | 61 +++++++++---------- 2 files changed, 30 insertions(+), 34 deletions(-) diff --git a/ui/app/models/transform.js b/ui/app/models/transform.js index ee587e84d1f9..fa1cc45eaa8b 100644 --- a/ui/app/models/transform.js +++ b/ui/app/models/transform.js @@ -1,7 +1,6 @@ -import { alias } from '@ember/object/computed'; import { computed } from '@ember/object'; import DS from 'ember-data'; -import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; +import { apiPath } from 'vault/macros/lazy-capabilities'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; import attachCapabilities from 'vault/lib/attach-capabilities'; diff --git a/ui/app/templates/partials/secret-list/transform-transformation-item.hbs b/ui/app/templates/partials/secret-list/transform-transformation-item.hbs index 21987c0f6400..a7c32cc4f1b7 100644 --- a/ui/app/templates/partials/secret-list/transform-transformation-item.hbs +++ b/ui/app/templates/partials/secret-list/transform-transformation-item.hbs @@ -24,41 +24,38 @@
- -
From d3dba7224634263c9491b1c285ab3111849e458c Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Tue, 11 Aug 2020 15:37:32 -0600 Subject: [PATCH 15/17] address pr comments --- ui/app/serializers/transform.js | 11 +-------- ui/app/styles/core/forms.scss | 4 ++-- .../transform-show-transformation.hbs | 24 +++++++++++-------- .../components/transformation-edit.hbs | 2 +- .../transform-transformation-item.hbs | 6 ++--- 5 files changed, 20 insertions(+), 27 deletions(-) diff --git a/ui/app/serializers/transform.js b/ui/app/serializers/transform.js index a9fe0a6793f3..a466cc4d5df9 100644 --- a/ui/app/serializers/transform.js +++ b/ui/app/serializers/transform.js @@ -5,16 +5,7 @@ export default ApplicationSerializer.extend({ if (payload.data.masking_character) { payload.data.masking_character = String.fromCharCode(payload.data.masking_character); } - - if (payload.data.templates && payload.data.templates.length === 1) { - // add space after comma in returned array length one of a string of templates - payload.data.templates[0] = payload.data.templates[0].replace(/,/g, ', '); - } - - // TODO: something similar her for roles, however it's a little tough because each role comes back as an item in an array. - // Also note, the BE is working on a ticket to amend these response, so revisit. - // TODO: QA to make sure this is only normalizing the response and not changing data on edit (e.g. add a space after the comma when rePOST on edit) - + // TODO: the BE is working on a ticket to amend these response, so revisit. return this._super(store, primaryModelClass, payload, id, requestType); }, }); diff --git a/ui/app/styles/core/forms.scss b/ui/app/styles/core/forms.scss index 1105180c1d85..074ae263c9b9 100644 --- a/ui/app/styles/core/forms.scss +++ b/ui/app/styles/core/forms.scss @@ -21,7 +21,7 @@ label { .b-checkbox .is-label { color: $grey-darker; display: inline-block; - font-size: 14px; + font-size: $body-size; font-weight: $font-weight-bold; &:not(:last-child) { @@ -73,7 +73,7 @@ label { .sub-text { color: $grey; margin-bottom: 0.25rem; - font-size: 12px; + font-size: $size-8; } .input, .textarea, diff --git a/ui/app/templates/components/transform-show-transformation.hbs b/ui/app/templates/components/transform-show-transformation.hbs index cee7a10053b3..3b31cd8273c6 100644 --- a/ui/app/templates/components/transform-show-transformation.hbs +++ b/ui/app/templates/components/transform-show-transformation.hbs @@ -19,11 +19,13 @@
- vault write transform/encode/payments value=<enter your value here> - - - + {{#let "vault write transform/encode/payments value=" as |copyEncodeCommand|}} + vault write transform/encode/payments value=<enter your value here> + + + + {{/let}}
@@ -34,11 +36,13 @@
- vault write transform/decode/payments value=<enter your value here> - - - + {{#let "vault write transform/decode/payments value=" as |copyDecodeCommand|}} + vault write transform/decode/payments value=<enter your value here> + + + + {{/let}}
diff --git a/ui/app/templates/components/transformation-edit.hbs b/ui/app/templates/components/transformation-edit.hbs index dc68427fe5d6..1ae25afd377a 100644 --- a/ui/app/templates/components/transformation-edit.hbs +++ b/ui/app/templates/components/transformation-edit.hbs @@ -39,7 +39,7 @@ Delete transformation {{/if}} - {{#if (or model.canUpdate model.canDelete)}} + {{#if model.canUpdate }} Date: Tue, 11 Aug 2020 15:42:11 -0600 Subject: [PATCH 16/17] remove leftover --- ui/app/models/transform.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/app/models/transform.js b/ui/app/models/transform.js index fa1cc45eaa8b..d8637656f81a 100644 --- a/ui/app/models/transform.js +++ b/ui/app/models/transform.js @@ -35,7 +35,6 @@ const TWEAK_SOURCE = [ }, ]; -// export default DS.Model.extend({ const Model = DS.Model.extend({ // TODO: for now, commenting out openApi info, but keeping here just in case we end up using it. // useOpenAPI: true, From d01b83ce6f1d01cf73af3c7b31add1467300fb24 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Tue, 11 Aug 2020 15:45:03 -0600 Subject: [PATCH 17/17] clean up --- ui/app/templates/components/transform-edit-form.hbs | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/app/templates/components/transform-edit-form.hbs b/ui/app/templates/components/transform-edit-form.hbs index 9f559fe4dd1a..a35e16c68245 100644 --- a/ui/app/templates/components/transform-edit-form.hbs +++ b/ui/app/templates/components/transform-edit-form.hbs @@ -10,7 +10,6 @@ @model={{model}} /> {{/each}} - {{!-- --}}