fix(vault-plugin): rework

Signed-off-by: denis.fortin <denis.fortin@adevinta.com>
This commit is contained in:
denis.fortin
2022-06-28 11:43:16 +02:00
parent b5170119fc
commit d1994e7ed1
2 changed files with 8 additions and 11 deletions
+1 -1
View File
@@ -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
@@ -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: (
<Link
aria-label="View"
title={`View ${getSecretRelativeName(secretPath, secret)}`}
title={`View ${secretName}`}
to={secret.showUrl}
>
<Visibility style={{ fontSize: 16 }} />
@@ -74,7 +71,7 @@ export const EntityVaultTable = ({ entity }: { entity: Entity }) => {
edit: (
<Link
aria-label="Edit"
title={`Edit ${getSecretRelativeName(secretPath, secret)}`}
title={`Edit ${secretName}`}
to={secret.editUrl}
>
<Edit style={{ fontSize: 16 }} />