mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Merge pull request #2476 from Infisical/daniel/fix-missing-vars-count
fix(dashboard): fix imports missing secrets counter
This commit is contained in:
@@ -189,6 +189,22 @@ export const useGetImportedSecretsAllEnvs = ({
|
|||||||
}))
|
}))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getEnvImportedSecretKeyCount = useCallback(
|
||||||
|
(env: string) => {
|
||||||
|
const selectedEnvIndex = environments.indexOf(env);
|
||||||
|
let totalSecrets = 0;
|
||||||
|
|
||||||
|
if (selectedEnvIndex !== -1) {
|
||||||
|
secretImports?.[selectedEnvIndex]?.data?.forEach((secret) => {
|
||||||
|
totalSecrets += secret.secrets.length;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalSecrets;
|
||||||
|
},
|
||||||
|
[(secretImports || []).map((response) => response.data)]
|
||||||
|
);
|
||||||
|
|
||||||
const isImportedSecretPresentInEnv = useCallback(
|
const isImportedSecretPresentInEnv = useCallback(
|
||||||
(envSlug: string, secretName: string) => {
|
(envSlug: string, secretName: string) => {
|
||||||
const selectedEnvIndex = environments.indexOf(envSlug);
|
const selectedEnvIndex = environments.indexOf(envSlug);
|
||||||
@@ -226,7 +242,12 @@ export const useGetImportedSecretsAllEnvs = ({
|
|||||||
[(secretImports || []).map((response) => response.data)]
|
[(secretImports || []).map((response) => response.data)]
|
||||||
);
|
);
|
||||||
|
|
||||||
return { secretImports, isImportedSecretPresentInEnv, getImportedSecretByKey };
|
return {
|
||||||
|
secretImports,
|
||||||
|
isImportedSecretPresentInEnv,
|
||||||
|
getImportedSecretByKey,
|
||||||
|
getEnvImportedSecretKeyCount
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useGetImportedFoldersByEnv = ({
|
export const useGetImportedFoldersByEnv = ({
|
||||||
|
|||||||
@@ -207,11 +207,12 @@ export const SecretOverviewPage = () => {
|
|||||||
setVisibleEnvs(readableEnvs);
|
setVisibleEnvs(readableEnvs);
|
||||||
}, [userAvailableEnvs, secretPath]);
|
}, [userAvailableEnvs, secretPath]);
|
||||||
|
|
||||||
const { isImportedSecretPresentInEnv, getImportedSecretByKey } = useGetImportedSecretsAllEnvs({
|
const { isImportedSecretPresentInEnv, getImportedSecretByKey, getEnvImportedSecretKeyCount } =
|
||||||
projectId: workspaceId,
|
useGetImportedSecretsAllEnvs({
|
||||||
path: secretPath,
|
projectId: workspaceId,
|
||||||
environments: userAvailableEnvs.map(({ slug }) => slug)
|
path: secretPath,
|
||||||
});
|
environments: userAvailableEnvs.map(({ slug }) => slug)
|
||||||
|
});
|
||||||
|
|
||||||
const paginationOffset = (page - 1) * perPage;
|
const paginationOffset = (page - 1) * perPage;
|
||||||
|
|
||||||
@@ -784,7 +785,9 @@ export const SecretOverviewPage = () => {
|
|||||||
</Th>
|
</Th>
|
||||||
{visibleEnvs?.map(({ name, slug }, index) => {
|
{visibleEnvs?.map(({ name, slug }, index) => {
|
||||||
const envSecKeyCount = getEnvSecretKeyCount(slug);
|
const envSecKeyCount = getEnvSecretKeyCount(slug);
|
||||||
const missingKeyCount = secKeys.length - envSecKeyCount;
|
const importedSecKeyCount = getEnvImportedSecretKeyCount(slug);
|
||||||
|
const missingKeyCount = secKeys.length - envSecKeyCount - importedSecKeyCount;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Th
|
<Th
|
||||||
className="min-table-row min-w-[11rem] border-b-0 p-0 text-center"
|
className="min-table-row min-w-[11rem] border-b-0 p-0 text-center"
|
||||||
|
|||||||
Reference in New Issue
Block a user