1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

feat: update feature search (#5473)

This commit is contained in:
Tymoteusz Czech 2023-11-29 08:45:30 +01:00 committed by GitHub
parent 7800211945
commit e476de5faa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -75,7 +75,7 @@ const PaginatedProjectOverview: FC<{
sortOrder: tableState.sortOrder === 'desc' ? 'desc' : 'asc', sortOrder: tableState.sortOrder === 'desc' ? 'desc' : 'asc',
favoritesFirst: tableState.favorites === 'true', favoritesFirst: tableState.favorites === 'true',
}, },
projectId, projectId ? `IS:${projectId}` : '',
tableState.search, tableState.search,
{ {
refreshInterval, refreshInterval,

View File

@ -127,7 +127,9 @@ const getFeatureSearchFetcher = (
) => { ) => {
const searchQueryParams = translateToQueryParams(searchValue); const searchQueryParams = translateToQueryParams(searchValue);
const sortQueryParams = translateToSortQueryParams(sortingRules); 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 fetcher = () => {
const path = formatApiPath(KEY); const path = formatApiPath(KEY);
return fetch(path, { return fetch(path, {

View File

@ -10,7 +10,7 @@ const filterObjectKeys = <T extends Record<string, unknown>>(
Object.entries(obj).filter(([key]) => keys.includes(key as keyof T)), Object.entries(obj).filter(([key]) => keys.includes(key as keyof T)),
) as T; ) as T;
const defaultStoredKeys = [ export const defaultStoredKeys = [
'pageSize', 'pageSize',
'search', 'search',
'sortBy', 'sortBy',
@ -18,7 +18,7 @@ const defaultStoredKeys = [
'favorites', 'favorites',
'columns', 'columns',
]; ];
const defaultQueryKeys = [...defaultStoredKeys, 'page']; export const defaultQueryKeys = [...defaultStoredKeys, 'page'];
/** /**
* There are 3 sources of params, in order of priority: * There are 3 sources of params, in order of priority:
@ -38,8 +38,8 @@ const defaultQueryKeys = [...defaultStoredKeys, 'page'];
export const useTableState = <Params extends Record<string, string>>( export const useTableState = <Params extends Record<string, string>>(
defaultParams: Params, defaultParams: Params,
storageId: string, storageId: string,
queryKeys?: Array<keyof Params>, queryKeys?: Array<keyof Params | string>,
storageKeys?: Array<keyof Params>, storageKeys?: Array<keyof Params | string>,
) => { ) => {
const [searchParams, setSearchParams] = useSearchParams(); const [searchParams, setSearchParams] = useSearchParams();
const { value: storedParams, setValue: setStoredParams } = const { value: storedParams, setValue: setStoredParams } =