diff --git a/package-lock.json b/package-lock.json index e6be9778d5..1f54bb8c95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gsa", - "version": "23.3.1-dev1", + "version": "24.0.2-dev1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gsa", - "version": "23.3.1-dev1", + "version": "24.0.2-dev1", "license": "AGPL-3.0+", "dependencies": { "@greenbone/opensight-ui-components": "^0.4.1-alpha6", diff --git a/src/gmp/models/filter.js b/src/gmp/models/filter.js index c6842bccac..231fe1d2a3 100644 --- a/src/gmp/models/filter.js +++ b/src/gmp/models/filter.js @@ -806,6 +806,7 @@ export const VULNS_FILTER_FILTER = Filter.fromString('type=vuln'); export const DEFAULT_FALLBACK_FILTER = Filter.fromString('sort=name first=1'); +export const NO_ROW_LIMIT = -1; export const RESET_FILTER = Filter.fromString('first=1'); export const DEFAULT_ROWS_PER_PAGE = 50; diff --git a/src/web/entities/__tests__/filterprovider.jsx b/src/web/entities/__tests__/filterprovider.jsx index d6d3b6a778..765bc064f7 100644 --- a/src/web/entities/__tests__/filterprovider.jsx +++ b/src/web/entities/__tests__/filterprovider.jsx @@ -57,7 +57,7 @@ describe('FilterProvider component tests', () => { }); test('should prefer pageFilter over defaultSettingFilter', async () => { - const resultingFilter = Filter.fromString('page=filter rows=42'); + const resultingFilter = Filter.fromString('page=filter'); const pFilter = Filter.fromString('page=filter'); @@ -99,7 +99,7 @@ describe('FilterProvider component tests', () => { test('should allow to set a pageName for loading the pageFilter', async () => { const gmpName = 'task'; const pageName = 'foo-bar-baz'; - const resultingFilter = Filter.fromString('page=filter rows=42'); + const resultingFilter = Filter.fromString('page=filter'); const pFilter = Filter.fromString('page=filter'); @@ -143,7 +143,7 @@ describe('FilterProvider component tests', () => { }); test('should use defaultSettingFilter', async () => { - const resultingFilter = Filter.fromString('foo=bar rows=42'); + const resultingFilter = Filter.fromString('foo=bar'); const defaultSettingFilter = Filter.fromString('foo=bar'); @@ -180,7 +180,7 @@ describe('FilterProvider component tests', () => { }); test('should use fallbackFilter if defaultSettingFilter could not be loaded', async () => { - const resultingFilter = Filter.fromString('fall=back rows=42'); + const resultingFilter = Filter.fromString('fall=back'); const fallbackFilter = Filter.fromString('fall=back'); @@ -222,7 +222,7 @@ describe('FilterProvider component tests', () => { test('should use fallbackFilter if given', async () => { // if no usersettings defaultFilter exists use the given fallbackFilter - const resultingFilter = Filter.fromString('fall=back rows=42'); + const resultingFilter = Filter.fromString('fall=back'); const fallbackFilter = Filter.fromString('fall=back'); @@ -260,7 +260,7 @@ describe('FilterProvider component tests', () => { }); test('should use default fallbackFilter as last resort', async () => { - const resultingFilter = DEFAULT_FALLBACK_FILTER.copy().set('rows', 42); + const resultingFilter = DEFAULT_FALLBACK_FILTER.copy(); const getSetting = testing.fn().mockResolvedValue({}); const subscribe = testing.fn(); @@ -332,7 +332,7 @@ describe('FilterProvider component tests', () => { }); test('should use default rows per page if rows per page setting could not be loaded', async () => { - const resultingFilter = Filter.fromString('fall=back rows=50'); + const resultingFilter = Filter.fromString('fall=back'); const fallbackFilter = Filter.fromString('fall=back'); const getSetting = testing.fn().mockRejectedValue(new Error('an error')); diff --git a/src/web/hooks/usePageFilter.js b/src/web/hooks/usePageFilter.js index f38fd2d689..31b272e9ae 100644 --- a/src/web/hooks/usePageFilter.js +++ b/src/web/hooks/usePageFilter.js @@ -15,6 +15,7 @@ import Filter, { DEFAULT_FALLBACK_FILTER, DEFAULT_ROWS_PER_PAGE, RESET_FILTER, + NO_ROW_LIMIT, } from 'gmp/models/filter'; import {isDefined, hasValue} from 'gmp/utils/identity'; @@ -74,6 +75,7 @@ const usePageFilter = ( userSettingDefaultSel.getError(), ]; }); + const pageFilter = useShallowEqualSelector(state => getPage(state).getFilter(pageName), ); @@ -113,12 +115,14 @@ const usePageFilter = ( useEffect(() => { if (hasValue(locationQueryFilterString)) { - dispatch( - setPageFilter(pageName, Filter.fromString(locationQueryFilterString)), - ); + const filter = Filter.fromString(locationQueryFilterString); + if (!filter.has('rows') && isDefined(rowsPerPage)) { + filter.set('rows', rowsPerPage); + } + dispatch(setPageFilter(pageName, filter)); } setLocationQueryFilter(undefined); - }, []); // eslint-disable-line react-hooks/exhaustive-deps + }, [locationQueryFilterString, rowsPerPage, dispatch, pageName]); if (hasValue(locationQueryFilter)) { returnedFilter = locationQueryFilter; @@ -140,7 +144,11 @@ const usePageFilter = ( rowsPerPage = DEFAULT_ROWS_PER_PAGE; } - if (!returnedFilter.has('rows') && isDefined(rowsPerPage)) { + if ( + !returnedFilter.has('rows') && + isDefined(rowsPerPage) && + rowsPerPage === NO_ROW_LIMIT + ) { returnedFilter = returnedFilter.set('rows', rowsPerPage); }