mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
feat: corrected dummy column in overview and main page
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
} from "@app/hooks/api/dashboard/types";
|
||||
import { OrderByDirection } from "@app/hooks/api/generic/types";
|
||||
import { mergePersonalSecrets } from "@app/hooks/api/secrets/queries";
|
||||
import { unique } from "@app/lib/fn/array";
|
||||
|
||||
export const dashboardKeys = {
|
||||
all: () => ["dashboard"] as const,
|
||||
@@ -154,10 +155,24 @@ export const useGetProjectSecretsOverview = (
|
||||
},
|
||||
select: useCallback((data: Awaited<ReturnType<typeof fetchProjectSecretsOverview>>) => {
|
||||
const { secrets, ...select } = data;
|
||||
const uniqueSecrets = secrets
|
||||
? unique(secrets, (i) => `${i.secretKey}:${i.environment}`)
|
||||
: [];
|
||||
|
||||
const uniqueFolders = select.folders
|
||||
? unique(select.folders, (i) => `${i.name}:${i.environment}`)
|
||||
: [];
|
||||
|
||||
const uniqueDynamicSecrets = select.dynamicSecrets
|
||||
? unique(select.dynamicSecrets, (i) => `${i.name}:${i.environment}`)
|
||||
: [];
|
||||
|
||||
return {
|
||||
...select,
|
||||
secrets: secrets ? mergePersonalSecrets(secrets) : undefined
|
||||
secrets: secrets ? mergePersonalSecrets(secrets) : undefined,
|
||||
totalUniqueSecretsInPage: uniqueSecrets.length,
|
||||
totalUniqueDynamicSecretsInPage: uniqueDynamicSecrets.length,
|
||||
totalUniqueFoldersInPage: uniqueFolders.length
|
||||
};
|
||||
}, []),
|
||||
keepPreviousData: true
|
||||
|
||||
@@ -12,6 +12,9 @@ export type DashboardProjectSecretsOverviewResponse = {
|
||||
totalFolderCount?: number;
|
||||
totalDynamicSecretCount?: number;
|
||||
totalCount: number;
|
||||
totalUniqueSecretsInPage: number;
|
||||
totalUniqueDynamicSecretsInPage: number;
|
||||
totalUniqueFoldersInPage: number;
|
||||
};
|
||||
|
||||
export type DashboardProjectSecretsDetailsResponse = {
|
||||
|
||||
@@ -13,3 +13,22 @@ export const groupBy = <T, Key extends string | number | symbol>(
|
||||
acc[groupId].push(item);
|
||||
return acc;
|
||||
}, {} as Record<Key, T[]>);
|
||||
|
||||
/**
|
||||
* Given a list of items returns a new list with only
|
||||
* unique items. Accepts an optional identity function
|
||||
* to convert each item in the list to a comparable identity
|
||||
* value
|
||||
*/
|
||||
export const unique = <T, K extends string | number | symbol>(
|
||||
array: readonly T[],
|
||||
toKey?: (item: T) => K
|
||||
): T[] => {
|
||||
const valueMap = array.reduce((acc, item) => {
|
||||
const key = toKey ? toKey(item) : (item as unknown as string | number | symbol);
|
||||
if (acc[key]) return acc;
|
||||
acc[key] = item;
|
||||
return acc;
|
||||
}, {} as Record<string | number | symbol, T>);
|
||||
return Object.values(valueMap);
|
||||
};
|
||||
|
||||
@@ -409,6 +409,7 @@ export const SecretMainPage = () => {
|
||||
<SecretNoAccessListView
|
||||
count={Math.max(
|
||||
(page * perPage > totalCount ? totalCount % perPage : perPage) -
|
||||
(imports?.length || 0) -
|
||||
(folders?.length || 0) -
|
||||
(secrets?.length || 0) -
|
||||
(dynamicSecrets?.length || 0),
|
||||
|
||||
@@ -71,7 +71,10 @@ import { SecretType, TSecretFolder } from "@app/hooks/api/types";
|
||||
import { ProjectVersion } from "@app/hooks/api/workspace/types";
|
||||
import { useDynamicSecretOverview, useFolderOverview, useSecretOverview } from "@app/hooks/utils";
|
||||
import { SecretOverviewDynamicSecretRow } from "@app/views/SecretOverviewPage/components/SecretOverviewDynamicSecretRow";
|
||||
import { SecretOverviewTableRow } from "@app/views/SecretOverviewPage/components/SecretOverviewTableRow";
|
||||
import {
|
||||
SecretNoAccessOverviewTableRow,
|
||||
SecretOverviewTableRow
|
||||
} from "@app/views/SecretOverviewPage/components/SecretOverviewTableRow";
|
||||
import { SecretTableResourceCount } from "@app/views/SecretOverviewPage/components/SecretTableResourceCount";
|
||||
|
||||
import { FolderForm } from "../SecretMainPage/components/ActionBar/FolderForm";
|
||||
@@ -239,7 +242,10 @@ export const SecretOverviewPage = () => {
|
||||
totalFolderCount,
|
||||
totalSecretCount,
|
||||
totalDynamicSecretCount,
|
||||
totalCount = 0
|
||||
totalCount = 0,
|
||||
totalUniqueFoldersInPage,
|
||||
totalUniqueSecretsInPage,
|
||||
totalUniqueDynamicSecretsInPage
|
||||
} = overview ?? {};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -968,6 +974,16 @@ export const SecretOverviewPage = () => {
|
||||
expandableColWidth={expandableTableWidth}
|
||||
/>
|
||||
))}
|
||||
<SecretNoAccessOverviewTableRow
|
||||
environments={visibleEnvs}
|
||||
count={Math.max(
|
||||
(page * perPage > totalCount ? totalCount % perPage : perPage) -
|
||||
(totalUniqueFoldersInPage || 0) -
|
||||
(totalUniqueDynamicSecretsInPage || 0) -
|
||||
(totalUniqueSecretsInPage || 0),
|
||||
0
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</TBody>
|
||||
|
||||
Reference in New Issue
Block a user