From 491307416b4fb27bb1bb41fd005217950ee86d6e Mon Sep 17 00:00:00 2001 From: Johanna Szepanski <johanna.szepanski@softhouse.se> Date: Fri, 16 Aug 2024 09:12:36 +0200 Subject: [PATCH] updated status logic and story to accommodate BE fix for stopped IOCs --- src/components/common/Status/StatusData.js | 21 ++------ src/mocks/fixtures/IOCAlerts.json | 56 ++++++++++------------ src/mocks/fixtures/IOCStatus.json | 30 ++++++++++-- 3 files changed, 57 insertions(+), 50 deletions(-) diff --git a/src/components/common/Status/StatusData.js b/src/components/common/Status/StatusData.js index 0219be02..e922d850 100644 --- a/src/components/common/Status/StatusData.js +++ b/src/components/common/Status/StatusData.js @@ -66,10 +66,7 @@ export const getStatus = (state, alert) => { ) { // Active status / running return STATUS.active; - } else if ( - isActive === false && - (alertSeverity === undefined || alertSeverity === SEVERITY.info) - ) { + } else if (isActive !== false && !isActive) { // stopped/paused return STATUS.disabled; } else if ( @@ -87,21 +84,13 @@ export const getStatus = (state, alert) => { // warning return STATUS.warning; } else if ( - (!isActive || isActive === null) && - (alertSeverity === undefined || alertSeverity === SEVERITY.info) + isActive === false && + (!alertSeverity || alertSeverity === SEVERITY.info) ) { - // Inactive status return STATUS.inactive; - } else if ( - (!isActive || isActive === null) && - alertSeverity === SEVERITY.alert - ) { - // inactive with warning/error + } else if (isActive === false && alertSeverity === SEVERITY.alert) { return STATUS.inactiveAlert; - } else if ( - (!isActive || isActive === null) && - alertSeverity === SEVERITY.warning - ) { + } else if (isActive === false && alertSeverity === SEVERITY.warning) { return STATUS.inactiveWarning; } else { // unknown fallback state diff --git a/src/mocks/fixtures/IOCAlerts.json b/src/mocks/fixtures/IOCAlerts.json index c59b7949..fe65d8da 100644 --- a/src/mocks/fixtures/IOCAlerts.json +++ b/src/mocks/fixtures/IOCAlerts.json @@ -17,19 +17,8 @@ }, { "iocId": 15, - "alertSeverity": "WARNING", - "alerts": [ - { - "type": "WARNING", - "message": "This is warning 1", - "link": null - }, - { - "type": "WARNING", - "message": "This is warning 2", - "link": null - } - ] + "alertSeverity": null, + "alerts": [] }, { "iocId": 18, @@ -55,16 +44,32 @@ }, { "iocId": 21, - "alertSeverity": null, - "alerts": [] + "alertSeverity": "ERROR", + "alerts": [ + { + "type": "INFO", + "message": "IOC is not deployed", + "link": null + }, + { + "type": "ERROR", + "message": "IOC's latest deployment failed, IOC may be in inconsistent state", + "link": null + }, + { + "type": "WARNING", + "message": "This is a warning message", + "link": null + } + ] }, { "iocId": 49, - "alertSeverity": "INFO", + "alertSeverity": "WARNING", "alerts": [ { - "type": "INFO", - "message": "IOC is not deployed", + "type": "WARNING", + "message": "This is a warning message", "link": null } ] @@ -86,18 +91,7 @@ }, { "iocId": 43, - "alertSeverity": "ERROR", - "alerts": [ - { - "type": "ERROR", - "message": "IOC's latest deployment failed, IOC may be in inconsistent state", - "link": null - }, - { - "type": "WARNING", - "message": "This is a warning message", - "link": null - } - ] + "alertSeverity": null, + "alerts": [] } ] diff --git a/src/mocks/fixtures/IOCStatus.json b/src/mocks/fixtures/IOCStatus.json index c3da9093..960a1136 100644 --- a/src/mocks/fixtures/IOCStatus.json +++ b/src/mocks/fixtures/IOCStatus.json @@ -9,7 +9,15 @@ }, { "iocId": 18, - "isActive": null + "alertSeverity": "INFO", + "alerts": [ + { + "type": "INFO", + "message": "IOC is not deployed", + "link": null + } + ], + "isActive": false }, { "iocId": 39, @@ -17,11 +25,27 @@ }, { "iocId": 21, - "isActive": null + "alertSeverity": "INFO", + "alerts": [ + { + "type": "INFO", + "message": "IOC is not deployed", + "link": null + } + ], + "isActive": false }, { "iocId": 49, - "isActive": null + "alertSeverity": "INFO", + "alerts": [ + { + "type": "INFO", + "message": "IOC is not deployed", + "link": null + } + ], + "isActive": false }, { "iocId": 40, -- GitLab