From 15d115bb392223b5498ef112c5e6078e8067ef8e Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Tue, 18 Jun 2024 15:29:37 -0600 Subject: [PATCH 01/13] initial shuffling of credentials and advanced configuration options --- ui/app/models/sync/destinations/gh.js | 3 +- .../page/destinations/create-and-edit.hbs | 43 +++++++++++++++---- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/ui/app/models/sync/destinations/gh.js b/ui/app/models/sync/destinations/gh.js index 8cd6e7bd147f..f6240b194482 100644 --- a/ui/app/models/sync/destinations/gh.js +++ b/ui/app/models/sync/destinations/gh.js @@ -18,8 +18,9 @@ const displayFields = [ 'secretNameTemplate', ]; const formFieldGroups = [ - { default: ['name', 'repositoryOwner', 'repositoryName', 'granularity', 'secretNameTemplate'] }, + { default: ['name', 'repositoryOwner', 'repositoryName'] }, { Credentials: ['accessToken'] }, + { config: ['granularity', 'secretNameTemplate'] }, ]; @withFormFields(displayFields, formFieldGroups) diff --git a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs index 5593fa591176..ee77c27be0b7 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs +++ b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs @@ -12,18 +12,27 @@ {{#each @destination.formFieldGroups as |fieldGroup|}} {{#each-in fieldGroup as |group fields|}} - {{#if (and (eq group "Credentials") (not @destination.isNew))}} + {{! titles for groups to be displayed in both create and edit }} + {{#if (eq group "Credentials")}}
Credentials - Connection credentials are sensitive information and the value cannot be read. Enable the input to update. + Connection credentials are sensitive information + {{#if @destination.isNew}} used to authenticate with the destination. {{else}} + and the value cannot be read. Enable the input to update. + {{/if}} - {{#each fields as |attr|}} - - - - {{/each}} - {{else}} + {{/if}} + + {{#if (eq group "config")}} +
+ Advanced configuration + + Configuration options for the destination. + + {{/if}} + {{! CREATE }} + {{#if @destination.isNew}} {{#each fields as |attr|}} {{/each}} + {{else}} + {{! EDIT }} + {{#if (eq group "Credentials")}} + {{#each fields as |attr|}} + + + + {{/each}} + {{else}} + {{#each fields as |attr|}} + + {{/each}} + {{/if}} {{/if}} {{/each-in}} {{/each}} From af4c517628f6d64ea2f0e22c11e1f8a576e39f89 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Tue, 18 Jun 2024 18:53:57 -0600 Subject: [PATCH 02/13] update all destination models --- ui/app/models/sync/destination.js | 7 ++++++ ui/app/models/sync/destinations/aws-sm.js | 12 ++++------ ui/app/models/sync/destinations/azure-kv.js | 22 ++++--------------- ui/app/models/sync/destinations/gcp-sm.js | 13 ++++------- ui/app/models/sync/destinations/gh.js | 6 +++-- .../page/destinations/create-and-edit.hbs | 5 ++--- 6 files changed, 25 insertions(+), 40 deletions(-) diff --git a/ui/app/models/sync/destination.js b/ui/app/models/sync/destination.js index 086bd69e2221..04bcfb88db98 100644 --- a/ui/app/models/sync/destination.js +++ b/ui/app/models/sync/destination.js @@ -29,6 +29,13 @@ export default class SyncDestinationModel extends Model { }) secretNameTemplate; + @attr('object', { + subText: + 'An optional set of informational key-value pairs added as additional metadata on secrets synced to this destination. Custom tags are merged with built-in tags.', + editType: 'kv', + }) + customTags; + @attr('string', { editType: 'radio', label: 'Secret sync granularity', diff --git a/ui/app/models/sync/destinations/aws-sm.js b/ui/app/models/sync/destinations/aws-sm.js index 5574d19a2e53..e0ec10a7117a 100644 --- a/ui/app/models/sync/destinations/aws-sm.js +++ b/ui/app/models/sync/destinations/aws-sm.js @@ -7,6 +7,7 @@ import SyncDestinationModel from '../destination'; import { attr } from '@ember-data/model'; import { withFormFields } from 'vault/decorators/model-form-fields'; +// displayFields are used on the destination details view const displayFields = [ // connection details 'name', @@ -20,11 +21,13 @@ const displayFields = [ 'secretNameTemplate', 'customTags', ]; +// formFieldGroups are used on the create-edit destination view const formFieldGroups = [ { - default: ['name', 'region', 'roleArn', 'externalId', 'granularity', 'secretNameTemplate', 'customTags'], + default: ['name', 'region', 'roleArn', 'externalId'], }, { Credentials: ['accessKeyId', 'secretAccessKey'] }, + { config: ['granularity', 'secretNameTemplate', 'customTags'] }, ]; @withFormFields(displayFields, formFieldGroups) export default class SyncDestinationsAwsSecretsManagerModel extends SyncDestinationModel { @@ -53,13 +56,6 @@ export default class SyncDestinationsAwsSecretsManagerModel extends SyncDestinat }) region; - @attr('object', { - subText: - 'An optional set of informational key-value pairs added as additional metadata on secrets synced to this destination. Custom tags are merged with built-in tags.', - editType: 'kv', - }) - customTags; - @attr('string', { label: 'Role ARN', subText: diff --git a/ui/app/models/sync/destinations/azure-kv.js b/ui/app/models/sync/destinations/azure-kv.js index fa363d695909..ac34c73146f7 100644 --- a/ui/app/models/sync/destinations/azure-kv.js +++ b/ui/app/models/sync/destinations/azure-kv.js @@ -6,7 +6,7 @@ import SyncDestinationModel from '../destination'; import { attr } from '@ember-data/model'; import { withFormFields } from 'vault/decorators/model-form-fields'; - +// displayFields are used on the destination details view const displayFields = [ // connection details 'name', @@ -20,20 +20,13 @@ const displayFields = [ 'secretNameTemplate', 'customTags', ]; +// formFieldGroups are used on the create-edit destination view const formFieldGroups = [ { - default: [ - 'name', - 'keyVaultUri', - 'tenantId', - 'cloud', - 'clientId', - 'granularity', - 'secretNameTemplate', - 'customTags', - ], + default: ['name', 'keyVaultUri', 'tenantId', 'cloud', 'clientId'], }, { Credentials: ['clientSecret'] }, + { config: ['granularity', 'secretNameTemplate', 'customTags'] }, ]; @withFormFields(displayFields, formFieldGroups) export default class SyncDestinationsAzureKeyVaultModel extends SyncDestinationModel { @@ -73,11 +66,4 @@ export default class SyncDestinationsAzureKeyVaultModel extends SyncDestinationM editDisabled: true, }) cloud; - - @attr('object', { - subText: - 'An optional set of informational key-value pairs added as additional metadata on secrets synced to this destination. Custom tags are merged with built-in tags.', - editType: 'kv', - }) - customTags; } diff --git a/ui/app/models/sync/destinations/gcp-sm.js b/ui/app/models/sync/destinations/gcp-sm.js index 6de8200eeb5d..b66935c55b2d 100644 --- a/ui/app/models/sync/destinations/gcp-sm.js +++ b/ui/app/models/sync/destinations/gcp-sm.js @@ -6,7 +6,7 @@ import SyncDestinationModel from '../destination'; import { attr } from '@ember-data/model'; import { withFormFields } from 'vault/decorators/model-form-fields'; - +// displayFields are used on the destination details view const displayFields = [ // connection details 'name', @@ -17,9 +17,11 @@ const displayFields = [ 'secretNameTemplate', 'customTags', ]; +// formFieldGroups are used on the create-edit destination view const formFieldGroups = [ - { default: ['name', 'projectId', 'granularity', 'secretNameTemplate', 'customTags'] }, + { default: ['name', 'projectId'] }, { Credentials: ['credentials'] }, + { config: ['granularity', 'secretNameTemplate', 'customTags'] }, ]; @withFormFields(displayFields, formFieldGroups) export default class SyncDestinationsGoogleCloudSecretManagerModel extends SyncDestinationModel { @@ -38,11 +40,4 @@ export default class SyncDestinationsGoogleCloudSecretManagerModel extends SyncD docLink: '/vault/docs/secrets/gcp#authentication', }) credentials; // obfuscated, never returned by API. Masking handled by EnableInput component - - @attr('object', { - subText: - 'An optional set of informational key-value pairs added as additional metadata on secrets synced to this destination. Custom tags are merged with built-in tags.', - editType: 'kv', - }) - customTags; } diff --git a/ui/app/models/sync/destinations/gh.js b/ui/app/models/sync/destinations/gh.js index f6240b194482..18dd2b619a64 100644 --- a/ui/app/models/sync/destinations/gh.js +++ b/ui/app/models/sync/destinations/gh.js @@ -6,7 +6,7 @@ import SyncDestinationModel from '../destination'; import { attr } from '@ember-data/model'; import { withFormFields } from 'vault/decorators/model-form-fields'; - +// displayFields are used on the destination details view const displayFields = [ // connection details 'name', @@ -17,10 +17,12 @@ const displayFields = [ 'granularity', 'secretNameTemplate', ]; + +// formFieldGroups are used on the create-edit destination view const formFieldGroups = [ { default: ['name', 'repositoryOwner', 'repositoryName'] }, { Credentials: ['accessToken'] }, - { config: ['granularity', 'secretNameTemplate'] }, + { config: ['granularity', 'secretNameTemplate', 'customTags'] }, ]; @withFormFields(displayFields, formFieldGroups) diff --git a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs index ee77c27be0b7..e979e8a233ae 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs +++ b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs @@ -12,7 +12,7 @@ {{#each @destination.formFieldGroups as |fieldGroup|}} {{#each-in fieldGroup as |group fields|}} - {{! titles for groups to be displayed in both create and edit }} + {{! h2 titles Credentials and Configuration for FormFieldGroups to be displayed in both create and edit }} {{#if (eq group "Credentials")}}
Credentials @@ -23,7 +23,6 @@ {{/if}} {{/if}} - {{#if (eq group "config")}}
Advanced configuration @@ -31,7 +30,7 @@ Configuration options for the destination. {{/if}} - {{! CREATE }} + {{! CREATE fields }} {{#if @destination.isNew}} {{#each fields as |attr|}} Date: Tue, 18 Jun 2024 19:20:23 -0600 Subject: [PATCH 03/13] wip changelog --- changelog/27538.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/27538.txt diff --git a/changelog/27538.txt b/changelog/27538.txt new file mode 100644 index 000000000000..8b76d9dc3310 --- /dev/null +++ b/changelog/27538.txt @@ -0,0 +1,3 @@ +```release-note:improvement +ui: TODO xx (unsure all the new fields to be added.) +``` \ No newline at end of file From 895127e64ee923fb49b36c11774867f241ded6c1 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Thu, 20 Jun 2024 09:32:09 -0600 Subject: [PATCH 04/13] Update 27538.txt --- changelog/27538.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog/27538.txt b/changelog/27538.txt index 8b76d9dc3310..e1d14481502c 100644 --- a/changelog/27538.txt +++ b/changelog/27538.txt @@ -1,3 +1,3 @@ ```release-note:improvement -ui: TODO xx (unsure all the new fields to be added.) -``` \ No newline at end of file +ui: Creates separate section for updating sensitive creds for Secrets sync create/edit view. +``` From 19b13f6ddeb0ca93356f0c7fc47609c0ac9a6b2f Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Thu, 20 Jun 2024 09:33:11 -0600 Subject: [PATCH 05/13] remove custom_tags from gh --- ui/app/models/sync/destinations/gh.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/models/sync/destinations/gh.js b/ui/app/models/sync/destinations/gh.js index 18dd2b619a64..87e0f53cd271 100644 --- a/ui/app/models/sync/destinations/gh.js +++ b/ui/app/models/sync/destinations/gh.js @@ -22,7 +22,7 @@ const displayFields = [ const formFieldGroups = [ { default: ['name', 'repositoryOwner', 'repositoryName'] }, { Credentials: ['accessToken'] }, - { config: ['granularity', 'secretNameTemplate', 'customTags'] }, + { config: ['granularity', 'secretNameTemplate'] }, ]; @withFormFields(displayFields, formFieldGroups) From fb3f94719c5f3183a700763a81f709945e3a6272 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Fri, 21 Jun 2024 09:29:18 -0600 Subject: [PATCH 06/13] missed vercel and remove custom_tags from base --- ui/app/models/sync/destination.js | 7 ------- ui/app/models/sync/destinations/aws-sm.js | 7 +++++++ ui/app/models/sync/destinations/azure-kv.js | 7 +++++++ ui/app/models/sync/destinations/gcp-sm.js | 7 +++++++ ui/app/models/sync/destinations/vercel-project.js | 6 ++++-- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/ui/app/models/sync/destination.js b/ui/app/models/sync/destination.js index 04bcfb88db98..086bd69e2221 100644 --- a/ui/app/models/sync/destination.js +++ b/ui/app/models/sync/destination.js @@ -29,13 +29,6 @@ export default class SyncDestinationModel extends Model { }) secretNameTemplate; - @attr('object', { - subText: - 'An optional set of informational key-value pairs added as additional metadata on secrets synced to this destination. Custom tags are merged with built-in tags.', - editType: 'kv', - }) - customTags; - @attr('string', { editType: 'radio', label: 'Secret sync granularity', diff --git a/ui/app/models/sync/destinations/aws-sm.js b/ui/app/models/sync/destinations/aws-sm.js index e0ec10a7117a..06a26905918f 100644 --- a/ui/app/models/sync/destinations/aws-sm.js +++ b/ui/app/models/sync/destinations/aws-sm.js @@ -56,6 +56,13 @@ export default class SyncDestinationsAwsSecretsManagerModel extends SyncDestinat }) region; + @attr('object', { + subText: + 'An optional set of informational key-value pairs added as additional metadata on secrets synced to this destination. Custom tags are merged with built-in tags.', + editType: 'kv', + }) + customTags; + @attr('string', { label: 'Role ARN', subText: diff --git a/ui/app/models/sync/destinations/azure-kv.js b/ui/app/models/sync/destinations/azure-kv.js index ac34c73146f7..a27f584fc1d7 100644 --- a/ui/app/models/sync/destinations/azure-kv.js +++ b/ui/app/models/sync/destinations/azure-kv.js @@ -66,4 +66,11 @@ export default class SyncDestinationsAzureKeyVaultModel extends SyncDestinationM editDisabled: true, }) cloud; + + @attr('object', { + subText: + 'An optional set of informational key-value pairs added as additional metadata on secrets synced to this destination. Custom tags are merged with built-in tags.', + editType: 'kv', + }) + customTags; } diff --git a/ui/app/models/sync/destinations/gcp-sm.js b/ui/app/models/sync/destinations/gcp-sm.js index b66935c55b2d..c5157d874cc6 100644 --- a/ui/app/models/sync/destinations/gcp-sm.js +++ b/ui/app/models/sync/destinations/gcp-sm.js @@ -40,4 +40,11 @@ export default class SyncDestinationsGoogleCloudSecretManagerModel extends SyncD docLink: '/vault/docs/secrets/gcp#authentication', }) credentials; // obfuscated, never returned by API. Masking handled by EnableInput component + + @attr('object', { + subText: + 'An optional set of informational key-value pairs added as additional metadata on secrets synced to this destination. Custom tags are merged with built-in tags.', + editType: 'kv', + }) + customTags; } diff --git a/ui/app/models/sync/destinations/vercel-project.js b/ui/app/models/sync/destinations/vercel-project.js index b788a780c41f..70e6d373ec8d 100644 --- a/ui/app/models/sync/destinations/vercel-project.js +++ b/ui/app/models/sync/destinations/vercel-project.js @@ -21,7 +21,7 @@ const validations = { // getter/setter for the deploymentEnvironments model attribute deploymentEnvironmentsArray: [{ type: 'presence', message: 'At least one environment is required.' }], }; - +// displayFields are used on the destination details view const displayFields = [ // connection details 'name', @@ -33,9 +33,11 @@ const displayFields = [ 'granularity', 'secretNameTemplate', ]; +// formFieldGroups are used on the create-edit destination view const formFieldGroups = [ - { default: ['name', 'projectId', 'teamId', 'deploymentEnvironments', 'granularity', 'secretNameTemplate'] }, + { default: ['name', 'projectId', 'teamId', 'deploymentEnvironments'] }, { Credentials: ['accessToken'] }, + { config: ['granularity', 'secretNameTemplate'] }, ]; @withModelValidations(validations) @withFormFields(displayFields, formFieldGroups) From 466c17ddd2054c4c6eb9f824c3cc0db1b2606628 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 26 Jun 2024 10:33:14 -0600 Subject: [PATCH 07/13] refactor conditional logic on templace --- .../page/destinations/create-and-edit.hbs | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs index e979e8a233ae..92cbfe855067 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs +++ b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs @@ -31,34 +31,20 @@ {{/if}} {{! CREATE fields }} - {{#if @destination.isNew}} - {{#each fields as |attr|}} + {{#each fields as |attr|}} + {{#if (and (eq group "Credentials") (not @destination.isNew))}} + + + + {{else}} - {{/each}} - {{else}} - {{! EDIT }} - {{#if (eq group "Credentials")}} - {{#each fields as |attr|}} - - - - {{/each}} - {{else}} - {{#each fields as |attr|}} - - {{/each}} {{/if}} - {{/if}} + {{/each}} {{/each-in}} {{/each}} From 4c1712ef08b6c93754eb049fb24a6c177d76c745 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 26 Jun 2024 11:14:01 -0600 Subject: [PATCH 08/13] things --- ui/app/models/sync/destinations/aws-sm.js | 2 +- ui/app/models/sync/destinations/azure-kv.js | 2 +- ui/app/models/sync/destinations/gcp-sm.js | 2 +- ui/app/models/sync/destinations/gh.js | 2 +- .../models/sync/destinations/vercel-project.js | 2 +- .../page/destinations/create-and-edit.hbs | 17 +++-------------- .../page/destinations/create-and-edit.ts | 11 +++++++++++ 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ui/app/models/sync/destinations/aws-sm.js b/ui/app/models/sync/destinations/aws-sm.js index 06a26905918f..2cb37a79a5dd 100644 --- a/ui/app/models/sync/destinations/aws-sm.js +++ b/ui/app/models/sync/destinations/aws-sm.js @@ -27,7 +27,7 @@ const formFieldGroups = [ default: ['name', 'region', 'roleArn', 'externalId'], }, { Credentials: ['accessKeyId', 'secretAccessKey'] }, - { config: ['granularity', 'secretNameTemplate', 'customTags'] }, + { 'Advanced configuration': ['granularity', 'secretNameTemplate', 'customTags'] }, ]; @withFormFields(displayFields, formFieldGroups) export default class SyncDestinationsAwsSecretsManagerModel extends SyncDestinationModel { diff --git a/ui/app/models/sync/destinations/azure-kv.js b/ui/app/models/sync/destinations/azure-kv.js index a27f584fc1d7..0fcf98e447a6 100644 --- a/ui/app/models/sync/destinations/azure-kv.js +++ b/ui/app/models/sync/destinations/azure-kv.js @@ -26,7 +26,7 @@ const formFieldGroups = [ default: ['name', 'keyVaultUri', 'tenantId', 'cloud', 'clientId'], }, { Credentials: ['clientSecret'] }, - { config: ['granularity', 'secretNameTemplate', 'customTags'] }, + { 'Advanced configuration': ['granularity', 'secretNameTemplate', 'customTags'] }, ]; @withFormFields(displayFields, formFieldGroups) export default class SyncDestinationsAzureKeyVaultModel extends SyncDestinationModel { diff --git a/ui/app/models/sync/destinations/gcp-sm.js b/ui/app/models/sync/destinations/gcp-sm.js index c5157d874cc6..784dd24857e2 100644 --- a/ui/app/models/sync/destinations/gcp-sm.js +++ b/ui/app/models/sync/destinations/gcp-sm.js @@ -21,7 +21,7 @@ const displayFields = [ const formFieldGroups = [ { default: ['name', 'projectId'] }, { Credentials: ['credentials'] }, - { config: ['granularity', 'secretNameTemplate', 'customTags'] }, + { 'Advanced configuration': ['granularity', 'secretNameTemplate', 'customTags'] }, ]; @withFormFields(displayFields, formFieldGroups) export default class SyncDestinationsGoogleCloudSecretManagerModel extends SyncDestinationModel { diff --git a/ui/app/models/sync/destinations/gh.js b/ui/app/models/sync/destinations/gh.js index 87e0f53cd271..5815b8e9b097 100644 --- a/ui/app/models/sync/destinations/gh.js +++ b/ui/app/models/sync/destinations/gh.js @@ -22,7 +22,7 @@ const displayFields = [ const formFieldGroups = [ { default: ['name', 'repositoryOwner', 'repositoryName'] }, { Credentials: ['accessToken'] }, - { config: ['granularity', 'secretNameTemplate'] }, + { 'Advanced configuration': ['granularity', 'secretNameTemplate'] }, ]; @withFormFields(displayFields, formFieldGroups) diff --git a/ui/app/models/sync/destinations/vercel-project.js b/ui/app/models/sync/destinations/vercel-project.js index 70e6d373ec8d..8599ff202d4e 100644 --- a/ui/app/models/sync/destinations/vercel-project.js +++ b/ui/app/models/sync/destinations/vercel-project.js @@ -37,7 +37,7 @@ const displayFields = [ const formFieldGroups = [ { default: ['name', 'projectId', 'teamId', 'deploymentEnvironments'] }, { Credentials: ['accessToken'] }, - { config: ['granularity', 'secretNameTemplate'] }, + { 'Advanced configuration': ['granularity', 'secretNameTemplate'] }, ]; @withModelValidations(validations) @withFormFields(displayFields, formFieldGroups) diff --git a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs index 92cbfe855067..3f87ff83a179 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs +++ b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs @@ -12,22 +12,11 @@ {{#each @destination.formFieldGroups as |fieldGroup|}} {{#each-in fieldGroup as |group fields|}} - {{! h2 titles Credentials and Configuration for FormFieldGroups to be displayed in both create and edit }} - {{#if (eq group "Credentials")}} + {{#if (not-eq group "default")}}
- Credentials + {{group}} - Connection credentials are sensitive information - {{#if @destination.isNew}} used to authenticate with the destination. {{else}} - and the value cannot be read. Enable the input to update. - {{/if}} - - {{/if}} - {{#if (eq group "config")}} -
- Advanced configuration - - Configuration options for the destination. + {{(this.groupSubtext group)}} {{/if}} {{! CREATE fields }} diff --git a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.ts b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.ts index 35d7d4221e7c..3335843cbcd4 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.ts +++ b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.ts @@ -56,6 +56,17 @@ export default class DestinationsCreateForm extends Component { }; } + groupSubtext(group: string) { + switch (group) { + case 'Advanced configuration': + return 'Configuration options for the destination.'; + case 'Credentials': + return 'Connection credentials are sensitive information used to authenticate with the destination.'; + default: + return ''; + } + } + @task @waitFor *save(event: Event) { From 6ebf0e2216c27d6aac1a005414744ef0710f707f Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 26 Jun 2024 15:57:33 -0600 Subject: [PATCH 09/13] test coverage and dynamic subText --- .../page/destinations/create-and-edit.hbs | 10 ++++- .../page/destinations/create-and-edit.ts | 7 +++- ui/tests/helpers/sync/sync-selectors.js | 1 + .../page/destinations/create-and-edit-test.js | 37 ++++++++++++++++--- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs index 3f87ff83a179..0592e020cffa 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs +++ b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs @@ -15,8 +15,14 @@ {{#if (not-eq group "default")}}
{{group}} - - {{(this.groupSubtext group)}} + + {{(this.groupSubtext group @destination.isNew)}} {{/if}} {{! CREATE fields }} diff --git a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.ts b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.ts index 3335843cbcd4..30198e713305 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.ts +++ b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.ts @@ -56,12 +56,15 @@ export default class DestinationsCreateForm extends Component { }; } - groupSubtext(group: string) { + groupSubtext(group: string, isNew: boolean) { + const dynamicText = isNew + ? 'used to authenticate with the destination' + : 'and the value cannot be read. Enable the input to update'; switch (group) { case 'Advanced configuration': return 'Configuration options for the destination.'; case 'Credentials': - return 'Connection credentials are sensitive information used to authenticate with the destination.'; + return `Connection credentials are sensitive information ${dynamicText}.`; default: return ''; } diff --git a/ui/tests/helpers/sync/sync-selectors.js b/ui/tests/helpers/sync/sync-selectors.js index db3658f9a3ee..7b702fa805e4 100644 --- a/ui/tests/helpers/sync/sync-selectors.js +++ b/ui/tests/helpers/sync/sync-selectors.js @@ -86,6 +86,7 @@ export const PAGE = { toolbar: (btnText) => `[data-test-toolbar="${btnText}"]`, form: { enableInput: (attr) => `[data-test-enable-field="${attr}"] [data-test-icon="edit"]`, + fieldGroupSubtext: (group) => `[data-test-destination-subText="${group}"]`, fillInByAttr: async (attr, value) => { // for handling more complex form input elements by attr name switch (attr) { diff --git a/ui/tests/integration/components/sync/secrets/page/destinations/create-and-edit-test.js b/ui/tests/integration/components/sync/secrets/page/destinations/create-and-edit-test.js index 46c86a0398cc..c171c5f6f15e 100644 --- a/ui/tests/integration/components/sync/secrets/page/destinations/create-and-edit-test.js +++ b/ui/tests/integration/components/sync/secrets/page/destinations/create-and-edit-test.js @@ -56,23 +56,48 @@ module('Integration | Component | sync | Secrets::Page::Destinations::CreateAndE assert.true(transition, 'transitions to vault.cluster.sync.secrets.destinations.create on cancel'); }); + test('create: it renders fieldGroups subtext', async function (assert) { + assert.expect(2); + const { type } = SYNC_DESTINATIONS[0]; + this.model = this.store.createRecord(`sync/destinations/${type}`, { type }); + + await this.renderFormComponent(); + + assert + .dom(PAGE.form.fieldGroupSubtext('Credentials')) + .hasText('Connection credentials are sensitive information used to authenticate with the destination.'); + assert + .dom(PAGE.form.fieldGroupSubtext('Advanced configuration')) + .hasText('Configuration options for the destination.'); + }); + test('edit: it renders and navigates back to details on cancel', async function (assert) { - assert.expect(4); + assert.expect(3); this.model = this.generateModel(); await this.renderFormComponent(); assert.dom(PAGE.breadcrumbs).hasText('Secrets Sync Destinations Destination Edit Destination'); assert.dom('h2').hasText('Credentials', 'renders credentials section on edit'); - assert - .dom('p.hds-foreground-faint') - .hasText( - 'Connection credentials are sensitive information and the value cannot be read. Enable the input to update.' - ); await click(PAGE.cancelButton); const transition = this.transitionStub.calledWith('vault.cluster.sync.secrets.destinations.destination'); assert.true(transition, 'transitions to vault.cluster.sync.secrets.destinations.destination on cancel'); }); + test('edit: it renders fieldGroup subtext', async function (assert) { + assert.expect(2); + const { type } = SYNC_DESTINATIONS[0]; + this.model = this.store.createRecord(`sync/destinations/${type}`, { type }); + + await this.renderFormComponent(); + + assert + .dom(PAGE.form.fieldGroupSubtext('Credentials')) + .hasText('Connection credentials are sensitive information used to authenticate with the destination.'); + assert + .dom(PAGE.form.fieldGroupSubtext('Advanced configuration')) + .hasText('Configuration options for the destination.'); + }); + test('edit: it PATCH updates custom_tags', async function (assert) { assert.expect(1); this.model = this.generateModel(); From b2887c959e960d2404d6a27ea4cad259d98e698a Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 26 Jun 2024 16:04:57 -0600 Subject: [PATCH 10/13] add assert to not see enableInput on create --- .../sync/secrets/page/destinations/create-and-edit-test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/tests/integration/components/sync/secrets/page/destinations/create-and-edit-test.js b/ui/tests/integration/components/sync/secrets/page/destinations/create-and-edit-test.js index c171c5f6f15e..0c42204592f6 100644 --- a/ui/tests/integration/components/sync/secrets/page/destinations/create-and-edit-test.js +++ b/ui/tests/integration/components/sync/secrets/page/destinations/create-and-edit-test.js @@ -261,7 +261,7 @@ module('Integration | Component | sync | Secrets::Page::Destinations::CreateAndE const filteredObfuscatedFields = this.model.formFields.filter((field) => obfuscatedFields.includes(field.name) ); - assert.expect(filteredObfuscatedFields.length); + assert.expect(filteredObfuscatedFields.length * 2); await this.renderFormComponent(); // iterate over the form fields and filter for those that are obfuscated // fill those in and assert that they are masked @@ -271,6 +271,9 @@ module('Integration | Component | sync | Secrets::Page::Destinations::CreateAndE assert .dom(PAGE.maskedInput(field.name)) .hasClass('masked-font', `it renders ${field.name} for ${destination} with masked font`); + assert + .dom(PAGE.form.enableInput(field.name)) + .doesNotExist(`it does not render enable input for ${field.name}`); }); }); From 5d653fec351bdc4edae70972af3466315f481def Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 26 Jun 2024 16:21:09 -0600 Subject: [PATCH 11/13] clean up --- .../components/secrets/page/destinations/create-and-edit.hbs | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs index 0592e020cffa..a87bb3b66bc9 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs +++ b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs @@ -25,7 +25,6 @@ {{(this.groupSubtext group @destination.isNew)}} {{/if}} - {{! CREATE fields }} {{#each fields as |attr|}} {{#if (and (eq group "Credentials") (not @destination.isNew))}} From 2acb753a9c1b6d439e188df46a121ee8b6f6c148 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Thu, 27 Jun 2024 10:25:10 -0600 Subject: [PATCH 12/13] remove extra parens --- .../components/secrets/page/destinations/create-and-edit.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs index a87bb3b66bc9..08c015a992b8 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs +++ b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs @@ -22,7 +22,7 @@ class="has-bottom-margin-m" data-test-destination-subText={{group}} > - {{(this.groupSubtext group @destination.isNew)}} + {{this.groupSubtext group @destination.isNew}} {{/if}} {{#each fields as |attr|}} From ddf4757265dbed2c24f83b5bb88d5c564e8f19f3 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Thu, 27 Jun 2024 11:34:23 -0600 Subject: [PATCH 13/13] test clean up to clarify what the header subtext vs breadcrumb transition are testing --- .../page/destinations/create-and-edit.hbs | 7 +++- ui/tests/helpers/sync/sync-selectors.js | 1 + .../page/destinations/create-and-edit-test.js | 37 ++++++++++++------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs index 08c015a992b8..1349b170f14f 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs +++ b/ui/lib/sync/addon/components/secrets/page/destinations/create-and-edit.hbs @@ -14,7 +14,12 @@ {{#each-in fieldGroup as |group fields|}} {{#if (not-eq group "default")}}
- {{group}} + {{group}} `[data-test-toolbar="${btnText}"]`, form: { enableInput: (attr) => `[data-test-enable-field="${attr}"] [data-test-icon="edit"]`, + fieldGroupHeader: (group) => `[data-test-destination-header="${group}"]`, fieldGroupSubtext: (group) => `[data-test-destination-subText="${group}"]`, fillInByAttr: async (attr, value) => { // for handling more complex form input elements by attr name diff --git a/ui/tests/integration/components/sync/secrets/page/destinations/create-and-edit-test.js b/ui/tests/integration/components/sync/secrets/page/destinations/create-and-edit-test.js index 0c42204592f6..302e7faaea0c 100644 --- a/ui/tests/integration/components/sync/secrets/page/destinations/create-and-edit-test.js +++ b/ui/tests/integration/components/sync/secrets/page/destinations/create-and-edit-test.js @@ -44,7 +44,7 @@ module('Integration | Component | sync | Secrets::Page::Destinations::CreateAndE }; }); - test('create: it renders and navigates back to create on cancel', async function (assert) { + test('create: it renders breadcrumbs and navigates back to create on cancel', async function (assert) { assert.expect(2); const { type } = SYNC_DESTINATIONS[0]; this.model = this.store.createRecord(`sync/destinations/${type}`, { type }); @@ -56,13 +56,18 @@ module('Integration | Component | sync | Secrets::Page::Destinations::CreateAndE assert.true(transition, 'transitions to vault.cluster.sync.secrets.destinations.create on cancel'); }); - test('create: it renders fieldGroups subtext', async function (assert) { - assert.expect(2); + test('create: it renders headers and fieldGroups subtext', async function (assert) { + assert.expect(4); const { type } = SYNC_DESTINATIONS[0]; this.model = this.store.createRecord(`sync/destinations/${type}`, { type }); await this.renderFormComponent(); - + assert + .dom(PAGE.form.fieldGroupHeader('Credentials')) + .hasText('Credentials', 'renders credentials section on create'); + assert + .dom(PAGE.form.fieldGroupHeader('Advanced configuration')) + .hasText('Advanced configuration', 'renders advanced configuration section on create'); assert .dom(PAGE.form.fieldGroupSubtext('Credentials')) .hasText('Connection credentials are sensitive information used to authenticate with the destination.'); @@ -71,28 +76,34 @@ module('Integration | Component | sync | Secrets::Page::Destinations::CreateAndE .hasText('Configuration options for the destination.'); }); - test('edit: it renders and navigates back to details on cancel', async function (assert) { - assert.expect(3); + test('edit: it renders breadcrumbs and navigates back to details on cancel', async function (assert) { + assert.expect(2); this.model = this.generateModel(); await this.renderFormComponent(); assert.dom(PAGE.breadcrumbs).hasText('Secrets Sync Destinations Destination Edit Destination'); - assert.dom('h2').hasText('Credentials', 'renders credentials section on edit'); + await click(PAGE.cancelButton); const transition = this.transitionStub.calledWith('vault.cluster.sync.secrets.destinations.destination'); assert.true(transition, 'transitions to vault.cluster.sync.secrets.destinations.destination on cancel'); }); - test('edit: it renders fieldGroup subtext', async function (assert) { - assert.expect(2); - const { type } = SYNC_DESTINATIONS[0]; - this.model = this.store.createRecord(`sync/destinations/${type}`, { type }); + test('edit: it renders headers and fieldGroup subtext', async function (assert) { + assert.expect(4); + this.model = this.generateModel(); await this.renderFormComponent(); - + assert + .dom(PAGE.form.fieldGroupHeader('Credentials')) + .hasText('Credentials', 'renders credentials section on edit'); + assert + .dom(PAGE.form.fieldGroupHeader('Advanced configuration')) + .hasText('Advanced configuration', 'renders advanced configuration section on edit'); assert .dom(PAGE.form.fieldGroupSubtext('Credentials')) - .hasText('Connection credentials are sensitive information used to authenticate with the destination.'); + .hasText( + 'Connection credentials are sensitive information and the value cannot be read. Enable the input to update.' + ); assert .dom(PAGE.form.fieldGroupSubtext('Advanced configuration')) .hasText('Configuration options for the destination.');