diff --git a/src/api/SwaggerApi.js b/src/api/SwaggerApi.js index 4b37f9196ee37ea0d65ecd86af10d81710fe0f4a..dc90c28b85f4813178077574e91c6814db9145ec 100644 --- a/src/api/SwaggerApi.js +++ b/src/api/SwaggerApi.js @@ -344,23 +344,27 @@ export function unpackDeployment(deployment) { return d; } -export function unpackOngoingCommand(command) { - if (command) { - return { ...command }; - } - return null; +export function unpackOngoingOperations(input) { + const { operations: operationsList, ...rest } = input; + const output = { ...rest, operationsList }; + return output.totalCount > 0 ? output.operationsList[0] : null; } export function useOngoingCommand(iocId) { const api = useContext(apiContext); const method = useCallAndUnpack( - api.apis.Deployments.ongoingCommandByIoc, - unpackOngoingCommand + api.apis.Deployments.listOperations, + unpackOngoingOperations ); - const boundMethod = useCallback(method.bind(null, { ioc_id: iocId }), [ - iocId - ]); - return useAsync({ fcn: boundMethod, call: false }); + const boundMethod = useCallback( + method.bind(null, { ioc_id: iocId, type: "COMMAND", status: "ONGOING" }), + [iocId] + ); + return useAsync({ + fcn: boundMethod, + call: false, + init: emptyOperationsListResponse + }); } const emptyOperationsListResponse = { diff --git a/src/components/common/notification/Storage.js b/src/components/common/notification/Storage.js index 8cb4884b6746343cd38506cef7b63ded2524f9d9..6395a95af0b42f6506db45ef60909380e4626448 100644 --- a/src/components/common/notification/Storage.js +++ b/src/components/common/notification/Storage.js @@ -8,15 +8,17 @@ export const TYPE_COMMAND = "command"; function watchId(watchedId, storageKey) { let watchedIds = JSON.parse(localStorage.getItem(storageKey)); - if (watchedIds) { - if (!watchedIds.includes(watchedId)) { - localStorage.setItem( - storageKey, - JSON.stringify([watchedId].concat(watchedIds)) - ); + if (watchedId) { + if (watchedIds) { + if (!watchedIds.includes(watchedId)) { + localStorage.setItem( + storageKey, + JSON.stringify([watchedId].concat(watchedIds)) + ); + } + } else { + localStorage.setItem(storageKey, JSON.stringify([watchedId])); } - } else { - localStorage.setItem(storageKey, JSON.stringify([watchedId])); } } diff --git a/src/views/IOC/IOCDetailsView.js b/src/views/IOC/IOCDetailsView.js index 7561f4fdd06881c2df3a7bb62c5fe487196d76d0..eae883e030caec2a32db0ce76ab9dbfdf1bda11b 100644 --- a/src/views/IOC/IOCDetailsView.js +++ b/src/views/IOC/IOCDetailsView.js @@ -37,9 +37,9 @@ export function IOCDetailsView({ ioc, getIOC, loading }) { useOperationsSearch(); const [ ongoingCommand, - getOngoingCommand /* reset*/, + getOngoingCommand, , - ongoingCommandLoading + /* reset*/ ongoingCommandLoading ] = useOngoingCommand(ioc.id); const jobLazyParams = useCallback(() => {