-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(SystemsPage): RHINENG-5977 - Fix URL params filters handling
- Loading branch information
Showing
41 changed files
with
90 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+8.12 KB
(110%)
...ts/CVEs/__image_snapshots__/CVE list table exists and matches screenshot #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+8.13 KB
(110%)
...ts/CVEs/__image_snapshots__/CVE list table exists and matches screenshot #1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-107 KB
...s/CVEs/__image_snapshots__/CVE list table exists and matches screenshot #10.png
Binary file not shown.
Binary file removed
BIN
-107 KB
...s/CVEs/__image_snapshots__/CVE list table exists and matches screenshot #11.png
Binary file not shown.
Binary file removed
BIN
-107 KB
...s/CVEs/__image_snapshots__/CVE list table exists and matches screenshot #12.png
Binary file not shown.
Binary file modified
BIN
+8.13 KB
(110%)
...ts/CVEs/__image_snapshots__/CVE list table exists and matches screenshot #2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-107 KB
...ts/CVEs/__image_snapshots__/CVE list table exists and matches screenshot #3.png
Binary file not shown.
Binary file removed
BIN
-107 KB
...ts/CVEs/__image_snapshots__/CVE list table exists and matches screenshot #4.png
Binary file not shown.
Binary file removed
BIN
-107 KB
...ts/CVEs/__image_snapshots__/CVE list table exists and matches screenshot #5.png
Binary file not shown.
Binary file removed
BIN
-107 KB
...ts/CVEs/__image_snapshots__/CVE list table exists and matches screenshot #6.png
Binary file not shown.
Binary file removed
BIN
-107 KB
...ts/CVEs/__image_snapshots__/CVE list table exists and matches screenshot #7.png
Binary file not shown.
Binary file removed
BIN
-107 KB
...ts/CVEs/__image_snapshots__/CVE list table exists and matches screenshot #8.png
Binary file not shown.
Binary file removed
BIN
-107 KB
...ts/CVEs/__image_snapshots__/CVE list table exists and matches screenshot #9.png
Binary file not shown.
Binary file modified
BIN
-66 Bytes
(100%)
...mage_snapshots__/CVE list table has expanded row that matches screenshot #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.7 KB
(120%)
...mage_snapshots__/CVE list table has expanded row that matches screenshot #1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.7 KB
(120%)
...mage_snapshots__/CVE list table has expanded row that matches screenshot #2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-35.2 KB
...mage_snapshots__/CVE list table has expanded row that matches screenshot #3.png
Binary file not shown.
Binary file removed
BIN
-35.2 KB
...mage_snapshots__/CVE list table has expanded row that matches screenshot #4.png
Binary file not shown.
Binary file removed
BIN
-35.2 KB
...mage_snapshots__/CVE list table has expanded row that matches screenshot #5.png
Binary file not shown.
Binary file removed
BIN
-35.2 KB
...mage_snapshots__/CVE list table has expanded row that matches screenshot #6.png
Binary file not shown.
Binary file removed
BIN
-35.2 KB
...mage_snapshots__/CVE list table has expanded row that matches screenshot #7.png
Binary file not shown.
Binary file modified
BIN
+348 Bytes
(100%)
...table shows missing metadata empty state when CVE description is unknown #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5 KB
(120%)
...table shows missing metadata empty state when CVE description is unknown #1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5 KB
(120%)
...table shows missing metadata empty state when CVE description is unknown #2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-30.7 KB
...table shows missing metadata empty state when CVE description is unknown #3.png
Binary file not shown.
Binary file removed
BIN
-30.7 KB
...table shows missing metadata empty state when CVE description is unknown #4.png
Diff not rendered.
Binary file removed
BIN
-30.7 KB
...table shows missing metadata empty state when CVE description is unknown #5.png
Diff not rendered.
Binary file modified
BIN
+695 Bytes
(100%)
... table without canEditStatusOrBusinessRisk permission matches screenshot #0.png
Oops, something went wrong.
Binary file added
BIN
+115 KB
... table without canEditStatusOrBusinessRisk permission matches screenshot #1.png
Oops, something went wrong.
Binary file modified
BIN
+8.54 KB
(110%)
...e_snapshots__/CVE list table without items exists and matches screenshot #0.png
Oops, something went wrong.
Binary file modified
BIN
+8.61 KB
(110%)
...e_snapshots__/CVE list table without items exists and matches screenshot #1.png
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/Components/SmartComponents/SystemsExposedTable/SystemsExposedTable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useCallback } from 'react'; | ||
import { useSearchParams } from 'react-router-dom'; | ||
|
||
// TODO DRY:similar to constructParameters | ||
export function constructURLParameters(urlParams, allowedParams) { | ||
if (urlParams) { | ||
const params = { ...urlParams }; | ||
Object.keys(urlParams).forEach( | ||
key => ( | ||
params[key] === undefined | ||
|| params[key] === '' | ||
|| !allowedParams.includes(key) | ||
|| params[key] === false | ||
) | ||
&& delete params[key] | ||
|
||
); | ||
return params; | ||
} | ||
} | ||
|
||
export const useUrlParams = (allowedParams) => { | ||
const [searchParams, setSearchParams] = useSearchParams(); | ||
|
||
const setUrlParams = useCallback((parameters) => { | ||
const para = constructURLParameters(parameters, allowedParams); | ||
|
||
setSearchParams(para); | ||
}, [JSON.stringify(allowedParams)]); | ||
|
||
return [searchParams, setUrlParams]; | ||
}; | ||
|
||
export default useUrlParams; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { renderHook, act } from '@testing-library/react'; | ||
import { createTestWrapper } from '../Utilities/TestWrapper'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
|
||
import useUrlParams, { constructURLParameters } from './useUrlParams'; | ||
|
||
describe('MiscHelper', () => { | ||
it('useUrlParams', async () => { | ||
const { result } = renderHook(() => useUrlParams(['a', 'b']), { | ||
wrapper: createTestWrapper(MemoryRouter, { initialEntries: ['/'] }) | ||
}); | ||
|
||
await act(()=> { | ||
result.current[1]({ a: 'testValue', b: 'testValue', c: 'testValue' }); | ||
}); | ||
|
||
expect(result.current[0].get('a')).toEqual('testValue'); | ||
expect(result.current[0].get('b')).toEqual('testValue'); | ||
expect(result.current[0].get('c')).toEqual(null); | ||
}); | ||
|
||
it.each` | ||
urlParams | expected_data | ||
${undefined} | ${undefined} | ||
${{}} | ${{}} | ||
${{ a: 'testValue', b: undefined }} | ${{ a: 'testValue' }} | ||
${{ a: false, b: 'testValue' }} | ${{ b: 'testValue' }} | ||
${{ a: 'testValue', c: 'testValue' }} | ${{ a: 'testValue' }} | ||
${{ a: '', b: 'testValue' }} | ${{ b: 'testValue' }} | ||
`('constructURLParameters', ({ urlParams, expected_data }) => { // eslint-disable-line camelcase | ||
|
||
const result = constructURLParameters(urlParams, ['a', 'b']); | ||
expect(result).toEqual(expected_data); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters