diff --git a/package-lock.json b/package-lock.json index bfa886ea4..15e7fb983 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@redhat-cloud-services/frontend-components-pdf-generator": "2.6.7", "@redhat-cloud-services/frontend-components-translations": "3.2.3", "@redhat-cloud-services/frontend-components-utilities": "3.2.8", - "@redhat-cloud-services/vulnerabilities-client": "1.0.106", + "@redhat-cloud-services/vulnerabilities-client": "1.0.107", "axios": "^0.26.1", "classnames": "^2.2.5", "dot": "^1.1.3", @@ -4124,9 +4124,9 @@ } }, "node_modules/@redhat-cloud-services/vulnerabilities-client": { - "version": "1.0.106", - "resolved": "https://registry.npmjs.org/@redhat-cloud-services/vulnerabilities-client/-/vulnerabilities-client-1.0.106.tgz", - "integrity": "sha512-oGnd1w8nJZJcXRnvKzU0K1yswl5zWxGWiTQ1QAzJVsDi8EldGJdAntwVLYB3zJRJKhKZfu8ap51m43qjIFZO1Q==", + "version": "1.0.107", + "resolved": "https://registry.npmjs.org/@redhat-cloud-services/vulnerabilities-client/-/vulnerabilities-client-1.0.107.tgz", + "integrity": "sha512-H2FXP/Lm+xqthK0KYvNyB05I5mEN/V4qohl/99cp/QvOiduNu9NK8KwwoxyLQ/xt0tTMbOnFC/rMtSp/87kVSw==", "dependencies": { "axios": "^0.21.1", "yaml": "^1.8.3" @@ -11018,9 +11018,9 @@ } }, "node_modules/http-proxy-middleware": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.4.tgz", - "integrity": "sha512-m/4FxX17SUvz4lJ5WPXOHDUuCwIqXLfLHs1s0uZ3oYjhoXlx9csYxaOa0ElDEJ+h8Q4iJ1s+lTMbiCa4EXIJqg==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz", + "integrity": "sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==", "dev": true, "dependencies": { "@types/http-proxy": "^1.17.8", @@ -27261,9 +27261,9 @@ } }, "@redhat-cloud-services/vulnerabilities-client": { - "version": "1.0.106", - "resolved": "https://registry.npmjs.org/@redhat-cloud-services/vulnerabilities-client/-/vulnerabilities-client-1.0.106.tgz", - "integrity": "sha512-oGnd1w8nJZJcXRnvKzU0K1yswl5zWxGWiTQ1QAzJVsDi8EldGJdAntwVLYB3zJRJKhKZfu8ap51m43qjIFZO1Q==", + "version": "1.0.107", + "resolved": "https://registry.npmjs.org/@redhat-cloud-services/vulnerabilities-client/-/vulnerabilities-client-1.0.107.tgz", + "integrity": "sha512-H2FXP/Lm+xqthK0KYvNyB05I5mEN/V4qohl/99cp/QvOiduNu9NK8KwwoxyLQ/xt0tTMbOnFC/rMtSp/87kVSw==", "requires": { "axios": "^0.21.1", "yaml": "^1.8.3" @@ -32778,9 +32778,9 @@ } }, "http-proxy-middleware": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.4.tgz", - "integrity": "sha512-m/4FxX17SUvz4lJ5WPXOHDUuCwIqXLfLHs1s0uZ3oYjhoXlx9csYxaOa0ElDEJ+h8Q4iJ1s+lTMbiCa4EXIJqg==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz", + "integrity": "sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==", "dev": true, "requires": { "@types/http-proxy": "^1.17.8", diff --git a/package.json b/package.json index 9b212a243..d7d4ece4f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@redhat-cloud-services/frontend-components-pdf-generator": "2.6.7", "@redhat-cloud-services/frontend-components-translations": "3.2.3", "@redhat-cloud-services/frontend-components-utilities": "3.2.8", - "@redhat-cloud-services/vulnerabilities-client": "1.0.106", + "@redhat-cloud-services/vulnerabilities-client": "1.0.107", "axios": "^0.26.1", "classnames": "^2.2.5", "dot": "^1.1.3", diff --git a/src/Components/SmartComponents/Dashbar/Dashbar.js b/src/Components/SmartComponents/Dashbar/Dashbar.js index 799b8fe01..3db54a855 100644 --- a/src/Components/SmartComponents/Dashbar/Dashbar.js +++ b/src/Components/SmartComponents/Dashbar/Dashbar.js @@ -2,8 +2,8 @@ import React, { useEffect, useState } from 'react'; import { Card, Grid, GridItem, StackItem, Stack, Alert, CardBody, Text } from '@patternfly/react-core'; import { Main } from '@redhat-cloud-services/frontend-components/Main'; import { SecurityIcon } from '@patternfly/react-icons'; -import { CVES_ALLOWED_PARAMS, impactList, CVES_DEFAULT_FILTERS } from '../../../Helpers/constants'; -import { constructFilterParameters, useUrlParams } from '../../../Helpers/MiscHelper'; +import { impactList, CVES_DEFAULT_FILTERS } from '../../../Helpers/constants'; +import { constructFilterParameters } from '../../../Helpers/MiscHelper'; import { useDispatch, useSelector } from 'react-redux'; import { changeCveListParameters } from '../../../Store/Actions/Actions'; import { FormattedMessage } from 'react-intl'; @@ -49,7 +49,7 @@ DashbarItem.propTypes = { const Dashbar = () => { const intl = useIntl(); const dispatch = useDispatch(); - const [urlParameters] = useUrlParams([CVES_ALLOWED_PARAMS]); + const [isFirstLoad, setFirstLoad] = useState(true); const [dashbar, setDashbar] = useState({}); const [announcement, setAnnouncement] = useState({}); const [isDashbarLoading, setDashbarLoading] = useState(true); @@ -76,16 +76,20 @@ const Dashbar = () => { }; const fetchDashbar = async () => { - let data = await getDashbar(); + let data = await getDashbar(parameters); setDashbar(data); setDashbarLoading(false); }; - fetchAnnouncements(); - fetchDashbar(); - }, []); + if (isFirstLoad) { + setFirstLoad(false); + } else { + fetchAnnouncements(); + fetchDashbar(); + } + }, [parameters]); - return (urlParameters?.dashbar === 'true' && + return (
diff --git a/src/Components/SmartComponents/Dashbar/Dashbar.test.js b/src/Components/SmartComponents/Dashbar/Dashbar.test.js deleted file mode 100644 index 03597a792..000000000 --- a/src/Components/SmartComponents/Dashbar/Dashbar.test.js +++ /dev/null @@ -1,66 +0,0 @@ -import Dashbar from "./Dashbar"; -import { Card, Grid } from "@patternfly/react-core"; -import toJson from "enzyme-to-json"; -import { mountWithIntl } from "../../../Helpers/MiscHelper"; -import { Provider } from "react-redux"; -import configureStore from "redux-mock-store"; -import { BrowserRouter as Router } from "react-router-dom"; -import { DashbarItem } from './Dashbar' - -jest.mock("react-redux", () => ({ - ...jest.requireActual("react-redux"), - useSelector: jest.fn(), -})); - -const mockStore = configureStore([(store) => (next) => (action) => { }]); -let store = mockStore({}); - -jest.mock("../../../Helpers/MiscHelper", () => ({ - ...jest.requireActual("../../../Helpers/MiscHelper"), - useUrlParams: () => [{ dashbar: "true" }, jest.fn()], -})); - - -jest.mock("../../../Helpers/APIHelper", () => ({ - ...jest.requireActual("../../../Helpers/APIHelper"), - getAnnouncement: () => new Promise((resolve) => resolve({ message: "Message test!" })), - getDashbar: () => new Promise((resolve) => resolve({ exploitable_cves: 1, cves_with_rule: 2, critical_cves: 3, important_cves: 4 })) -})) - -describe("Dashbar", () => { - it("Should match the snapshot", async () => { - - const wrapper = await mountWithIntl( - - - - - - ); - wrapper.update() - expect(toJson(wrapper)).toMatchSnapshot(); - }); - it("Should render Grid with props hasGutter = true", async () => { - const wrapper = await mountWithIntl( - - - - - - ); - wrapper.update() - expect(wrapper.find(Grid)).toHaveLength(1); - expect(wrapper.find(Grid).prop("hasGutter")).toBeTruthy(); - }); - it("Should have 4 DashbarItems", async () => { - const wrapper = await mountWithIntl( - - - - - - ); - wrapper.update() - expect(wrapper.find(DashbarItem)).toHaveLength(4); - }); -}); diff --git a/src/Components/SmartComponents/Dashbar/__snapshots__/Dashbar.test.js.snap b/src/Components/SmartComponents/Dashbar/__snapshots__/Dashbar.test.js.snap deleted file mode 100644 index e71bceeb3..000000000 --- a/src/Components/SmartComponents/Dashbar/__snapshots__/Dashbar.test.js.snap +++ /dev/null @@ -1,521 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Dashbar Should match the snapshot 1`] = ` - - - - - -
-
- -
- -
- -
- -
- - } - > - -
- -
- -

- - CVEs with known exploits - -

-
- -

- - 1 - -

-
-
-
-
-
-
-
-
- -
- - } - > - -
- -
- -

- - CVEs with security rules - -

-
- -

- - 2 - -

-
-
-
-
-
-
-
-
- -
- - } - > - - - - -
-
- -
- - } - > - - - - -
-
-
-
-
-
- -
- -
- -
- - - - - -
-
-

- - Warning alert: - - Announcement -

-
- Message test! -
-
-
-
-
-
-
-
-
-
-
-
-
-
-`; diff --git a/src/Helpers/constants.js b/src/Helpers/constants.js index 63230a885..47d4bd039 100644 --- a/src/Helpers/constants.js +++ b/src/Helpers/constants.js @@ -870,8 +870,7 @@ export const CVES_ALLOWED_PARAMS = [ 'tags', 'sap_sids', 'sap_system', - 'remediation', - 'dashbar' + 'remediation' ]; export const SYSTEMS_EXPOSED_ALLOWED_PARAMS = [