From ce282706b1a01d5914d289d076780309490f04ad Mon Sep 17 00:00:00 2001 From: Harshith Mohan Date: Wed, 14 Feb 2024 14:13:38 +0530 Subject: [PATCH] Enable sorting for file util search results (#812) --- src/components/Utilities/UtilitiesTable.tsx | 4 ++-- src/pages/utilities/FileSearch.tsx | 3 +-- .../utilities/UnrecognizedUtilityTabs/IgnoredFilesTab.tsx | 5 +---- .../utilities/UnrecognizedUtilityTabs/UnrecognizedTab.tsx | 5 +---- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/components/Utilities/UtilitiesTable.tsx b/src/components/Utilities/UtilitiesTable.tsx index c472aaa1f..ba21e5789 100644 --- a/src/components/Utilities/UtilitiesTable.tsx +++ b/src/components/Utilities/UtilitiesTable.tsx @@ -23,7 +23,7 @@ type Props = { isFetchingNextPage: boolean; rows: FileType[] | SeriesType[]; setSortCriteria?: React.Dispatch>; - skipSort: boolean; + skipSort?: boolean; sortCriteria?: FileSortCriteriaEnum; handleRowSelect?: (id: number, select: boolean) => void; rowSelection?: Record; @@ -139,7 +139,7 @@ const HeaderItem = ( id: string; name: string; setSortCriteria?: React.Dispatch>; - skipSort: boolean; + skipSort?: boolean; sortCriteria?: FileSortCriteriaEnum; }, ) => { diff --git a/src/pages/utilities/FileSearch.tsx b/src/pages/utilities/FileSearch.tsx index c53462e1c..fabf8768f 100644 --- a/src/pages/utilities/FileSearch.tsx +++ b/src/pages/utilities/FileSearch.tsx @@ -264,7 +264,7 @@ const FileSearch = () => { const debouncedSearch = useDebounce(search, 250); const filesQuery = useFilesInfiniteQuery({ include: ['XRefs'], - sortOrder: debouncedSearch ? [] : [sortCriteria], + sortOrder: [sortCriteria], pageSize: 50, }, debouncedSearch); const [files, fileCount] = useFlattenListResult(filesQuery.data); @@ -338,7 +338,6 @@ const FileSearch = () => { rows={files} rowSelection={rowSelection} setSelectedRows={setRowSelection} - skipSort={!!debouncedSearch} setSortCriteria={setSortCriteria} sortCriteria={sortCriteria} /> diff --git a/src/pages/utilities/UnrecognizedUtilityTabs/IgnoredFilesTab.tsx b/src/pages/utilities/UnrecognizedUtilityTabs/IgnoredFilesTab.tsx index 1819419a8..8bb715622 100644 --- a/src/pages/utilities/UnrecognizedUtilityTabs/IgnoredFilesTab.tsx +++ b/src/pages/utilities/UnrecognizedUtilityTabs/IgnoredFilesTab.tsx @@ -97,9 +97,7 @@ function IgnoredFilesTab() { { pageSize: 50, include_only: ['Ignored'], - sortOrder: debouncedSearch - ? [] - : [sortCriteria, FileSortCriteriaEnum.FileName, FileSortCriteriaEnum.RelativePath], + sortOrder: [sortCriteria, FileSortCriteriaEnum.FileName, FileSortCriteriaEnum.RelativePath], }, debouncedSearch, ); @@ -173,7 +171,6 @@ function IgnoredFilesTab() { rowSelection={rowSelection} setSelectedRows={setRowSelection} setSortCriteria={setSortCriteria} - skipSort={!!debouncedSearch} sortCriteria={sortCriteria} /> )} diff --git a/src/pages/utilities/UnrecognizedUtilityTabs/UnrecognizedTab.tsx b/src/pages/utilities/UnrecognizedUtilityTabs/UnrecognizedTab.tsx index e651c8fdf..ef4b165f7 100644 --- a/src/pages/utilities/UnrecognizedUtilityTabs/UnrecognizedTab.tsx +++ b/src/pages/utilities/UnrecognizedUtilityTabs/UnrecognizedTab.tsx @@ -244,9 +244,7 @@ function UnrecognizedTab() { { pageSize: 50, include_only: ['Unrecognized'], - sortOrder: debouncedSearch - ? [] - : [sortCriteria, FileSortCriteriaEnum.FileName, FileSortCriteriaEnum.RelativePath], + sortOrder: [sortCriteria, FileSortCriteriaEnum.FileName, FileSortCriteriaEnum.RelativePath], }, debouncedSearch, ); @@ -402,7 +400,6 @@ function UnrecognizedTab() { rowSelection={rowSelection} setSelectedRows={setRowSelection} setSortCriteria={setSortCriteria} - skipSort={!!debouncedSearch} sortCriteria={sortCriteria} /> )}