Skip to content

Commit

Permalink
feat: update feature search (#5473)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymek authored Nov 29, 2023
1 parent 7800211 commit e476de5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion frontend/src/component/project/Project/ProjectOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const PaginatedProjectOverview: FC<{
sortOrder: tableState.sortOrder === 'desc' ? 'desc' : 'asc',
favoritesFirst: tableState.favorites === 'true',
},
projectId,
projectId ? `IS:${projectId}` : '',
tableState.search,
{
refreshInterval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/hooks/useTableState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ const filterObjectKeys = <T extends Record<string, unknown>>(
Object.entries(obj).filter(([key]) => keys.includes(key as keyof T)),
) as T;

const defaultStoredKeys = [
export const defaultStoredKeys = [
'pageSize',
'search',
'sortBy',
'sortOrder',
'favorites',
'columns',
];
const defaultQueryKeys = [...defaultStoredKeys, 'page'];
export const defaultQueryKeys = [...defaultStoredKeys, 'page'];

/**
* There are 3 sources of params, in order of priority:
Expand All @@ -38,8 +38,8 @@ const defaultQueryKeys = [...defaultStoredKeys, 'page'];
export const useTableState = <Params extends Record<string, string>>(
defaultParams: Params,
storageId: string,
queryKeys?: Array<keyof Params>,
storageKeys?: Array<keyof Params>,
queryKeys?: Array<keyof Params | string>,
storageKeys?: Array<keyof Params | string>,
) => {
const [searchParams, setSearchParams] = useSearchParams();
const { value: storedParams, setValue: setStoredParams } =
Expand Down

0 comments on commit e476de5

Please sign in to comment.