Skip to content

Commit a3afe05

Browse files
raswondersezr-ondrej
authored andcommitted
refactor: remove unused code related to bulk select all
1 parent 3d2b6fb commit a3afe05

File tree

2 files changed

+5
-51
lines changed

2 files changed

+5
-51
lines changed

src/components/SystemsViewTable/SystemsViewTable.tsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ import {
2323
ResponsiveActions,
2424
BulkSelect,
2525
} from '@patternfly/react-component-groups';
26-
import {
27-
type System,
28-
fetchAllSystems,
29-
useSystemsQuery,
30-
} from './hooks/useSystemsQuery';
31-
import { useQueryClient } from '@tanstack/react-query';
26+
import { type System, useSystemsQuery } from './hooks/useSystemsQuery';
3227
import { ErrorState } from '@redhat-cloud-services/frontend-components/ErrorState';
3328
import SkeletonTable from '@patternfly/react-component-groups/dist/dynamic/SkeletonTable';
3429
import { EmptySystemsState } from './components/EmptySystemsState';
@@ -38,8 +33,6 @@ const INITIAL_PAGE = 1;
3833
const NO_HEADER = <></>;
3934

4035
const SystemsViewTable: React.FC = () => {
41-
const queryClient = useQueryClient();
42-
4336
const pagination = useDataViewPagination({
4437
perPage: PER_PAGE,
4538
page: INITIAL_PAGE,
@@ -128,14 +121,6 @@ const SystemsViewTable: React.FC = () => {
128121
setSelected([]);
129122
}
130123
break;
131-
case 'all':
132-
const allSystems = await fetchAllSystems({
133-
total,
134-
perPage: pagination.perPage,
135-
queryClient,
136-
});
137-
onSelect(true, allSystems.map(mapSystemToRow));
138-
break;
139124
}
140125
};
141126

@@ -149,7 +134,7 @@ const SystemsViewTable: React.FC = () => {
149134
bulkSelect={
150135
<BulkSelect
151136
pageCount={rows.length}
152-
// canSelectAll disabled as we miss spinner & ability to disable controls
137+
// canSelectAll disabled see JIRA: RHINENG-22312 for details
153138
totalCount={total}
154139
selectedCount={selected.length}
155140
pagePartiallySelected={isPagePartiallySelected(rows)}

src/components/SystemsViewTable/hooks/useSystemsQuery.ts

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { type QueryClient, useQuery } from '@tanstack/react-query';
1+
import { useQuery } from '@tanstack/react-query';
22
import { generateFilter } from '@redhat-cloud-services/frontend-components-utilities/helpers';
33
import { getHostList, getHostTags } from '../../../api/hostInventoryApiTyped';
4-
import pAll from 'p-all';
54

65
type FetchSystemsReturnedValue = Awaited<ReturnType<typeof fetchSystems>>;
76
export type System = FetchSystemsReturnedValue['results'][number];
@@ -10,7 +9,6 @@ interface FetchSystemsParams {
109
page: number;
1110
perPage: number;
1211
}
13-
1412
const fetchSystems = async ({ page, perPage }: FetchSystemsParams) => {
1513
const state = { filters: { filter: {} } };
1614
const fields = {
@@ -54,39 +52,10 @@ const fetchSystems = async ({ page, perPage }: FetchSystemsParams) => {
5452
return { results, total };
5553
};
5654

57-
const MAX_CONCURRENT_FETCHES = 5;
58-
interface FetchAllSystemsParams {
59-
total?: number;
55+
interface UseSystemsQueryParams {
56+
page: number;
6057
perPage: number;
61-
queryClient: QueryClient;
6258
}
63-
64-
export const fetchAllSystems = async ({
65-
total,
66-
perPage,
67-
queryClient,
68-
}: FetchAllSystemsParams) => {
69-
if (!total) return [];
70-
71-
const totalPages = Math.ceil(total / perPage);
72-
73-
const allPages = (await pAll(
74-
Array.from(
75-
{ length: totalPages },
76-
(_, i) => () =>
77-
queryClient.fetchQuery({
78-
queryKey: ['systems', i + 1, perPage],
79-
queryFn: () => fetchSystems({ page: i + 1, perPage }),
80-
}),
81-
),
82-
{ concurrency: MAX_CONCURRENT_FETCHES },
83-
)) as FetchSystemsReturnedValue[];
84-
85-
return allPages.flatMap((page) => page.results);
86-
};
87-
88-
type UseSystemsQueryParams = FetchSystemsParams;
89-
9059
export const useSystemsQuery = ({ page, perPage }: UseSystemsQueryParams) => {
9160
const { data, isLoading, isError, error } = useQuery({
9261
queryKey: ['systems', page, perPage],

0 commit comments

Comments
 (0)