From e6d2caaa52c71c6de0df76e183563e09bb0e65d2 Mon Sep 17 00:00:00 2001 From: claire bontempo <68122737+hellobontempo@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:37:35 -0800 Subject: [PATCH] update overview metric to total secrets instead of associations (#25599) --- .../components/secrets/page/overview.hbs | 12 ++++------ .../sync/addon/templates/secrets/overview.hbs | 2 +- ui/mirage/handlers/sync.js | 24 ++++++++++--------- .../sync/secrets/page/overview-test.js | 9 ++++--- 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/ui/lib/sync/addon/components/secrets/page/overview.hbs b/ui/lib/sync/addon/components/secrets/page/overview.hbs index 941bbfa267..d91c48578a 100644 --- a/ui/lib/sync/addon/components/secrets/page/overview.hbs +++ b/ui/lib/sync/addon/components/secrets/page/overview.hbs @@ -149,21 +149,17 @@ -

- {{or @totalAssociations "None"}} +

+ {{or @totalVaultSecrets "None"}}

diff --git a/ui/lib/sync/addon/templates/secrets/overview.hbs b/ui/lib/sync/addon/templates/secrets/overview.hbs index 2a2b609b51..72f31cc6e4 100644 --- a/ui/lib/sync/addon/templates/secrets/overview.hbs +++ b/ui/lib/sync/addon/templates/secrets/overview.hbs @@ -5,5 +5,5 @@ \ No newline at end of file diff --git a/ui/mirage/handlers/sync.js b/ui/mirage/handlers/sync.js index 4ec06a9a69..86645fa640 100644 --- a/ui/mirage/handlers/sync.js +++ b/ui/mirage/handlers/sync.js @@ -189,23 +189,25 @@ export default function (server) { }); // associations server.get('/sys/sync/associations', (schema) => { - const records = schema.db.syncAssociations.where({}); - if (!records.length) { + const associations = schema.db.syncAssociations.where({}); + if (!associations.length) { return new Response(404, {}, { errors: [] }); } - // for now we only care about the total_associations value + + const secrets = associations.reduce((secrets, association) => { + const secretPath = `${association.mount}/${association.secret_name}`; + if (!secrets.includes(secretPath)) { + secrets.push(secretPath); + } + return secrets; + }, []); + return { data: { key_info: {}, keys: [], - total_associations: records.length, - total_secrets: records.reduce((secrets, association) => { - const secretPath = `${association.mount}/${association.secret_name}`; - if (!secrets.includes(secretPath)) { - secrets.push(secretPath); - } - return secrets; - }, []), + total_associations: associations.length, // link between a secret and a destination + total_secrets: secrets.length, // number of secrets synced from vault (one secret can be synced to multiple destinations) }, }; }); diff --git a/ui/tests/integration/components/sync/secrets/page/overview-test.js b/ui/tests/integration/components/sync/secrets/page/overview-test.js index 709118ed61..ea93bbde20 100644 --- a/ui/tests/integration/components/sync/secrets/page/overview-test.js +++ b/ui/tests/integration/components/sync/secrets/page/overview-test.js @@ -43,7 +43,7 @@ module('Integration | Component | sync | Page::Overview', function (hooks) { this.destinations = await store.query('sync/destination', {}); await render( - hbs``, + hbs``, { owner: this.engine, } @@ -143,9 +143,8 @@ module('Integration | Component | sync | Page::Overview', function (hooks) { count: '6', }, { - cardTitle: 'Total sync associations', - subText: - 'The number of secrets with a configured sync destination. One secret synced to two unique destinations will count as two associations.', + cardTitle: 'Total secrets', + subText: 'The total number of secrets synced from Vault.', // actionText: 'View billing', count: '7', }, @@ -155,7 +154,7 @@ module('Integration | Component | sync | Page::Overview', function (hooks) { assert.dom(title(cardTitle)).hasText(cardTitle, 'Overview card title renders'); assert.dom(description(cardTitle)).hasText(subText, 'Destinations overview card description renders'); assert.dom(content(cardTitle)).hasText(count, 'Total count renders'); - if (cardTitle === 'Total sync associations') return; // uncomment 'actionText' above and this return after SYNC BETA + if (cardTitle === 'Total secrets') return; // uncomment 'actionText' above and this return after SYNC BETA assert.dom(action(cardTitle)).hasText(actionText, 'Card action renders'); }); });