diff --git a/src/components/IOC/IOCTable/IOCTable.spec.js b/src/components/IOC/IOCTable/IOCTable.spec.js index 0a735eed3d1f7dd57c50cc613ebb384bb7d2332e..57f9ceda29c96dd32949e7fe5d1b38729a6bdbe7 100644 --- a/src/components/IOC/IOCTable/IOCTable.spec.js +++ b/src/components/IOC/IOCTable/IOCTable.spec.js @@ -6,10 +6,10 @@ const textColumns = ["IOC name", "Description", "Host", "Network"]; const columns = ["Status"].concat(textColumns); const firstRowData = [ "Active with alert(s) 1 warnings1 errors !", - "CCCE:MOCK1", - "Some description", - "vacs-accv-vm-ioc", - "ChannelAccess-FEB" + "CCCE:MOCK4", + "---", + "ccce-test-ioc-02", + "CSLab-GeneralLab" ]; describe("IOCTable", () => { @@ -31,9 +31,9 @@ describe("IOCTable", () => { .should("have.length", textColumns.length - 1); }); - it("Displays correct content in first row", () => { + it("Displays correct content in third row", () => { cy.findAllByRole("row") - .eq(1) // first row is headers, so get next index + .eq(4) // first row is headers, so get next index .each(($el, index) => { if (index === 0) { const iconTitle = firstRowData[index]; diff --git a/src/components/common/Status/Status.js b/src/components/common/Status/Status.js index 0a9e8dbb12eb9451e2f7dacd47ad6a74dfaa5da4..66b4c65cf6b77ab4af219318b61571e3d594bb36 100644 --- a/src/components/common/Status/Status.js +++ b/src/components/common/Status/Status.js @@ -7,7 +7,7 @@ import { PlayCircleFilled, PauseCircleFilled } from "@mui/icons-material"; import { StatusPopoverContent } from "./StatusPopoverContent"; import { StatusBadge } from "./StatusBadge"; import { StatusIcon } from "./StatusIcon"; -import { STATUS, statusConfig, getStatus } from "./StatusData"; +import { statusesWithAlerts, statusConfig, getStatus } from "./StatusData"; const propsTypes = { state: object, @@ -15,16 +15,6 @@ const propsTypes = { hideAlerts: bool }; -const checkDisplayBadge = (status, hideAlerts) => { - return ( - !hideAlerts && - (status === STATUS.alert || - status === STATUS.warning || - status === STATUS.inactiveAlert || - status === STATUS.inactiveWarning) - ); -}; - export function Status({ state, alert, hideAlerts = false }) { const [status, setStatus] = useState(null); const theme = useTheme(); @@ -53,7 +43,7 @@ export function Status({ state, alert, hideAlerts = false }) { onMouseLeave={handlePopoverClose} style={{ color: theme.palette.status.icons }} > - {checkDisplayBadge(status, hideAlerts) ? ( + {!hideAlerts && statusesWithAlerts.includes(status) ? ( <StatusBadge status={status} theme={theme} diff --git a/src/components/common/Status/StatusBadge.js b/src/components/common/Status/StatusBadge.js index c00f97a06b8d33cee6ad6171d4bfa0fafb991420..ba4f700d43135383f5889140ebe91087e4472be8 100644 --- a/src/components/common/Status/StatusBadge.js +++ b/src/components/common/Status/StatusBadge.js @@ -20,13 +20,17 @@ const commonStyles = { export const StatusBadge = ({ status, theme, children }) => ( <Stack sx={{ position: "relative" }}> {children} - {status === STATUS.warning || status === STATUS.inactiveWarning ? ( + {status === STATUS.warning || + status === STATUS.inactiveWarning || + status === STATUS.disabledWarning ? ( <WarningAmberIcon sx={{ fill: theme.palette.warning.main, ...commonStyles }} /> ) : ( <> - {status === STATUS.alert || status === STATUS.inactiveAlert ? ( + {status === STATUS.alert || + status === STATUS.inactiveAlert || + status === STATUS.disabledAlert ? ( <ErrorOutlineIcon sx={{ fill: theme.palette.error.main, ...commonStyles }} /> diff --git a/src/components/common/Status/StatusData.js b/src/components/common/Status/StatusData.js index e922d850abc0b8aac3f0c3df8cec8ebae5922b16..6820391de4bfc2b65922ae0b49f8c4098ff3c6e1 100644 --- a/src/components/common/Status/StatusData.js +++ b/src/components/common/Status/StatusData.js @@ -8,6 +8,8 @@ import { export const STATUS = { active: "active", disabled: "disabled", + disabledAlert: "disabled alert", + disabledWarning: "disabled warning", alert: "alert", warning: "warning", inactive: "inactive", @@ -21,6 +23,15 @@ export const SEVERITY = { warning: "warning" }; +export const statusesWithAlerts = [ + STATUS.alert, + STATUS.warning, + STATUS.disabledAlert, + STATUS.disabledWarning, + STATUS.inactiveAlert, + STATUS.inactiveWarning +]; + export const statusConfig = { [STATUS.active]: { title: "Active", @@ -30,6 +41,14 @@ export const statusConfig = { title: "Disabled", icon: StopCircle }, + [STATUS.disabledAlert]: { + title: "Disabled with alert(s)", + icon: StopCircle + }, + [STATUS.disabledWarning]: { + title: "Disabled with warnings(s)", + icon: StopCircle + }, [STATUS.alert]: { title: "Active with alert(s)", icon: Brightness1 @@ -58,6 +77,7 @@ export const statusConfig = { export const getStatus = (state, alert) => { let { isActive } = state; + const isDeployed = !state.alertSeverity; const alertSeverity = alert?.alertSeverity?.toLowerCase(); if ( @@ -66,9 +86,17 @@ export const getStatus = (state, alert) => { ) { // Active status / running return STATUS.active; - } else if (isActive !== false && !isActive) { + } else if ( + !isActive && + isDeployed && + (!alertSeverity || alertSeverity === SEVERITY.info) + ) { // stopped/paused return STATUS.disabled; + } else if (!isActive && isDeployed && alertSeverity === SEVERITY.alert) { + return STATUS.disabledAlert; + } else if (!isActive && isDeployed && alertSeverity === SEVERITY.warning) { + return STATUS.disabledWarning; } else if ( isActive && alertSeverity !== undefined && diff --git a/src/components/common/Status/StatusIcon.js b/src/components/common/Status/StatusIcon.js index 1701927461eb2625f841ce54e085e664e0756a4f..055c9789f3b09511d4d8021e2dfaaa2d450cac84 100644 --- a/src/components/common/Status/StatusIcon.js +++ b/src/components/common/Status/StatusIcon.js @@ -1,19 +1,14 @@ import { object, string } from "prop-types"; -import { STATUS, statusConfig } from "./StatusData"; +import { statusConfig, statusesWithAlerts } from "./StatusData"; import { LabeledIcon } from "@ess-ics/ce-ui-common"; const propTypes = { alerts: object, status: string }; - +statusesWithAlerts.includes(status); const getLabel = (alerts, status) => { - if ( - status === STATUS.alert || - status === STATUS.warning || - status === STATUS.inactiveAlert || - status === STATUS.inactiveWarning - ) { + if (statusesWithAlerts.includes(status)) { const warnings = alerts.filter((alert) => alert.type === "WARNING"); const errors = alerts.filter((alert) => alert.type === "ERROR"); const hasWarnings = Boolean(warnings.length); diff --git a/src/mocks/fixtures/IOCAlerts.json b/src/mocks/fixtures/IOCAlerts.json index fe65d8dab1d9c525953ae81d9d65cec804552861..6d10ddc744a4771e372eaed9f6f8641f210b6b85 100644 --- a/src/mocks/fixtures/IOCAlerts.json +++ b/src/mocks/fixtures/IOCAlerts.json @@ -1,11 +1,32 @@ [ { "iocId": 14, + "alertSeverity": null, + "alerts": [] + }, + { + "iocId": 15, + "alertSeverity": null, + "alerts": [] + }, + { + "iocId": 18, + "alertSeverity": "INFO", + "alerts": [ + { + "type": "INFO", + "message": "IOC is not deployed", + "link": null + } + ] + }, + { + "iocId": 39, "alertSeverity": "ERROR", "alerts": [ { "type": "ERROR", - "message": "IOC's latest deployment failed, IOC may be in inconsistent state", + "message": "IOC is active with error message", "link": null }, { @@ -16,34 +37,40 @@ ] }, { - "iocId": 15, - "alertSeverity": null, - "alerts": [] + "iocId": 21, + "alertSeverity": "WARNING", + "alerts": [ + { + "type": "WARNING", + "message": "This is a warning message", + "link": null + } + ] }, { - "iocId": 18, - "alertSeverity": "INFO", + "iocId": 40, + "alertSeverity": "ERROR", "alerts": [ { - "type": "INFO", - "message": "IOC is not deployed", + "type": "ERROR", + "message": "IOC is inactive with error message", "link": null } ] }, { - "iocId": 39, + "iocId": 49, "alertSeverity": "WARNING", "alerts": [ { "type": "WARNING", - "message": "IOC is active with warning message", + "message": "IOC is inactive with warning message", "link": null } ] }, { - "iocId": 21, + "iocId": 41, "alertSeverity": "ERROR", "alerts": [ { @@ -53,42 +80,27 @@ }, { "type": "ERROR", - "message": "IOC's latest deployment failed, IOC may be in inconsistent state", - "link": null - }, - { - "type": "WARNING", - "message": "This is a warning message", + "message": "IOC is not deployed with error message", "link": null } ] }, { - "iocId": 49, + "iocId": 42, "alertSeverity": "WARNING", "alerts": [ + { + "type": "INFO", + "message": "IOC is not deployed", + "link": null + }, { "type": "WARNING", - "message": "This is a warning message", + "message": "IOC is not deployed with warning message", "link": null } ] }, - { - "iocId": 40, - "alertSeverity": null, - "alerts": [] - }, - { - "iocId": 41, - "alertSeverity": null, - "alerts": [] - }, - { - "iocId": 42, - "alertSeverity": null, - "alerts": [] - }, { "iocId": 43, "alertSeverity": null, diff --git a/src/mocks/fixtures/IOCStatus.json b/src/mocks/fixtures/IOCStatus.json index 960a113627b09dd971261121a5f3c927b0aa7d57..2763540916b7e1e3de33b5aa57b666dcc03673e3 100644 --- a/src/mocks/fixtures/IOCStatus.json +++ b/src/mocks/fixtures/IOCStatus.json @@ -5,10 +5,6 @@ }, { "iocId": 15, - "isActive": null - }, - { - "iocId": 18, "alertSeverity": "INFO", "alerts": [ { @@ -19,12 +15,28 @@ ], "isActive": false }, + { + "iocId": 18, + "isActive": null + }, { "iocId": 39, "isActive": true }, { "iocId": 21, + "isActive": true + }, + { + "iocId": 40, + "isActive": null + }, + { + "iocId": 49, + "isActive": null + }, + { + "iocId": 41, "alertSeverity": "INFO", "alerts": [ { @@ -36,7 +48,7 @@ "isActive": false }, { - "iocId": 49, + "iocId": 42, "alertSeverity": "INFO", "alerts": [ { @@ -47,18 +59,6 @@ ], "isActive": false }, - { - "iocId": 40, - "isActive": true - }, - { - "iocId": 41, - "isActive": true - }, - { - "iocId": 42, - "isActive": true - }, { "iocId": 43, "isActive": null diff --git a/src/mocks/fixtures/PagedIOCResponse.json b/src/mocks/fixtures/PagedIOCResponse.json index 5c4f6d0a818fee09752acb6f97927c28e9185f91..69816d77acbe084c02af1ae8c2bb0097551282f9 100644 --- a/src/mocks/fixtures/PagedIOCResponse.json +++ b/src/mocks/fixtures/PagedIOCResponse.json @@ -80,14 +80,6 @@ "sourceVersionShort": null } }, - { - "id": 49, - "namingName": "CCCE:MOCK6", - "createdBy": "mock user 6", - "gitProjectId": 12972, - "deployedWithOldPlaybook": true, - "activeDeployment": null - }, { "id": 40, "namingName": "CCCE:MOCK-TEST", @@ -96,6 +88,14 @@ "deployedWithOldPlaybook": true, "activeDeployment": null }, + { + "id": 49, + "namingName": "CCCE:MOCK6", + "createdBy": "mock user 6", + "gitProjectId": 12972, + "deployedWithOldPlaybook": true, + "activeDeployment": null + }, { "id": 41, "namingName": "CCCE:MOCK7", diff --git a/src/stories/views/IOC/IocDetailsView.stories.js b/src/stories/views/IOC/IocDetailsView.stories.js index 6a8271077bd28e2db3242a949de3d9f20fbc9bfe..b206af67f0159cb126ef59d86d34c5bd7a4bdce2 100644 --- a/src/stories/views/IOC/IocDetailsView.stories.js +++ b/src/stories/views/IOC/IocDetailsView.stories.js @@ -29,11 +29,11 @@ NotDeployed.args = { export const Deployed = (args) => <Template {...args} />; Deployed.args = { ...config, - id: 39 + id: 14 }; export const DeployedErrors = (args) => <Template {...args} />; DeployedErrors.args = { ...config, - id: 14 + id: 39 };