diff options
author | 2019-02-28 15:23:42 +0100 | |
---|---|---|
committer | 2019-02-28 15:24:28 +0100 | |
commit | 7446f23b3abc30d7c53f2eaa951742371c071171 (patch) | |
tree | b76a8d2e64c7aa850c09f8e69f01e7a262ab5cd5 /sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx | |
parent | 49b155ec687cdf58fb51fe8245a2f5f4582b68f0 (diff) |
UX extensions
UX Maintenance client and further changes
Change-Id: I7643661d17db5fc3d3f94b58cb42ed0be558c64f
Issue-ID: SDNC-583
Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx')
-rw-r--r-- | sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx b/sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx index 70b4d8f2a..db86b99c2 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx @@ -1,7 +1,7 @@ import { IActionHandler } from '../../../../framework/src/flux/action'; import { - AddMountedNetworkElement, + AddOrUpdateMountedNetworkElement, AllMountedNetworkElementsLoadedAction, LoadAllMountedNetworkElementsAction, RemoveMountedNetworkElement, @@ -28,7 +28,7 @@ export const mountedNetworkElementsActionHandler: IActionHandler<IMountedNetwork ...state, busy: true }; - + } else if (action instanceof AllMountedNetworkElementsLoadedAction) { if (!action.error && action.mountedNetworkElements) { state = { @@ -42,11 +42,24 @@ export const mountedNetworkElementsActionHandler: IActionHandler<IMountedNetwork busy: false }; } - } else if (action instanceof AddMountedNetworkElement) { - action.mountedNetworkElement && (state = { - ...state, - elements: [...state.elements, action.mountedNetworkElement], - }); + } else if (action instanceof AddOrUpdateMountedNetworkElement) { + if (!action.mountedNetworkElement) return state; // should handle error here + const index = state.elements.findIndex(el => el.mountId === (action.mountedNetworkElement && action.mountedNetworkElement.mountId)); + if (index > -1) { + state = { + ...state, + elements: [ + ...state.elements.slice(0, index), + action.mountedNetworkElement, + ...state.elements.slice(index + 1) + ] + } + } else { + state = { + ...state, + elements: [...state.elements, action.mountedNetworkElement], + } + }; } else if (action instanceof RemoveMountedNetworkElement) { state = { ...state, |