diff --git a/package-lock.json b/package-lock.json index 7fe60783205cb28330aa0efa4e18871f67fba263..d677d8b6912a4f8201d4899781f63313c2b7ba62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "@ahooksjs/use-url-state": "^3.5.0", "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", - "@ess-ics/ce-ui-common": "^6.1.4", + "@ess-ics/ce-ui-common": "^6.2.0", "@fontsource/roboto": "^4.1.0", "@mui/icons-material": "^5.14.1", "@mui/material": "^5.14.1", @@ -3072,9 +3072,9 @@ } }, "node_modules/@ess-ics/ce-ui-common": { - "version": "6.1.4", - "resolved": "https://artifactory.esss.lu.se/artifactory/api/npm/ics-npm/@ess-ics/ce-ui-common/-/ce-ui-common-6.1.4.tgz", - "integrity": "sha1-tuOpU2+nVV9bvH/nh8E1Ddme8z0=", + "version": "6.2.0", + "resolved": "https://artifactory.esss.lu.se/artifactory/api/npm/ics-npm/@ess-ics/ce-ui-common/-/ce-ui-common-6.2.0.tgz", + "integrity": "sha1-Z5Hib745MUnOAIb3lKea1WpEOtU=", "dependencies": { "@fontsource/titillium-web": "^4.5.9", "@mui/x-data-grid-pro": "^6.5.0", @@ -34273,9 +34273,9 @@ "dev": true }, "@ess-ics/ce-ui-common": { - "version": "6.1.4", - "resolved": "https://artifactory.esss.lu.se/artifactory/api/npm/ics-npm/@ess-ics/ce-ui-common/-/ce-ui-common-6.1.4.tgz", - "integrity": "sha1-tuOpU2+nVV9bvH/nh8E1Ddme8z0=", + "version": "6.2.0", + "resolved": "https://artifactory.esss.lu.se/artifactory/api/npm/ics-npm/@ess-ics/ce-ui-common/-/ce-ui-common-6.2.0.tgz", + "integrity": "sha1-Z5Hib745MUnOAIb3lKea1WpEOtU=", "requires": { "@fontsource/titillium-web": "^4.5.9", "@mui/x-data-grid-pro": "^6.5.0", diff --git a/package.json b/package.json index d7452e1c32726cd2097846896eba462d4fd6fc9c..21d5b1eee775de8fb46bfad560701970f39d7f33 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "@ahooksjs/use-url-state": "^3.5.0", "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", - "@ess-ics/ce-ui-common": "^6.1.4", + "@ess-ics/ce-ui-common": "^6.2.0", "@fontsource/roboto": "^4.1.0", "@mui/icons-material": "^5.14.1", "@mui/material": "^5.14.1", diff --git a/src/components/maintenance/MaintenanceMode.js b/src/components/maintenance/MaintenanceMode.js new file mode 100644 index 0000000000000000000000000000000000000000..2416decafe3244b857406503afe131276b092a07 --- /dev/null +++ b/src/components/maintenance/MaintenanceMode.js @@ -0,0 +1,28 @@ +import { useContext, useEffect } from "react"; +import { useAPIMethod, MaintenanceModeBanner } from "@ess-ics/ce-ui-common"; +import { apiContext } from "../../api/DeployApi"; + +export function MaintenanceMode() { + const client = useContext(apiContext); + const { + value: mode, + wrapper: getMode, + abort: abortGetMode + } = useAPIMethod({ + fcn: client.apis.Maintenance.getCurrentMode, + call: false + }); + + useEffect(() => { + getMode(); + return () => { + abortGetMode(); + }; + }, [abortGetMode, getMode]); + + if (mode) { + return <MaintenanceModeBanner {...mode} />; + } + + return; +} diff --git a/src/components/maintenance/index.js b/src/components/maintenance/index.js new file mode 100644 index 0000000000000000000000000000000000000000..225a573d221ce0ab5579e8a07b92a6e27ecc2070 --- /dev/null +++ b/src/components/maintenance/index.js @@ -0,0 +1,4 @@ +import { MaintenanceMode } from "./MaintenanceMode"; + +export { MaintenanceMode }; +export default MaintenanceMode; diff --git a/src/components/navigation/NavigationMenu/NavigationMenu.js b/src/components/navigation/NavigationMenu/NavigationMenu.js index ac5b1f614937765a45f4a11babd7a9d31d91f384..f33a9e40940c67686abc80f415ed33384e3905ab 100644 --- a/src/components/navigation/NavigationMenu/NavigationMenu.js +++ b/src/components/navigation/NavigationMenu/NavigationMenu.js @@ -26,6 +26,7 @@ import { LoginControls } from "./LoginControls"; import { Link } from "react-router-dom"; import { CCCEControlSymbol } from "../../../icons/CCCEControlSymbol"; import { CreateIOCButton } from "./CreateIOCButton"; +import { MaintenanceMode } from "../../maintenance/MaintenanceMode"; function MenuListItem({ url, icon, text, tooltip }) { const currentUrl = `${window.location}`; @@ -110,6 +111,7 @@ const NavigationMenu = ({ children }) => { defaultTitle: applicationTitle(), defaultActionButton: <LoginControls />, defaultOpen: false, + defaultBanner: <MaintenanceMode />, widthOpen: "170px", // default size 240px widthClosed: "57px", defaultIconMenuButton: <CreateIOCButton />, diff --git a/src/mocks/fixtures/MaintenanceMode.json b/src/mocks/fixtures/MaintenanceMode.json new file mode 100644 index 0000000000000000000000000000000000000000..562661a1bf113dfb428df43e80d335085351993f --- /dev/null +++ b/src/mocks/fixtures/MaintenanceMode.json @@ -0,0 +1,6 @@ +{ + "id": 3925, + "message": "Maintenance Message", + "started": "2022-02-11T12:29:24.332+00:00", + "finished": "2022-02-11T12:29:29.595+00:00" +} diff --git a/src/mocks/mockAPI.js b/src/mocks/mockAPI.js index 7fe7e6a40765907240bb3a59897e137725f06f89..95ed8fa73e6f593a9b85f1afe107e1316476b3a6 100644 --- a/src/mocks/mockAPI.js +++ b/src/mocks/mockAPI.js @@ -275,6 +275,11 @@ function fetchIOCByName(req) { return { body }; } +function getCurrentMode(req) { + const body = require("./fixtures/MaintenanceMode.json"); + return { body }; +} + // just to organize const mockAPI = { spec: spec, @@ -293,6 +298,9 @@ const mockAPI = { fetchIocStatus, fetchProcServLogLines }, + maintenance: { + getCurrentMode + }, operations: { listOperations, fetchOperation, @@ -405,6 +413,11 @@ export const apiHandlers = [ mockAPI.git_helper.listTagsAndCommitIds ), + makeHandler( + "GET", + qRegExp(".*/maintenance_mode/current"), + mockAPI.maintenance.getCurrentMode + ), // operations makeHandler( "GET",