mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat: pagination reset on feature list (#5644)
This commit is contained in:
parent
a595c0fbcc
commit
772682176e
@ -136,5 +136,7 @@ test('Filter table by project', async () => {
|
|||||||
await screen.findByText(
|
await screen.findByText(
|
||||||
'No feature toggles available. Get started by adding a new feature toggle.',
|
'No feature toggles available. Get started by adding a new feature toggle.',
|
||||||
);
|
);
|
||||||
expect(window.location.href).toContain('?columns=&project=IS%3Aproject-b');
|
expect(window.location.href).toContain(
|
||||||
|
'?offset=0&columns=&project=IS%3Aproject-b',
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
@ -92,6 +92,9 @@ export const FeatureToggleListTable: VFC = () => {
|
|||||||
'features-list-table',
|
'features-list-table',
|
||||||
stateConfig,
|
stateConfig,
|
||||||
);
|
);
|
||||||
|
// offset needs to be first so we can override it
|
||||||
|
const setTableStateWithOffsetReset: typeof setTableState = (data) =>
|
||||||
|
setTableState({ offset: 0, ...data });
|
||||||
|
|
||||||
const filterState = {
|
const filterState = {
|
||||||
project: tableState.project,
|
project: tableState.project,
|
||||||
@ -138,7 +141,7 @@ export const FeatureToggleListTable: VFC = () => {
|
|||||||
<FavoriteIconHeader
|
<FavoriteIconHeader
|
||||||
isActive={tableState.favoritesFirst}
|
isActive={tableState.favoritesFirst}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setTableState({
|
setTableStateWithOffsetReset({
|
||||||
favoritesFirst: !tableState.favoritesFirst,
|
favoritesFirst: !tableState.favoritesFirst,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -227,7 +230,7 @@ export const FeatureToggleListTable: VFC = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const table = useReactTable(
|
const table = useReactTable(
|
||||||
withTableState(tableState, setTableState, {
|
withTableState(tableState, setTableStateWithOffsetReset, {
|
||||||
columns,
|
columns,
|
||||||
data,
|
data,
|
||||||
}),
|
}),
|
||||||
@ -252,7 +255,8 @@ export const FeatureToggleListTable: VFC = () => {
|
|||||||
}
|
}
|
||||||
}, [isSmallScreen, isMediumScreen]);
|
}, [isSmallScreen, isMediumScreen]);
|
||||||
|
|
||||||
const setSearchValue = (query = '') => setTableState({ query });
|
const setSearchValue = (query = '') =>
|
||||||
|
setTableStateWithOffsetReset({ query });
|
||||||
|
|
||||||
const rows = table.getRowModel().rows;
|
const rows = table.getRowModel().rows;
|
||||||
|
|
||||||
@ -336,7 +340,7 @@ export const FeatureToggleListTable: VFC = () => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<FeatureToggleFilters
|
<FeatureToggleFilters
|
||||||
onChange={setTableState}
|
onChange={setTableStateWithOffsetReset}
|
||||||
state={filterState}
|
state={filterState}
|
||||||
/>
|
/>
|
||||||
<SearchHighlightProvider value={tableState.query || ''}>
|
<SearchHighlightProvider value={tableState.query || ''}>
|
||||||
|
Loading…
Reference in New Issue
Block a user