From d1994e7ed11de5cf2c5cc6e3b764aefeceaf997f Mon Sep 17 00:00:00 2001 From: "denis.fortin" Date: Tue, 28 Jun 2022 11:43:16 +0200 Subject: [PATCH] fix(vault-plugin): rework Signed-off-by: denis.fortin --- .changeset/moody-crabs-march.md | 2 +- .../EntityVaultTable/EntityVaultTable.tsx | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.changeset/moody-crabs-march.md b/.changeset/moody-crabs-march.md index f3ae24629a..b5ddf12ffa 100644 --- a/.changeset/moody-crabs-march.md +++ b/.changeset/moody-crabs-march.md @@ -3,4 +3,4 @@ '@backstage/plugin-vault-backend': patch --- -Added a path notion in addition to secret name to allow to differentiate secrets in subpaths +Added a path notion in addition to secret name to allow to differentiate secrets in sub-paths diff --git a/plugins/vault/src/components/EntityVaultTable/EntityVaultTable.tsx b/plugins/vault/src/components/EntityVaultTable/EntityVaultTable.tsx index 5923a4db6b..efc345b07f 100644 --- a/plugins/vault/src/components/EntityVaultTable/EntityVaultTable.tsx +++ b/plugins/vault/src/components/EntityVaultTable/EntityVaultTable.tsx @@ -32,13 +32,6 @@ export const vaultSecretPath = (entity: Entity) => { return { secretPath }; }; -function getSecretRelativeName( - secretPath: string, - secret: VaultSecret, -): string { - return `${secret.path.replace(`${secretPath}/`, '')}/${secret.name}`; -} - export const EntityVaultTable = ({ entity }: { entity: Entity }) => { const vaultApi = useApi(vaultApiRef); const { secretPath } = vaultSecretPath(entity); @@ -60,12 +53,16 @@ export const EntityVaultTable = ({ entity }: { entity: Entity }) => { ]; const data = (value || []).map(secret => { + const secretName = `${secret.path.replace(`${secretPath}/`, '')}/${ + secret.name + }`; + return { - secret: getSecretRelativeName(secretPath, secret), + secret: secretName, view: ( @@ -74,7 +71,7 @@ export const EntityVaultTable = ({ entity }: { entity: Entity }) => { edit: (