From f0a45fb7d8b9f23f7cf04bac898fad0417f79145 Mon Sep 17 00:00:00 2001 From: x032205 Date: Thu, 22 May 2025 11:32:49 -0400 Subject: [PATCH] Review fixes --- frontend/src/helpers/userTablePreferences.ts | 8 ++++++-- .../kms/KmipPage/components/KmipClientTable.tsx | 10 +++++++--- .../kms/OverviewPage/components/CmekTable.tsx | 10 +++++++--- .../components/OrgGroupsSection/OrgGroupsTable.tsx | 10 +++++++--- .../components/IdentitySection/IdentityTable.tsx | 10 +++++++--- .../OrgMembersSection/OrgMembersTable.tsx | 10 +++++++--- .../components/AppConnectionsTable.tsx | 10 +++++++--- .../GroupMembersSection/GroupMembersTable.tsx | 10 +++++++--- .../IdentityProjectsTable.tsx | 10 +++++++--- .../components/AllProjectView.tsx | 10 +++++++--- .../components/MyProjectView.tsx | 10 +++++++--- .../SecretScanningPage/SecretScanningPage.tsx | 14 +++++++++----- .../UserProjectsSection/UserGroupsTable.tsx | 10 +++++++--- .../UserProjectsSection/UserProjectsTable.tsx | 10 +++++++--- .../components/GroupsSection/GroupsTable.tsx | 10 +++++++--- .../components/IdentityTab/IdentityTab.tsx | 10 +++++++--- .../MembersTab/components/MembersTable.tsx | 10 +++++++--- .../NativeIntegrationsTab/IntegrationsTable.tsx | 10 +++++++--- .../SecretSyncTable/SecretSyncsTable.tsx | 10 +++++++--- .../secret-manager/OverviewPage/OverviewPage.tsx | 10 +++++++--- .../SecretDashboardPage/SecretDashboardPage.tsx | 10 +++++++--- .../SecretTagsSection/SecretTagsTable.tsx | 10 +++++++--- 22 files changed, 155 insertions(+), 67 deletions(-) diff --git a/frontend/src/helpers/userTablePreferences.ts b/frontend/src/helpers/userTablePreferences.ts index 95b219f67..a23438746 100644 --- a/frontend/src/helpers/userTablePreferences.ts +++ b/frontend/src/helpers/userTablePreferences.ts @@ -1,5 +1,9 @@ const TABLE_PREFERENCES_KEY = "userTablePreferences"; +export enum PreferenceKey { + PerPage = "perPage" +} + interface TableSpecificPreferences { [preferenceKey: string]: any; } @@ -33,7 +37,7 @@ const saveAllTablePreferences = (preferences: UserTablePreferences): void => { // Retrieves a specific preference for a given table export const getUserTablePreference = ( tableName: string, - preferenceKey: string, + preferenceKey: PreferenceKey, defaultValue: T ): T => { const preferences = getAllTablePreferences(); @@ -55,7 +59,7 @@ export const getUserTablePreference = ( // Sets a specific preference for a given table and saves it to localStorage export const setUserTablePreference = ( tableName: string, - preferenceKey: string, + preferenceKey: PreferenceKey, value: any ): void => { const preferences = getAllTablePreferences(); diff --git a/frontend/src/pages/kms/KmipPage/components/KmipClientTable.tsx b/frontend/src/pages/kms/KmipPage/components/KmipClientTable.tsx index aae8e81b3..bcc49b11a 100644 --- a/frontend/src/pages/kms/KmipPage/components/KmipClientTable.tsx +++ b/frontend/src/pages/kms/KmipPage/components/KmipClientTable.tsx @@ -43,7 +43,11 @@ import { useSubscription, useWorkspace } from "@app/context"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, usePopUp, useResetPageHelper } from "@app/hooks"; import { OrderByDirection } from "@app/hooks/api/generic/types"; import { useGetKmipClientsByProjectId } from "@app/hooks/api/kmip"; @@ -73,12 +77,12 @@ export const KmipClientTable = () => { page, setPerPage } = usePagination(KmipClientOrderBy.Name, { - initPerPage: getUserTablePreference("kmipClientTable", "perPage", 20) + initPerPage: getUserTablePreference("kmipClientTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("kmipClientTable", "perPage", newPerPage); + setUserTablePreference("kmipClientTable", PreferenceKey.PerPage, newPerPage); }; const { data, isPending, isFetching } = useGetKmipClientsByProjectId({ diff --git a/frontend/src/pages/kms/OverviewPage/components/CmekTable.tsx b/frontend/src/pages/kms/OverviewPage/components/CmekTable.tsx index 248cad09d..e1a2fe789 100644 --- a/frontend/src/pages/kms/OverviewPage/components/CmekTable.tsx +++ b/frontend/src/pages/kms/OverviewPage/components/CmekTable.tsx @@ -53,7 +53,11 @@ import { useWorkspace } from "@app/context"; import { kmsKeyUsageOptions } from "@app/helpers/kms"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, usePopUp, useResetPageHelper, useTimedReset } from "@app/hooks"; import { useGetCmeksByProjectId, useUpdateCmek } from "@app/hooks/api/cmeks"; import { CmekOrderBy, KmsKeyUsage, TCmek } from "@app/hooks/api/cmeks/types"; @@ -102,12 +106,12 @@ export const CmekTable = () => { page, setPerPage } = usePagination(CmekOrderBy.Name, { - initPerPage: getUserTablePreference("cmekClientTable", "perPage", 20) + initPerPage: getUserTablePreference("cmekClientTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("cmekClientTable", "perPage", newPerPage); + setUserTablePreference("cmekClientTable", PreferenceKey.PerPage, newPerPage); }; const { data, isPending, isFetching } = useGetCmeksByProjectId({ diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsTable.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsTable.tsx index 7369bbc11..14de28fd6 100644 --- a/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsTable.tsx +++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsTable.tsx @@ -34,7 +34,11 @@ import { Tr } from "@app/components/v2"; import { OrgPermissionGroupActions, OrgPermissionSubjects, useOrganization } from "@app/context"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, useResetPageHelper } from "@app/hooks"; import { useGetOrganizationGroups, useGetOrgRoles, useUpdateGroup } from "@app/hooks/api"; import { OrderByDirection } from "@app/hooks/api/generic/types"; @@ -105,12 +109,12 @@ export const OrgGroupsTable = ({ handlePopUpOpen }: Props) => { setOrderDirection, toggleOrderDirection } = usePagination(GroupsOrderBy.Name, { - initPerPage: getUserTablePreference("orgGroupsTable", "perPage", 20) + initPerPage: getUserTablePreference("orgGroupsTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("orgGroupsTable", "perPage", newPerPage); + setUserTablePreference("orgGroupsTable", PreferenceKey.PerPage, newPerPage); }; const filteredGroups = useMemo(() => { diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx index 03cd3ac06..d499a7b36 100644 --- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx +++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx @@ -42,7 +42,11 @@ import { Tr } from "@app/components/v2"; import { OrgPermissionIdentityActions, OrgPermissionSubjects, useOrganization } from "@app/context"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, useResetPageHelper } from "@app/hooks"; import { useGetOrgRoles, useSearchIdentities, useUpdateIdentity } from "@app/hooks/api"; import { OrderByDirection } from "@app/hooks/api/generic/types"; @@ -78,12 +82,12 @@ export const IdentityTable = ({ handlePopUpOpen }: Props) => { page, setPerPage } = usePagination(OrgIdentityOrderBy.Name, { - initPerPage: getUserTablePreference("identityTable", "perPage", 20) + initPerPage: getUserTablePreference("identityTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("identityTable", "perPage", newPerPage); + setUserTablePreference("identityTable", PreferenceKey.PerPage, newPerPage); }; const [filteredRoles, setFilteredRoles] = useState([]); diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx index e9c9d1f16..e0350741e 100644 --- a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx +++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx @@ -42,7 +42,11 @@ import { useSubscription, useUser } from "@app/context"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, useResetPageHelper } from "@app/hooks"; import { useFetchServerStatus, @@ -172,12 +176,12 @@ export const OrgMembersTable = ({ handlePopUpOpen, setCompleteInviteLinks }: Pro setOrderDirection, toggleOrderDirection } = usePagination(OrgMembersOrderBy.Name, { - initPerPage: getUserTablePreference("orgMembersTable", "perPage", 20) + initPerPage: getUserTablePreference("orgMembersTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("orgMembersTable", "perPage", newPerPage); + setUserTablePreference("orgMembersTable", PreferenceKey.PerPage, newPerPage); }; const filteredUsers = useMemo( diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionsTable.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionsTable.tsx index ffaac835e..bc448663a 100644 --- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionsTable.tsx +++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionsTable.tsx @@ -30,7 +30,11 @@ import { Tr } from "@app/components/v2"; import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, usePopUp, useResetPageHelper } from "@app/hooks"; import { TAppConnection, useListAppConnections } from "@app/hooks/api/appConnections"; import { AppConnection } from "@app/hooks/api/appConnections/enums"; @@ -78,12 +82,12 @@ export const AppConnectionsTable = () => { setOrderDirection, setOrderBy } = usePagination(AppConnectionsOrderBy.App, { - initPerPage: getUserTablePreference("appConnectionsTable", "perPage", 20) + initPerPage: getUserTablePreference("appConnectionsTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("appConnectionsTable", "perPage", newPerPage); + setUserTablePreference("appConnectionsTable", PreferenceKey.PerPage, newPerPage); }; const filteredAppConnections = useMemo( diff --git a/frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupMembersSection/GroupMembersTable.tsx b/frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupMembersSection/GroupMembersTable.tsx index 360dc95c9..6472c34c1 100644 --- a/frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupMembersSection/GroupMembersTable.tsx +++ b/frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupMembersSection/GroupMembersTable.tsx @@ -25,7 +25,11 @@ import { Tr } from "@app/components/v2"; import { OrgPermissionGroupActions, OrgPermissionSubjects, useOrganization } from "@app/context"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, useResetPageHelper } from "@app/hooks"; import { useListGroupUsers, useOidcManageGroupMembershipsEnabled } from "@app/hooks/api"; import { OrderByDirection } from "@app/hooks/api/generic/types"; @@ -59,12 +63,12 @@ export const GroupMembersTable = ({ groupId, groupSlug, handlePopUpOpen }: Props orderDirection, toggleOrderDirection } = usePagination(GroupMembersOrderBy.Name, { - initPerPage: getUserTablePreference("groupMembersTable", "perPage", 20) + initPerPage: getUserTablePreference("groupMembersTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("groupMembersTable", "perPage", newPerPage); + setUserTablePreference("groupMembersTable", PreferenceKey.PerPage, newPerPage); }; const { currentOrg } = useOrganization(); diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityProjectsSection/IdentityProjectsTable.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityProjectsSection/IdentityProjectsTable.tsx index c32c3226a..ef70d1f96 100644 --- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityProjectsSection/IdentityProjectsTable.tsx +++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityProjectsSection/IdentityProjectsTable.tsx @@ -21,7 +21,11 @@ import { THead, Tr } from "@app/components/v2"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, useResetPageHelper } from "@app/hooks"; import { useGetIdentityProjectMemberships } from "@app/hooks/api"; import { OrderByDirection } from "@app/hooks/api/generic/types"; @@ -55,12 +59,12 @@ export const IdentityProjectsTable = ({ identityId, handlePopUpOpen }: Props) => orderDirection, toggleOrderDirection } = usePagination(IdentityProjectsOrderBy.Name, { - initPerPage: getUserTablePreference("identityProjectsTable", "perPage", 20) + initPerPage: getUserTablePreference("identityProjectsTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("identityProjectsTable", "perPage", newPerPage); + setUserTablePreference("identityProjectsTable", PreferenceKey.PerPage, newPerPage); }; const filteredProjectMemberships = useMemo( diff --git a/frontend/src/pages/organization/SecretManagerOverviewPage/components/AllProjectView.tsx b/frontend/src/pages/organization/SecretManagerOverviewPage/components/AllProjectView.tsx index cf27a9961..6be1a4554 100644 --- a/frontend/src/pages/organization/SecretManagerOverviewPage/components/AllProjectView.tsx +++ b/frontend/src/pages/organization/SecretManagerOverviewPage/components/AllProjectView.tsx @@ -28,7 +28,11 @@ import { } from "@app/components/v2"; import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context"; import { getProjectHomePage } from "@app/helpers/project"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { useDebounce, usePagination, usePopUp, useResetPageHelper } from "@app/hooks"; import { useRequestProjectAccess, useSearchProjects } from "@app/hooks/api"; import { ProjectType, Workspace } from "@app/hooks/api/workspace/types"; @@ -106,12 +110,12 @@ export const AllProjectView = ({ toggleOrderDirection, orderDirection } = usePagination("name", { - initPerPage: getUserTablePreference("allProjectsTable", "perPage", 50) + initPerPage: getUserTablePreference("allProjectsTable", PreferenceKey.PerPage, 50) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("allProjectsTable", "perPage", newPerPage); + setUserTablePreference("allProjectsTable", PreferenceKey.PerPage, newPerPage); }; const { popUp, handlePopUpToggle, handlePopUpOpen } = usePopUp([ diff --git a/frontend/src/pages/organization/SecretManagerOverviewPage/components/MyProjectView.tsx b/frontend/src/pages/organization/SecretManagerOverviewPage/components/MyProjectView.tsx index 3e84e1809..a04b4e196 100644 --- a/frontend/src/pages/organization/SecretManagerOverviewPage/components/MyProjectView.tsx +++ b/frontend/src/pages/organization/SecretManagerOverviewPage/components/MyProjectView.tsx @@ -19,7 +19,11 @@ import { OrgPermissionCan } from "@app/components/permissions"; import { Button, IconButton, Input, Pagination, Skeleton, Tooltip } from "@app/components/v2"; import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context"; import { getProjectHomePage } from "@app/helpers/project"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, useResetPageHelper } from "@app/hooks"; import { useGetUserWorkspaces } from "@app/hooks/api"; import { OrderByDirection } from "@app/hooks/api/generic/types"; @@ -65,12 +69,12 @@ export const MyProjectView = ({ toggleOrderDirection, orderDirection } = usePagination(ProjectOrderBy.Name, { - initPerPage: getUserTablePreference("myProjectsTable", "perPage", 20) + initPerPage: getUserTablePreference("myProjectsTable", PreferenceKey.PerPage, 24) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("myProjectsTable", "perPage", newPerPage); + setUserTablePreference("myProjectsTable", PreferenceKey.PerPage, newPerPage); }; const { data: projectFavorites, isPending: isProjectFavoritesLoading } = diff --git a/frontend/src/pages/organization/SecretScanningPage/SecretScanningPage.tsx b/frontend/src/pages/organization/SecretScanningPage/SecretScanningPage.tsx index 41dec2981..f0ad03677 100644 --- a/frontend/src/pages/organization/SecretScanningPage/SecretScanningPage.tsx +++ b/frontend/src/pages/organization/SecretScanningPage/SecretScanningPage.tsx @@ -13,7 +13,11 @@ import { useOrganization, useServerConfig } from "@app/context"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { withPermission } from "@app/hoc"; import { usePagination, usePopUp } from "@app/hooks"; import { @@ -48,12 +52,12 @@ export const SecretScanningPage = withPermission( const { offset, limit, orderBy, setPage, perPage, page, setPerPage } = usePagination( SecretScanningOrderBy.CreatedAt, - { initPerPage: getUserTablePreference("secretScanningTable", "perPage", 20) } + { initPerPage: getUserTablePreference("secretScanningTable", PreferenceKey.PerPage, 20) } ); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("secretScanningTable", "perPage", newPerPage); + setUserTablePreference("secretScanningTable", PreferenceKey.PerPage, newPerPage); }; const repositoryNames = watch("repositoryNames"); @@ -184,7 +188,7 @@ export const SecretScanningPage = withPermission( )} -
+
{integrationEnabled && (
)} - {!isPending && risksData?.totalCount !== undefined && ( + {!isPending && risksData?.totalCount !== undefined && risksData.totalCount >= 10 && ( { orderDirection, toggleOrderDirection } = usePagination(UserGroupsOrderBy.Name, { - initPerPage: getUserTablePreference("userGroupsTable", "perPage", 20) + initPerPage: getUserTablePreference("userGroupsTable", PreferenceKey.PerPage, 10) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("userGroupsTable", "perPage", newPerPage); + setUserTablePreference("userGroupsTable", PreferenceKey.PerPage, newPerPage); }; const filteredGroupMemberships = useMemo( diff --git a/frontend/src/pages/organization/UserDetailsByIDPage/components/UserProjectsSection/UserProjectsTable.tsx b/frontend/src/pages/organization/UserDetailsByIDPage/components/UserProjectsSection/UserProjectsTable.tsx index c15c48cd3..9e6042c03 100644 --- a/frontend/src/pages/organization/UserDetailsByIDPage/components/UserProjectsSection/UserProjectsTable.tsx +++ b/frontend/src/pages/organization/UserDetailsByIDPage/components/UserProjectsSection/UserProjectsTable.tsx @@ -22,7 +22,11 @@ import { Tr } from "@app/components/v2"; import { useOrganization } from "@app/context"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, useResetPageHelper } from "@app/hooks"; import { useGetOrgMembershipProjectMemberships } from "@app/hooks/api"; import { OrderByDirection } from "@app/hooks/api/generic/types"; @@ -56,12 +60,12 @@ export const UserProjectsTable = ({ membershipId, handlePopUpOpen }: Props) => { orderDirection, toggleOrderDirection } = usePagination(UserProjectsOrderBy.Name, { - initPerPage: getUserTablePreference("userProjectsTable", "perPage", 20) + initPerPage: getUserTablePreference("userProjectsTable", PreferenceKey.PerPage, 10) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("userProjectsTable", "perPage", newPerPage); + setUserTablePreference("userProjectsTable", PreferenceKey.PerPage, newPerPage); }; const { data: projectMemberships = [], isPending } = useGetOrgMembershipProjectMemberships( diff --git a/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupsTable.tsx b/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupsTable.tsx index 731bb18d4..8f06576e2 100644 --- a/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupsTable.tsx +++ b/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupsTable.tsx @@ -27,7 +27,11 @@ import { Tr } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, useResetPageHelper } from "@app/hooks"; import { useListWorkspaceGroups } from "@app/hooks/api"; import { OrderByDirection } from "@app/hooks/api/generic/types"; @@ -64,12 +68,12 @@ export const GroupTable = ({ handlePopUpOpen }: Props) => { orderBy, toggleOrderDirection } = usePagination(GroupsOrderBy.Name, { - initPerPage: getUserTablePreference("projectGroupsTable", "perPage", 20) + initPerPage: getUserTablePreference("projectGroupsTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("projectGroupsTable", "perPage", newPerPage); + setUserTablePreference("projectGroupsTable", PreferenceKey.PerPage, newPerPage); }; const { data: groupMemberships = [], isPending } = useListWorkspaceGroups( diff --git a/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx b/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx index 730d5336d..d20beb738 100644 --- a/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx +++ b/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx @@ -42,7 +42,11 @@ import { } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; import { formatProjectRoleName } from "@app/helpers/roles"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { withProjectPermission } from "@app/hoc"; import { usePagination, useResetPageHelper } from "@app/hooks"; import { useDeleteIdentityFromWorkspace, useGetWorkspaceIdentityMemberships } from "@app/hooks/api"; @@ -74,12 +78,12 @@ export const IdentityTab = withProjectPermission( page, setPerPage } = usePagination(ProjectIdentityOrderBy.Name, { - initPerPage: getUserTablePreference("projectIdentityTable", "perPage", 20) + initPerPage: getUserTablePreference("projectIdentityTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("projectIdentityTable", "perPage", newPerPage); + setUserTablePreference("projectIdentityTable", PreferenceKey.PerPage, newPerPage); }; const workspaceId = currentWorkspace?.id ?? ""; diff --git a/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MembersTable.tsx b/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MembersTable.tsx index c409e503b..c1251bef2 100644 --- a/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MembersTable.tsx +++ b/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MembersTable.tsx @@ -51,7 +51,11 @@ import { useWorkspace } from "@app/context"; import { formatProjectRoleName } from "@app/helpers/roles"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, useResetPageHelper } from "@app/hooks"; import { useGetProjectRoles, useGetWorkspaceUsers } from "@app/hooks/api"; import { OrderByDirection } from "@app/hooks/api/generic/types"; @@ -102,12 +106,12 @@ export const MembersTable = ({ handlePopUpOpen }: Props) => { setOrderDirection, toggleOrderDirection } = usePagination(MembersOrderBy.Name, { - initPerPage: getUserTablePreference("projectMembersTable", "perPage", 20) + initPerPage: getUserTablePreference("projectMembersTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("projectMembersTable", "perPage", newPerPage); + setUserTablePreference("projectMembersTable", PreferenceKey.PerPage, newPerPage); }; const { data: members = [], isPending: isMembersLoading } = useGetWorkspaceUsers( diff --git a/frontend/src/pages/secret-manager/IntegrationsListPage/components/NativeIntegrationsTab/IntegrationsTable.tsx b/frontend/src/pages/secret-manager/IntegrationsListPage/components/NativeIntegrationsTab/IntegrationsTable.tsx index db250a2e7..775e42c50 100644 --- a/frontend/src/pages/secret-manager/IntegrationsListPage/components/NativeIntegrationsTab/IntegrationsTable.tsx +++ b/frontend/src/pages/secret-manager/IntegrationsListPage/components/NativeIntegrationsTab/IntegrationsTable.tsx @@ -32,7 +32,11 @@ import { Tooltip, Tr } from "@app/components/v2"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, useResetPageHelper } from "@app/hooks"; import { OrderByDirection } from "@app/hooks/api/generic/types"; import { useSyncIntegration } from "@app/hooks/api/integrations/queries"; @@ -112,12 +116,12 @@ export const IntegrationsTable = ({ setOrderDirection, setOrderBy } = usePagination(IntegrationsOrderBy.App, { - initPerPage: getUserTablePreference("integrationsTable", "perPage", 20) + initPerPage: getUserTablePreference("integrationsTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("integrationsTable", "perPage", newPerPage); + setUserTablePreference("integrationsTable", PreferenceKey.PerPage, newPerPage); }; useEffect(() => { diff --git a/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/SecretSyncsTable.tsx b/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/SecretSyncsTable.tsx index e9c50b05f..fcd42a10f 100644 --- a/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/SecretSyncsTable.tsx +++ b/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/SecretSyncsTable.tsx @@ -38,7 +38,11 @@ import { } from "@app/components/v2"; import { useWorkspace } from "@app/context"; import { SECRET_SYNC_MAP } from "@app/helpers/secretSyncs"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, usePopUp, useResetPageHelper } from "@app/hooks"; import { OrderByDirection } from "@app/hooks/api/generic/types"; import { @@ -121,12 +125,12 @@ export const SecretSyncsTable = ({ secretSyncs }: Props) => { setOrderDirection, setOrderBy } = usePagination(SecretSyncsOrderBy.Name, { - initPerPage: getUserTablePreference("secretSyncTable", "perPage", 20) + initPerPage: getUserTablePreference("secretSyncTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("secretSyncTable", "perPage", newPerPage); + setUserTablePreference("secretSyncTable", PreferenceKey.PerPage, newPerPage); }; const filteredSecretSyncs = useMemo( diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx index ad91c30eb..c94aef0d5 100644 --- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx +++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx @@ -64,7 +64,11 @@ import { useWorkspace } from "@app/context"; import { ProjectPermissionSecretRotationActions } from "@app/context/ProjectPermissionContext/types"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { useDebounce, usePagination, usePopUp, useResetPageHelper } from "@app/hooks"; import { useCreateFolder, @@ -182,12 +186,12 @@ export const OverviewPage = () => { setPerPage, orderBy } = usePagination(DashboardSecretsOrderBy.Name, { - initPerPage: getUserTablePreference("secretOverviewTable", "perPage", 100) + initPerPage: getUserTablePreference("secretOverviewTable", PreferenceKey.PerPage, 100) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("secretOverviewTable", "perPage", newPerPage); + setUserTablePreference("secretOverviewTable", PreferenceKey.PerPage, newPerPage); }; const resetSelectedEntries = useCallback(() => { diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx index 0873b5064..49bf1a72c 100644 --- a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx +++ b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx @@ -29,7 +29,11 @@ import { ProjectPermissionSecretActions, ProjectPermissionSecretRotationActions } from "@app/context/ProjectPermissionContext/types"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { useDebounce, usePagination, usePopUp, useResetPageHelper } from "@app/hooks"; import { useGetImportedSecretsSingleEnv, @@ -100,12 +104,12 @@ const Page = () => { setPerPage, orderBy } = usePagination(DashboardSecretsOrderBy.Name, { - initPerPage: getUserTablePreference("secretDashboardTable", "perPage", 100) + initPerPage: getUserTablePreference("secretDashboardTable", PreferenceKey.PerPage, 100) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("secretDashboardTable", "perPage", newPerPage); + setUserTablePreference("secretDashboardTable", PreferenceKey.PerPage, newPerPage); }; const [snapshotId, setSnapshotId] = useState(null); diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretTagsSection/SecretTagsTable.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/SecretTagsSection/SecretTagsTable.tsx index 180e78645..d0633eb12 100644 --- a/frontend/src/pages/secret-manager/SettingsPage/components/SecretTagsSection/SecretTagsTable.tsx +++ b/frontend/src/pages/secret-manager/SettingsPage/components/SecretTagsSection/SecretTagsTable.tsx @@ -25,7 +25,11 @@ import { Tr } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; -import { getUserTablePreference, setUserTablePreference } from "@app/helpers/userTablePreferences"; +import { + getUserTablePreference, + PreferenceKey, + setUserTablePreference +} from "@app/helpers/userTablePreferences"; import { usePagination, useResetPageHelper } from "@app/hooks"; import { OrderByDirection } from "@app/hooks/api/generic/types"; import { useGetWsTags } from "@app/hooks/api/tags"; @@ -63,12 +67,12 @@ export const SecretTagsTable = ({ handlePopUpOpen }: Props) => { orderDirection, toggleOrderDirection } = usePagination(TagsOrderBy.Slug, { - initPerPage: getUserTablePreference("secretTagsTable", "perPage", 20) + initPerPage: getUserTablePreference("secretTagsTable", PreferenceKey.PerPage, 20) }); const handlePerPageChange = (newPerPage: number) => { setPerPage(newPerPage); - setUserTablePreference("secretTagsTable", "perPage", newPerPage); + setUserTablePreference("secretTagsTable", PreferenceKey.PerPage, newPerPage); }; const filteredTags = useMemo(