From dfc4c5423f4a42fef3d52b589197627da0afb10b Mon Sep 17 00:00:00 2001 From: Brandon Andre Date: Thu, 23 Nov 2023 13:28:04 -0500 Subject: [PATCH] Support #32267 - Saved search doesn't remember the group - Changed filter to generate an IN with all of the options instead. - Updated the test for the new RSQL being generated. --- .../components/storage/StorageFilter.tsx | 17 ++++++++++------- .../__tests__/BrowseStorageTree.test.tsx | 6 +++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/dina-ui/components/storage/StorageFilter.tsx b/packages/dina-ui/components/storage/StorageFilter.tsx index af894c3d07..466169005f 100644 --- a/packages/dina-ui/components/storage/StorageFilter.tsx +++ b/packages/dina-ui/components/storage/StorageFilter.tsx @@ -63,16 +63,19 @@ export function StorageFilter({ onChange }: StorageFilterProps) { ] : []), ...(groupNames - ? groupNames.map((group, index) => { - return { - id: -index, + ? [ + { + id: -1234, type: "FILTER_ROW" as const, - attribute: "group", predicate: "IS" as const, searchType: "EXACT_MATCH" as const, - value: group - }; - }) + value: groupNames.join(","), + attribute: { + allowRange: true, + name: "group" + } + } + ] : []) ] }); diff --git a/packages/dina-ui/components/storage/__tests__/BrowseStorageTree.test.tsx b/packages/dina-ui/components/storage/__tests__/BrowseStorageTree.test.tsx index 9d85e719a6..62c029ca29 100644 --- a/packages/dina-ui/components/storage/__tests__/BrowseStorageTree.test.tsx +++ b/packages/dina-ui/components/storage/__tests__/BrowseStorageTree.test.tsx @@ -77,7 +77,7 @@ const mockGet = jest.fn(async (path, params = {}) => { case "collection-api/storage-unit": if ( params.filter?.parentStorageUnit === null || - params.filter?.rsql === "group==aafc;group==cnc" + params.filter?.rsql === "group=in=(aafc,cnc)" ) { // Top-level units: return { data: [STORAGE_A], meta: { totalResourceCount: 1 } }; @@ -158,7 +158,7 @@ describe("BrowseStorageTree component", () => { // With no filter, gets the top-level units: expect(mockGet).lastCalledWith("collection-api/storage-unit", { filter: { - rsql: "group==aafc;group==cnc" + rsql: "group=in=(aafc,cnc)" }, include: "storageUnitChildren,storageUnitType", page: { @@ -179,7 +179,7 @@ describe("BrowseStorageTree component", () => { // With a filter, gets units from any level matching the search text: expect(mockGet).lastCalledWith("collection-api/storage-unit", { filter: { - rsql: "name==*test-search-text*;group==aafc;group==cnc" + rsql: "name==*test-search-text*;group=in=(aafc,cnc)" }, include: "storageUnitChildren,storageUnitType", page: {