From 2cabfe0143f4980e507fc71e44237edfc2533da4 Mon Sep 17 00:00:00 2001 From: claire bontempo <68122737+hellobontempo@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:07:10 -0700 Subject: [PATCH] Secrets Sync UI: Add purge delete progress and error banner to destination header (#24761) * add deletion in progress banner * update kv details banner to inline alert * add logic for purge error * add params to mirage * comment in purge_initiated_at for mirage * update flash message for deleting * add test for banner * transition to destination associations after delete * redirect to details after delete instead of list * remove attrs from serializer * update mirage handler to mock purge_initiated_at --- ui/app/models/sync/destination.js | 3 ++ ui/app/serializers/sync/destination.js | 2 ++ .../addon/components/page/secret/details.hbs | 2 +- .../components/secrets/destination-header.hbs | 29 ++++++++++++++++ .../components/secrets/destination-header.ts | 8 +++-- .../components/secrets/page/destinations.ts | 6 ++-- .../page/destinations/create-and-edit.ts | 1 + ui/mirage/factories/sync-destination.js | 1 - ui/mirage/handlers/sync.js | 18 ++++++++-- ui/tests/helpers/sync/sync-selectors.js | 1 + .../sync/secrets/destination-header-test.js | 34 +++++++++++++++++-- .../sync/secrets/page/destinations-test.js | 2 +- .../page/destinations/create-and-edit-test.js | 2 +- 13 files changed, 96 insertions(+), 13 deletions(-) diff --git a/ui/app/models/sync/destination.js b/ui/app/models/sync/destination.js index 84d3e8b477..67660017be 100644 --- a/ui/app/models/sync/destination.js +++ b/ui/app/models/sync/destination.js @@ -20,6 +20,9 @@ const validations = { export default class SyncDestinationModel extends Model { @attr('string', { subText: 'Specifies the name for this destination.', editDisabled: true }) name; @attr type; + // only present if delete action has been initiated + @attr('string') purgeInitiatedAt; + @attr('string') purgeError; // findDestination returns static attributes for each destination type get icon() { diff --git a/ui/app/serializers/sync/destination.js b/ui/app/serializers/sync/destination.js index 122730b1cf..e20b1920c5 100644 --- a/ui/app/serializers/sync/destination.js +++ b/ui/app/serializers/sync/destination.js @@ -9,6 +9,8 @@ export default class SyncDestinationSerializer extends ApplicationSerializer { attrs = { name: { serialize: false }, type: { serialize: false }, + purgeInitiatedAt: { serialize: false }, + purgeError: { serialize: false }, }; serialize(snapshot) { diff --git a/ui/lib/kv/addon/components/page/secret/details.hbs b/ui/lib/kv/addon/components/page/secret/details.hbs index af0961bfe5..bac1604191 100644 --- a/ui/lib/kv/addon/components/page/secret/details.hbs +++ b/ui/lib/kv/addon/components/page/secret/details.hbs @@ -6,7 +6,7 @@ <:syncDetails> {{#if this.syncStatus}} - + This secret has been synced from Vault to {{pluralize this.syncStatus.length "destination"}}. Updates to this secret will automatically sync to its diff --git a/ui/lib/sync/addon/components/secrets/destination-header.hbs b/ui/lib/sync/addon/components/secrets/destination-header.hbs index 1a4b40ea66..3e914390ed 100644 --- a/ui/lib/sync/addon/components/secrets/destination-header.hbs +++ b/ui/lib/sync/addon/components/secrets/destination-header.hbs @@ -13,6 +13,35 @@ }} /> +{{#if @destination.purgeInitiatedAt}} + + {{#if @destination.purgeError}} + Deletion failed + + There was a problem with the delete purge initiated at + {{date-format @destination.purgeInitiatedAt "MMM dd, yyyy 'at' hh:mm:ss aaa"}}. + + + {{@destination.purgeError}} + + {{else}} + Deletion in progress + + Purge initiated on + {{date-format @destination.purgeInitiatedAt "MMM dd, yyyy 'at' hh:mm:ss aaa"}}. This process may take some time + depending on how many secrets must be un-synced from this destination. + + {{/if}} + +{{/if}} +