From e476de5faacd5110b98c6f323017a003b675695b Mon Sep 17 00:00:00 2001 From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> Date: Wed, 29 Nov 2023 08:45:30 +0100 Subject: [PATCH] feat: update feature search (#5473) --- .../src/component/project/Project/ProjectOverview.tsx | 2 +- .../api/getters/useFeatureSearch/useFeatureSearch.ts | 4 +++- frontend/src/hooks/useTableState.ts | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/src/component/project/Project/ProjectOverview.tsx b/frontend/src/component/project/Project/ProjectOverview.tsx index 2f26d7fbfc90..c5bc19d365a6 100644 --- a/frontend/src/component/project/Project/ProjectOverview.tsx +++ b/frontend/src/component/project/Project/ProjectOverview.tsx @@ -75,7 +75,7 @@ const PaginatedProjectOverview: FC<{ sortOrder: tableState.sortOrder === 'desc' ? 'desc' : 'asc', favoritesFirst: tableState.favorites === 'true', }, - projectId, + projectId ? `IS:${projectId}` : '', tableState.search, { refreshInterval, diff --git a/frontend/src/hooks/api/getters/useFeatureSearch/useFeatureSearch.ts b/frontend/src/hooks/api/getters/useFeatureSearch/useFeatureSearch.ts index d4dd59cde965..37a77623cd37 100644 --- a/frontend/src/hooks/api/getters/useFeatureSearch/useFeatureSearch.ts +++ b/frontend/src/hooks/api/getters/useFeatureSearch/useFeatureSearch.ts @@ -127,7 +127,9 @@ const getFeatureSearchFetcher = ( ) => { const searchQueryParams = translateToQueryParams(searchValue); const sortQueryParams = translateToSortQueryParams(sortingRules); - const KEY = `api/admin/search/features?projectId=${projectId}&offset=${offset}&limit=${limit}&${searchQueryParams}&${sortQueryParams}`; + const project = projectId ? `projectId=${projectId}&` : ''; + + const KEY = `api/admin/search/features?${project}offset=${offset}&limit=${limit}&${searchQueryParams}&${sortQueryParams}`; const fetcher = () => { const path = formatApiPath(KEY); return fetch(path, { diff --git a/frontend/src/hooks/useTableState.ts b/frontend/src/hooks/useTableState.ts index 5c78b7a900fc..3ed39323aad9 100644 --- a/frontend/src/hooks/useTableState.ts +++ b/frontend/src/hooks/useTableState.ts @@ -10,7 +10,7 @@ const filterObjectKeys = >( Object.entries(obj).filter(([key]) => keys.includes(key as keyof T)), ) as T; -const defaultStoredKeys = [ +export const defaultStoredKeys = [ 'pageSize', 'search', 'sortBy', @@ -18,7 +18,7 @@ const defaultStoredKeys = [ 'favorites', 'columns', ]; -const defaultQueryKeys = [...defaultStoredKeys, 'page']; +export const defaultQueryKeys = [...defaultStoredKeys, 'page']; /** * There are 3 sources of params, in order of priority: @@ -38,8 +38,8 @@ const defaultQueryKeys = [...defaultStoredKeys, 'page']; export const useTableState = >( defaultParams: Params, storageId: string, - queryKeys?: Array, - storageKeys?: Array, + queryKeys?: Array, + storageKeys?: Array, ) => { const [searchParams, setSearchParams] = useSearchParams(); const { value: storedParams, setValue: setStoredParams } =