From dc5070904b3ab6a8f7876360faada622c49ffdf2 Mon Sep 17 00:00:00 2001 From: claire bontempo <68122737+hellobontempo@users.noreply.github.com> Date: Fri, 23 Feb 2024 13:11:07 -0800 Subject: [PATCH] UI: add default granularity depending on type, add optional to secret_name_template (#25611) * add default granularity depending on type * move default setting to helper * add test coverage for default granularity * update mirage * update secret name template * remove has-text-black class which was making help tooltip black as well --- ui/app/models/sync/destination.js | 11 ++++++---- ui/lib/core/addon/components/form-field.hbs | 2 +- .../core/addon/helpers/sync-destinations.ts | 18 ++++++++++++++-- .../destinations/create/destination.ts | 7 +++++-- ui/mirage/factories/sync-destination.js | 3 ++- .../sync/secrets/destinations-test.js | 21 +++++++++++++++++++ ui/types/vault/helpers/sync-destinations.ts | 1 + 7 files changed, 53 insertions(+), 10 deletions(-) diff --git a/ui/app/models/sync/destination.js b/ui/app/models/sync/destination.js index f040e68c2f..086bd69e22 100644 --- a/ui/app/models/sync/destination.js +++ b/ui/app/models/sync/destination.js @@ -18,13 +18,17 @@ const validations = { @withModelValidations(validations) export default class SyncDestinationModel extends Model { - @attr('string', { subText: 'Specifies the name for this destination.', editDisabled: true }) name; + @attr('string', { subText: 'Specifies the name for this destination.', editDisabled: true }) + name; + @attr type; + @attr('string', { subText: - 'Go-template string that indicates how to format the secret name at the destination. The default template varies by destination type but is generally in the form of "vault--" e.g. "vault-kv-1234-my-secret-1".', + 'Go-template string that indicates how to format the secret name at the destination. The default template varies by destination type but is generally in the form of "vault-{{ .MountAccessor }}-{{ .SecretPath }}" e.g. "vault-kv_9a8f68ad-my-secret-1". Optional.', }) secretNameTemplate; + @attr('string', { editType: 'radio', label: 'Secret sync granularity', @@ -42,9 +46,8 @@ export default class SyncDestinationModel extends Model { value: 'secret-key', }, ], - defaultValue: 'secret-path', }) - granularity; + granularity; // default value depends on type and is set in create route // only present if delete action has been initiated @attr('string') purgeInitiatedAt; diff --git a/ui/lib/core/addon/components/form-field.hbs b/ui/lib/core/addon/components/form-field.hbs index 03cd70cb08..fb63d2e4ff 100644 --- a/ui/lib/core/addon/components/form-field.hbs +++ b/ui/lib/core/addon/components/form-field.hbs @@ -37,7 +37,7 @@