From 609d4166b2daead4370326f485af6229607ea343 Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Mon, 25 Mar 2024 16:56:59 -0400 Subject: [PATCH 1/5] New queries definition fo placement groups --- .../PlacementGroupsSelect.test.tsx | 9 ++- .../PlacementGroupsSelect.tsx | 4 +- ...lacementGroupsAssignLinodesDrawer.test.tsx | 7 +-- .../PlacementGroupsAssignLinodesDrawer.tsx | 4 +- .../PlacementGroupsDetailPanel.test.tsx | 7 +-- .../PlacementGroupsDetailPanel.tsx | 4 +- .../manager/src/queries/placementGroups.ts | 59 ++++++++++++------- 7 files changed, 53 insertions(+), 41 deletions(-) diff --git a/packages/manager/src/components/PlacementGroupsSelect/PlacementGroupsSelect.test.tsx b/packages/manager/src/components/PlacementGroupsSelect/PlacementGroupsSelect.test.tsx index b822a22347c..023a67e704c 100644 --- a/packages/manager/src/components/PlacementGroupsSelect/PlacementGroupsSelect.test.tsx +++ b/packages/manager/src/components/PlacementGroupsSelect/PlacementGroupsSelect.test.tsx @@ -20,21 +20,20 @@ const props: PlacementGroupsSelectProps = { }; const queryMocks = vi.hoisted(() => ({ - useUnpaginatedPlacementGroupsQuery: vi.fn().mockReturnValue({}), + useAllPlacementGroupsQuery: vi.fn().mockReturnValue({}), })); vi.mock('src/queries/placementGroups', async () => { const actual = await vi.importActual('src/queries/placementGroups'); return { ...actual, - useUnpaginatedPlacementGroupsQuery: - queryMocks.useUnpaginatedPlacementGroupsQuery, + useAllPlacementGroupsQuery: queryMocks.useAllPlacementGroupsQuery, }; }); describe('PlacementGroupSelect', () => { beforeEach(() => { - queryMocks.useUnpaginatedPlacementGroupsQuery.mockReturnValue({ + queryMocks.useAllPlacementGroupsQuery.mockReturnValue({ data: [ placementGroupFactory.build({ affinity_type: 'affinity:local', @@ -67,7 +66,7 @@ describe('PlacementGroupSelect', () => { }); it('should have a disabled option if the region has reached its placement group capacity', async () => { - queryMocks.useUnpaginatedPlacementGroupsQuery.mockReturnValue({ + queryMocks.useAllPlacementGroupsQuery.mockReturnValue({ data: [ placementGroupFactory.build({ affinity_type: 'affinity:local', diff --git a/packages/manager/src/components/PlacementGroupsSelect/PlacementGroupsSelect.tsx b/packages/manager/src/components/PlacementGroupsSelect/PlacementGroupsSelect.tsx index f86e6b18e0e..81f45c9104c 100644 --- a/packages/manager/src/components/PlacementGroupsSelect/PlacementGroupsSelect.tsx +++ b/packages/manager/src/components/PlacementGroupsSelect/PlacementGroupsSelect.tsx @@ -6,7 +6,7 @@ import * as React from 'react'; import { Autocomplete } from 'src/components/Autocomplete/Autocomplete'; import { TextFieldProps } from 'src/components/TextField'; import { hasPlacementGroupReachedCapacity } from 'src/features/PlacementGroups/utils'; -import { useUnpaginatedPlacementGroupsQuery } from 'src/queries/placementGroups'; +import { useAllPlacementGroupsQuery } from 'src/queries/placementGroups'; import { PlacementGroupSelectOption } from './PlacementGroupSelectOption'; @@ -51,7 +51,7 @@ export const PlacementGroupsSelect = (props: PlacementGroupsSelectProps) => { data: placementGroups, error, isLoading, - } = useUnpaginatedPlacementGroupsQuery(Boolean(selectedRegion?.id)); + } = useAllPlacementGroupsQuery(Boolean(selectedRegion?.id)); const isDisabledPlacementGroup = ( selectedPlacementGroup: PlacementGroup, diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.test.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.test.tsx index bc2ec2d5722..2c158d6bf19 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.test.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.test.tsx @@ -14,7 +14,7 @@ const queryMocks = vi.hoisted(() => ({ useAllLinodesQuery: vi.fn().mockReturnValue({}), useAssignLinodesToPlacementGroup: vi.fn().mockReturnValue({}), useRegionsQuery: vi.fn().mockReturnValue({}), - useUnpaginatedPlacementGroupsQuery: vi.fn().mockReturnValue({}), + useAllPlacementGroupsQuery: vi.fn().mockReturnValue({}), })); vi.mock('src/queries/linodes/linodes', async () => { @@ -29,8 +29,7 @@ vi.mock('src/queries/placementGroups', async () => { const actual = await vi.importActual('src/queries/placementGroups'); return { ...actual, - useUnpaginatedPlacementGroupsQuery: - queryMocks.useUnpaginatedPlacementGroupsQuery, + useAllPlacementGroupsQuery: queryMocks.useAllPlacementGroupsQuery, }; }); @@ -77,7 +76,7 @@ describe('PlacementGroupsAssignLinodesDrawer', () => { ], }); queryMocks.useRegionsQuery.mockReturnValue(regionFactory.buildList(5)); - queryMocks.useUnpaginatedPlacementGroupsQuery.mockReturnValue({ + queryMocks.useAllPlacementGroupsQuery.mockReturnValue({ data: placementGroupFactory.build(), }); queryMocks.useAssignLinodesToPlacementGroup.mockReturnValue( diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.tsx index 6e6240e3605..b53cf3edc2b 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.tsx @@ -15,7 +15,7 @@ import { usePlacementGroupData } from 'src/hooks/usePlacementGroupsData'; import { useAllLinodesQuery } from 'src/queries/linodes/linodes'; import { useAssignLinodesToPlacementGroup, - useUnpaginatedPlacementGroupsQuery, + useAllPlacementGroupsQuery, } from 'src/queries/placementGroups'; import { LinodeSelect } from '../Linodes/LinodeSelect/LinodeSelect'; @@ -43,7 +43,7 @@ export const PlacementGroupsAssignLinodesDrawer = ( const { data: allPlacementGroups, error: allPlacementGroupsError, - } = useUnpaginatedPlacementGroupsQuery(); + } = useAllPlacementGroupsQuery(); const { enqueueSnackbar } = useSnackbar(); // We display a notice and disable inputs in case the user reaches this drawer somehow diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsDetailPanel.test.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsDetailPanel.test.tsx index 4511e498104..74766237cea 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsDetailPanel.test.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsDetailPanel.test.tsx @@ -11,7 +11,7 @@ const defaultProps = { const queryMocks = vi.hoisted(() => ({ useRegionsQuery: vi.fn().mockReturnValue({}), - useUnpaginatedPlacementGroupsQuery: vi.fn().mockReturnValue({}), + useAllPlacementGroupsQuery: vi.fn().mockReturnValue({}), })); vi.mock('src/queries/regions/regions', async () => { @@ -26,8 +26,7 @@ vi.mock('src/queries/placementGroups', async () => { const actual = await vi.importActual('src/queries/placementGroups'); return { ...actual, - useUnpaginatedPlacementGroupsQuery: - queryMocks.useUnpaginatedPlacementGroupsQuery, + useAllPlacementGroupsQuery: queryMocks.useAllPlacementGroupsQuery, }; }); @@ -54,7 +53,7 @@ describe('PlacementGroupsDetailPanel', () => { }), ], }); - queryMocks.useUnpaginatedPlacementGroupsQuery.mockReturnValue({ + queryMocks.useAllPlacementGroupsQuery.mockReturnValue({ data: [ placementGroupFactory.build({ affinity_type: 'affinity:local', diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsDetailPanel.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsDetailPanel.tsx index 44ccb25a9e0..ea4a1db2303 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsDetailPanel.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsDetailPanel.tsx @@ -11,7 +11,7 @@ import { Typography } from 'src/components/Typography'; import { PlacementGroupsCreateDrawer } from 'src/features/PlacementGroups/PlacementGroupsCreateDrawer'; import { hasRegionReachedPlacementGroupCapacity } from 'src/features/PlacementGroups/utils'; import { useRestrictedGlobalGrantCheck } from 'src/hooks/useRestrictedGlobalGrantCheck'; -import { useUnpaginatedPlacementGroupsQuery } from 'src/queries/placementGroups'; +import { useAllPlacementGroupsQuery } from 'src/queries/placementGroups'; import { useRegionsQuery } from 'src/queries/regions/regions'; import { PLACEMENT_GROUP_SELECT_TOOLTIP_COPY } from './constants'; @@ -27,7 +27,7 @@ interface Props { export const PlacementGroupsDetailPanel = (props: Props) => { const theme = useTheme(); const { handlePlacementGroupChange, selectedRegionId } = props; - const { data: allPlacementGroups } = useUnpaginatedPlacementGroupsQuery(); + const { data: allPlacementGroups } = useAllPlacementGroupsQuery(); const { data: regions } = useRegionsQuery(); const [ isCreatePlacementGroupDrawerOpen, diff --git a/packages/manager/src/queries/placementGroups.ts b/packages/manager/src/queries/placementGroups.ts index 61898ecf3e7..418cb053943 100644 --- a/packages/manager/src/queries/placementGroups.ts +++ b/packages/manager/src/queries/placementGroups.ts @@ -13,6 +13,7 @@ import { Params, ResourcePage, } from '@linode/api-v4/lib/types'; +import { createQueryKeys } from '@lukemorales/query-key-factory'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { getAll } from 'src/utilities/getAll'; @@ -27,13 +28,25 @@ import type { UpdatePlacementGroupPayload, } from '@linode/api-v4'; -export const queryKey = 'placement-groups'; +export const placementGroupQueries = createQueryKeys('placement-groups', { + all: (params: Params = {}, filters: Filter = {}) => ({ + queryFn: () => getAllPlacementGroupsRequest(), + queryKey: [params, filters], + }), + paginated: (params: Params, filters: Filter) => ({ + queryFn: () => getPlacementGroups(params, filters), + queryKey: [params, filters], + }), + placementGroup: (placementGroupId: number) => ({ + queryFn: () => getPlacementGroup(placementGroupId), + queryKey: [placementGroupId], + }), +}); -export const useUnpaginatedPlacementGroupsQuery = (enabled = true) => +export const useAllPlacementGroupsQuery = (enabled = true) => useQuery({ enabled, - queryFn: () => getAllPlacementGroupsRequest(), - queryKey: [queryKey, 'all'], + ...placementGroupQueries.all(), }); const getAllPlacementGroupsRequest = () => @@ -49,8 +62,7 @@ export const usePlacementGroupsQuery = ( useQuery, APIError[]>({ enabled, keepPreviousData: true, - queryFn: () => getPlacementGroups(params, filter), - queryKey: [queryKey, 'paginated', params, filter], + ...placementGroupQueries.paginated(params, filter), }); export const usePlacementGroupQuery = ( @@ -59,8 +71,7 @@ export const usePlacementGroupQuery = ( ) => { return useQuery({ enabled, - queryFn: () => getPlacementGroup(placementGroupId), - queryKey: [queryKey, 'placement-group', placementGroupId], + ...placementGroupQueries.placementGroup(placementGroupId), }); }; @@ -70,10 +81,10 @@ export const useCreatePlacementGroup = () => { return useMutation({ mutationFn: createPlacementGroup, onSuccess: (placementGroup) => { - queryClient.invalidateQueries([queryKey, 'paginated']); - queryClient.invalidateQueries([queryKey, 'all']); - queryClient.setQueryData( - [queryKey, 'placement-group', placementGroup.id], + queryClient.invalidateQueries(placementGroupQueries.paginated._def); + queryClient.invalidateQueries(placementGroupQueries.all._def); + queryClient.setQueryData( + placementGroupQueries.placementGroup(placementGroup.id).queryKey, placementGroup ); // If a restricted user creates an entity, we must make sure grants are up to date. @@ -88,10 +99,10 @@ export const useMutatePlacementGroup = (id: number) => { return useMutation({ mutationFn: (data) => updatePlacementGroup(id, data), onSuccess: (placementGroup) => { - queryClient.invalidateQueries([queryKey, 'paginated']); - queryClient.invalidateQueries([queryKey, 'all']); + queryClient.invalidateQueries(placementGroupQueries.paginated._def); + queryClient.invalidateQueries(placementGroupQueries.all._def); queryClient.setQueryData( - [queryKey, 'placement-group', id], + placementGroupQueries.placementGroup(id).queryKey, placementGroup ); }, @@ -104,9 +115,11 @@ export const useDeletePlacementGroup = (id: number) => { return useMutation<{}, APIError[]>({ mutationFn: () => deletePlacementGroup(id), onSuccess: () => { - queryClient.invalidateQueries([queryKey, 'paginated']); - queryClient.invalidateQueries([queryKey, 'all']); - queryClient.removeQueries([queryKey, 'placement-group', id]); + queryClient.invalidateQueries(placementGroupQueries.paginated._def); + queryClient.invalidateQueries(placementGroupQueries.all._def); + queryClient.removeQueries( + placementGroupQueries.placementGroup(id).queryKey + ); }, }); }; @@ -121,9 +134,10 @@ export const useAssignLinodesToPlacementGroup = (placementGroupId: number) => { >({ mutationFn: (data) => assignLinodesToPlacementGroup(placementGroupId, data), onSuccess: (updatedPlacementGroup) => { - queryClient.invalidateQueries([queryKey, 'paginated']); + queryClient.invalidateQueries(placementGroupQueries.paginated._def); + queryClient.invalidateQueries(placementGroupQueries.all._def); queryClient.setQueryData( - [queryKey, 'placement-group', placementGroupId], + placementGroupQueries.placementGroup(placementGroupId).queryKey, updatedPlacementGroup ); }, @@ -142,9 +156,10 @@ export const useUnassignLinodesFromPlacementGroup = ( mutationFn: (data) => unassignLinodesFromPlacementGroup(placementGroupId, data), onSuccess: (updatedPlacementGroup) => { - queryClient.invalidateQueries([queryKey, 'paginated']); + queryClient.invalidateQueries(placementGroupQueries.paginated._def); + queryClient.invalidateQueries(placementGroupQueries.all._def); queryClient.setQueryData( - [queryKey, 'placement-group', placementGroupId], + placementGroupQueries.placementGroup(placementGroupId).queryKey, updatedPlacementGroup ); }, From 66981b24040e9ae5998493ff3181feca2ae34254 Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Mon, 25 Mar 2024 22:41:52 -0400 Subject: [PATCH 2/5] invalidate linodes on assign/unassign --- .../manager/src/queries/placementGroups.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/manager/src/queries/placementGroups.ts b/packages/manager/src/queries/placementGroups.ts index 418cb053943..f4e6311c040 100644 --- a/packages/manager/src/queries/placementGroups.ts +++ b/packages/manager/src/queries/placementGroups.ts @@ -16,6 +16,7 @@ import { import { createQueryKeys } from '@lukemorales/query-key-factory'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; +import { queryKey as linodeQueryKey } from 'src/queries/linodes/linodes'; import { getAll } from 'src/utilities/getAll'; import { profileQueries } from './profile'; @@ -87,6 +88,7 @@ export const useCreatePlacementGroup = () => { placementGroupQueries.placementGroup(placementGroup.id).queryKey, placementGroup ); + // If a restricted user creates an entity, we must make sure grants are up to date. queryClient.invalidateQueries(profileQueries.grants.queryKey); }, @@ -133,13 +135,15 @@ export const useAssignLinodesToPlacementGroup = (placementGroupId: number) => { AssignLinodesToPlacementGroupPayload >({ mutationFn: (data) => assignLinodesToPlacementGroup(placementGroupId, data), - onSuccess: (updatedPlacementGroup) => { + onSuccess: () => { queryClient.invalidateQueries(placementGroupQueries.paginated._def); queryClient.invalidateQueries(placementGroupQueries.all._def); - queryClient.setQueryData( - placementGroupQueries.placementGroup(placementGroupId).queryKey, - updatedPlacementGroup + queryClient.invalidateQueries( + placementGroupQueries.placementGroup(placementGroupId).queryKey ); + + // Invalidate all linodes query since we use the list to populate the select in the assign drawer + queryClient.invalidateQueries([linodeQueryKey, 'all']); }, }); }; @@ -155,13 +159,15 @@ export const useUnassignLinodesFromPlacementGroup = ( >({ mutationFn: (data) => unassignLinodesFromPlacementGroup(placementGroupId, data), - onSuccess: (updatedPlacementGroup) => { + onSuccess: () => { queryClient.invalidateQueries(placementGroupQueries.paginated._def); queryClient.invalidateQueries(placementGroupQueries.all._def); - queryClient.setQueryData( - placementGroupQueries.placementGroup(placementGroupId).queryKey, - updatedPlacementGroup + queryClient.invalidateQueries( + placementGroupQueries.placementGroup(placementGroupId).queryKey ); + + // Invalidate all linodes query since we use the list to populate the select in the assign drawer + queryClient.invalidateQueries([linodeQueryKey, 'all']); }, }); }; From cf7a3eec75bc1e4889eb3ca675813f3a0250c151 Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Tue, 26 Mar 2024 09:43:01 -0400 Subject: [PATCH 3/5] Changeset & code comments --- .../.changeset/pr-10314-upcoming-features-1711460549811.md | 5 +++++ packages/manager/src/queries/placementGroups.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 packages/manager/.changeset/pr-10314-upcoming-features-1711460549811.md diff --git a/packages/manager/.changeset/pr-10314-upcoming-features-1711460549811.md b/packages/manager/.changeset/pr-10314-upcoming-features-1711460549811.md new file mode 100644 index 00000000000..a482b891e0f --- /dev/null +++ b/packages/manager/.changeset/pr-10314-upcoming-features-1711460549811.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Upcoming Features +--- + + Implement Placement Groups Query Key Factory ([#10314](https://github.com/linode/manager/pull/10314)) diff --git a/packages/manager/src/queries/placementGroups.ts b/packages/manager/src/queries/placementGroups.ts index f4e6311c040..71f53350baf 100644 --- a/packages/manager/src/queries/placementGroups.ts +++ b/packages/manager/src/queries/placementGroups.ts @@ -142,7 +142,7 @@ export const useAssignLinodesToPlacementGroup = (placementGroupId: number) => { placementGroupQueries.placementGroup(placementGroupId).queryKey ); - // Invalidate all linodes query since we use the list to populate the select in the assign drawer + // Invalidate all linodes query since we use the list to populate the PG linode select queryClient.invalidateQueries([linodeQueryKey, 'all']); }, }); @@ -166,7 +166,7 @@ export const useUnassignLinodesFromPlacementGroup = ( placementGroupQueries.placementGroup(placementGroupId).queryKey ); - // Invalidate all linodes query since we use the list to populate the select in the assign drawer + // Invalidate all linodes query since we use the list to populate the PG linode select queryClient.invalidateQueries([linodeQueryKey, 'all']); }, }); From 4bd63f0eea68816171f2db961a52b8da8eea178d Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Tue, 26 Mar 2024 12:29:21 -0400 Subject: [PATCH 4/5] feedback --- .../manager/src/queries/placementGroups.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/manager/src/queries/placementGroups.ts b/packages/manager/src/queries/placementGroups.ts index 71f53350baf..c0abf79990c 100644 --- a/packages/manager/src/queries/placementGroups.ts +++ b/packages/manager/src/queries/placementGroups.ts @@ -29,11 +29,16 @@ import type { UpdatePlacementGroupPayload, } from '@linode/api-v4'; +const getAllPlacementGroupsRequest = () => + getAll((params, filters) => + getPlacementGroups(params, filters) + )().then((data) => data.data); + export const placementGroupQueries = createQueryKeys('placement-groups', { - all: (params: Params = {}, filters: Filter = {}) => ({ - queryFn: () => getAllPlacementGroupsRequest(), - queryKey: [params, filters], - }), + all: { + queryFn: getAllPlacementGroupsRequest, + queryKey: null, + }, paginated: (params: Params, filters: Filter) => ({ queryFn: () => getPlacementGroups(params, filters), queryKey: [params, filters], @@ -47,14 +52,9 @@ export const placementGroupQueries = createQueryKeys('placement-groups', { export const useAllPlacementGroupsQuery = (enabled = true) => useQuery({ enabled, - ...placementGroupQueries.all(), + ...placementGroupQueries.all, }); -const getAllPlacementGroupsRequest = () => - getAll((params, filters) => - getPlacementGroups(params, filters) - )().then((data) => data.data); - export const usePlacementGroupsQuery = ( params: Params, filter: Filter, @@ -83,7 +83,7 @@ export const useCreatePlacementGroup = () => { mutationFn: createPlacementGroup, onSuccess: (placementGroup) => { queryClient.invalidateQueries(placementGroupQueries.paginated._def); - queryClient.invalidateQueries(placementGroupQueries.all._def); + queryClient.invalidateQueries(placementGroupQueries.all); queryClient.setQueryData( placementGroupQueries.placementGroup(placementGroup.id).queryKey, placementGroup @@ -102,7 +102,7 @@ export const useMutatePlacementGroup = (id: number) => { mutationFn: (data) => updatePlacementGroup(id, data), onSuccess: (placementGroup) => { queryClient.invalidateQueries(placementGroupQueries.paginated._def); - queryClient.invalidateQueries(placementGroupQueries.all._def); + queryClient.invalidateQueries(placementGroupQueries.all); queryClient.setQueryData( placementGroupQueries.placementGroup(id).queryKey, placementGroup @@ -118,7 +118,7 @@ export const useDeletePlacementGroup = (id: number) => { mutationFn: () => deletePlacementGroup(id), onSuccess: () => { queryClient.invalidateQueries(placementGroupQueries.paginated._def); - queryClient.invalidateQueries(placementGroupQueries.all._def); + queryClient.invalidateQueries(placementGroupQueries.all); queryClient.removeQueries( placementGroupQueries.placementGroup(id).queryKey ); @@ -137,7 +137,7 @@ export const useAssignLinodesToPlacementGroup = (placementGroupId: number) => { mutationFn: (data) => assignLinodesToPlacementGroup(placementGroupId, data), onSuccess: () => { queryClient.invalidateQueries(placementGroupQueries.paginated._def); - queryClient.invalidateQueries(placementGroupQueries.all._def); + queryClient.invalidateQueries(placementGroupQueries.all); queryClient.invalidateQueries( placementGroupQueries.placementGroup(placementGroupId).queryKey ); @@ -161,7 +161,7 @@ export const useUnassignLinodesFromPlacementGroup = ( unassignLinodesFromPlacementGroup(placementGroupId, data), onSuccess: () => { queryClient.invalidateQueries(placementGroupQueries.paginated._def); - queryClient.invalidateQueries(placementGroupQueries.all._def); + queryClient.invalidateQueries(placementGroupQueries.all); queryClient.invalidateQueries( placementGroupQueries.placementGroup(placementGroupId).queryKey ); From 03bbff507d3af248ea8647c8b39ae7495cb8fb2b Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Tue, 26 Mar 2024 12:54:11 -0400 Subject: [PATCH 5/5] feedback --- packages/manager/src/queries/placementGroups.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/manager/src/queries/placementGroups.ts b/packages/manager/src/queries/placementGroups.ts index c0abf79990c..6669ab1d67e 100644 --- a/packages/manager/src/queries/placementGroups.ts +++ b/packages/manager/src/queries/placementGroups.ts @@ -83,7 +83,7 @@ export const useCreatePlacementGroup = () => { mutationFn: createPlacementGroup, onSuccess: (placementGroup) => { queryClient.invalidateQueries(placementGroupQueries.paginated._def); - queryClient.invalidateQueries(placementGroupQueries.all); + queryClient.invalidateQueries(placementGroupQueries.all.queryKey); queryClient.setQueryData( placementGroupQueries.placementGroup(placementGroup.id).queryKey, placementGroup @@ -102,7 +102,7 @@ export const useMutatePlacementGroup = (id: number) => { mutationFn: (data) => updatePlacementGroup(id, data), onSuccess: (placementGroup) => { queryClient.invalidateQueries(placementGroupQueries.paginated._def); - queryClient.invalidateQueries(placementGroupQueries.all); + queryClient.invalidateQueries(placementGroupQueries.all.queryKey); queryClient.setQueryData( placementGroupQueries.placementGroup(id).queryKey, placementGroup @@ -118,7 +118,7 @@ export const useDeletePlacementGroup = (id: number) => { mutationFn: () => deletePlacementGroup(id), onSuccess: () => { queryClient.invalidateQueries(placementGroupQueries.paginated._def); - queryClient.invalidateQueries(placementGroupQueries.all); + queryClient.invalidateQueries(placementGroupQueries.all.queryKey); queryClient.removeQueries( placementGroupQueries.placementGroup(id).queryKey ); @@ -137,7 +137,7 @@ export const useAssignLinodesToPlacementGroup = (placementGroupId: number) => { mutationFn: (data) => assignLinodesToPlacementGroup(placementGroupId, data), onSuccess: () => { queryClient.invalidateQueries(placementGroupQueries.paginated._def); - queryClient.invalidateQueries(placementGroupQueries.all); + queryClient.invalidateQueries(placementGroupQueries.all.queryKey); queryClient.invalidateQueries( placementGroupQueries.placementGroup(placementGroupId).queryKey ); @@ -161,7 +161,7 @@ export const useUnassignLinodesFromPlacementGroup = ( unassignLinodesFromPlacementGroup(placementGroupId, data), onSuccess: () => { queryClient.invalidateQueries(placementGroupQueries.paginated._def); - queryClient.invalidateQueries(placementGroupQueries.all); + queryClient.invalidateQueries(placementGroupQueries.all.queryKey); queryClient.invalidateQueries( placementGroupQueries.placementGroup(placementGroupId).queryKey );