|
1 | | -import { useMemo } from 'react' |
| 1 | +import { useCallback, useMemo } from 'react' |
2 | 2 | import { generatePath, Link, useHistory } from 'react-router-dom' |
3 | 3 |
|
4 | 4 | import { |
@@ -237,46 +237,49 @@ const NodeViewGroupListWrapper = ({ |
237 | 237 |
|
238 | 238 | const NodeViewGroupList = ({ nodeViewGroupType }: { nodeViewGroupType: NodeViewGroupType }) => { |
239 | 239 | const { push } = useHistory() |
240 | | - const getRows: TableProps<NodeViewGroupRowType, FiltersTypeEnum.URL, {}>['getRows'] = async ( |
241 | | - { |
242 | | - searchKey, |
243 | | - offset, |
244 | | - pageSize, |
245 | | - sortBy, |
246 | | - sortOrder, |
247 | | - errorType, |
248 | | - autoscalerType, |
249 | | - schedulableType, |
250 | | - }: Record<NodeViewGroupListFiltersTypeEnum, string> & Parameters<TableProps['getRows']>[0], |
251 | | - abortSignal, |
252 | | - ) => { |
253 | | - const response = await getNodeViewGroupList({ |
254 | | - searchKey, |
255 | | - groupBy: nodeViewGroupType, |
256 | | - offset, |
257 | | - pageSize, |
258 | | - sortBy, |
259 | | - sortOrder, |
260 | | - ...(nodeViewGroupType === NodeViewGroupType.NODE_ERRORS && errorType !== 'ALL' |
261 | | - ? { errorType: errorType as NodeErrorsKeys } |
262 | | - : {}), |
263 | | - ...(nodeViewGroupType === NodeViewGroupType.AUTOSCALER_MANAGED && autoscalerType !== 'ALL' |
264 | | - ? { autoscalerType: autoscalerType as AutoscalerTypes } |
265 | | - : {}), |
266 | | - ...(nodeViewGroupType === NodeViewGroupType.NODE_SCHEDULING && schedulableType !== 'ALL' |
267 | | - ? { schedulableType: schedulableType as NodeSchedulingKeys } |
268 | | - : {}), |
| 240 | + const getRows: TableProps<NodeViewGroupRowType, FiltersTypeEnum.URL, {}>['getRows'] = useCallback( |
| 241 | + async ( |
| 242 | + { |
| 243 | + searchKey, |
| 244 | + offset, |
| 245 | + pageSize, |
| 246 | + sortBy, |
| 247 | + sortOrder, |
| 248 | + errorType, |
| 249 | + autoscalerType, |
| 250 | + schedulableType, |
| 251 | + }: Record<NodeViewGroupListFiltersTypeEnum, string> & Parameters<TableProps['getRows']>[0], |
269 | 252 | abortSignal, |
270 | | - }) |
| 253 | + ) => { |
| 254 | + const response = await getNodeViewGroupList({ |
| 255 | + searchKey, |
| 256 | + groupBy: nodeViewGroupType, |
| 257 | + offset, |
| 258 | + pageSize, |
| 259 | + sortBy, |
| 260 | + sortOrder, |
| 261 | + ...(nodeViewGroupType === NodeViewGroupType.NODE_ERRORS && errorType !== 'ALL' |
| 262 | + ? { errorType: errorType as NodeErrorsKeys } |
| 263 | + : {}), |
| 264 | + ...(nodeViewGroupType === NodeViewGroupType.AUTOSCALER_MANAGED && autoscalerType !== 'ALL' |
| 265 | + ? { autoscalerType: autoscalerType as AutoscalerTypes } |
| 266 | + : {}), |
| 267 | + ...(nodeViewGroupType === NodeViewGroupType.NODE_SCHEDULING && schedulableType !== 'ALL' |
| 268 | + ? { schedulableType: schedulableType as NodeSchedulingKeys } |
| 269 | + : {}), |
| 270 | + abortSignal, |
| 271 | + }) |
271 | 272 |
|
272 | | - return { |
273 | | - rows: (response.result?.nodeList || []).map((node) => ({ |
274 | | - id: `${node.nodeName}-${node.clusterName}`, |
275 | | - data: node, |
276 | | - })), |
277 | | - totalRows: response.result?.totalCount || 0, |
278 | | - } |
279 | | - } |
| 273 | + return { |
| 274 | + rows: (response.result?.nodeList || []).map((node) => ({ |
| 275 | + id: `${node.nodeName}-${node.clusterName}`, |
| 276 | + data: node, |
| 277 | + })), |
| 278 | + totalRows: response.result?.totalCount || 0, |
| 279 | + } |
| 280 | + }, |
| 281 | + [], |
| 282 | + ) |
280 | 283 |
|
281 | 284 | const clearFilters = () => { |
282 | 285 | push({ search: '' }) |
@@ -311,7 +314,7 @@ const NodeViewGroupList = ({ nodeViewGroupType }: { nodeViewGroupType: NodeViewG |
311 | 314 | }} |
312 | 315 | paginationVariant={PaginationEnum.PAGINATED} |
313 | 316 | filtersVariant={FiltersTypeEnum.URL} |
314 | | - filter={() => true} |
| 317 | + filter={null} |
315 | 318 | additionalFilterProps={{ |
316 | 319 | initialSortKey: 'nodeName', |
317 | 320 | parseSearchParams: (searchParams) => ({ |
|
0 commit comments