From 1fff14f0a5e25adaa851537c71c7bd8381c1bbb1 Mon Sep 17 00:00:00 2001 From: Koren Lev Date: Mon, 2 Oct 2017 11:37:03 +0300 Subject: ui move to docker Change-Id: Iff31ebb3fff782e848704801b7800fdf480264a1 Signed-off-by: Koren Lev (cherry picked from commit a9691f5fe78af32c474754f841a71a68e2d2a484) --- ui/imports/ui/reducers/navigation.js | 91 ------------------------------------ 1 file changed, 91 deletions(-) delete mode 100644 ui/imports/ui/reducers/navigation.js (limited to 'ui/imports/ui/reducers/navigation.js') diff --git a/ui/imports/ui/reducers/navigation.js b/ui/imports/ui/reducers/navigation.js deleted file mode 100644 index d7ab503..0000000 --- a/ui/imports/ui/reducers/navigation.js +++ /dev/null @@ -1,91 +0,0 @@ -import * as R from 'ramda'; - -import * as actions from '/imports/ui/actions/navigation'; - -const defaultState = { current: [], lastActionable: [] }; - -function reducer(state = defaultState, action) { - let lastActionable = null; - - switch (action.type) { - case actions.SET_CURRENT_NODE: - lastActionable = isActionable(action.payload.nodeChain) ? action.payload.nodeChain : - state.lastActionable; - - return R.merge(state, { - current: action.payload.nodeChain, - lastActionable: lastActionable - }); - - case actions.SET_CURRENT_NODE_FROM_TREE_CONTROL: - lastActionable = isActionable(action.payload.nodeChain) ? action.payload.nodeChain : - state.lastActionable; - - if (contains(action.payload.nodeChain, state.current)) { - let equalLastIndex = findEqualLastIndex(action.payload.nodeChain, state.current); - return R.merge(state, { - current: R.slice(0, equalLastIndex, action.payload.nodeChain), - lastActionable: lastActionable - }); - } else { - return R.merge(state, { - current: action.payload.nodeChain, - lastActionable: lastActionable - }); - } - - default: - return state; - } -} - -function contains(subArray, array) { - let equalLastIndex = findEqualLastIndex(subArray, array); - - if (subArray.length <= array.length && - equalLastIndex >= 0 && - subArray.length === equalLastIndex + 1) { - - return true; - } - - return false; -} - -function findEqualLastIndex (arrayA, arrayB) { - let indexResult = -1; - - for (let i = 0; (i < arrayA.length) && (i < arrayB.length); i++) { - if (equalsNodes(arrayA[i], arrayB[i])) { - indexResult = i; - } else { - break; - } - } - - return indexResult; -} - -function equalsNodes(nodeA, nodeB) { - if (nodeA.fullIdPath !== nodeB.fullIdPath) { return false; } - if (nodeA.fullNamePath !== nodeB.fullNamePath) { return false; } - - return true; -} - -function isActionable(nodeChain) { - let last = R.last(nodeChain); - - if (R.isNil(last)) { return false; } - if (R.isNil(last.item)) { return false; } - - if (! R.isNil(last.item.clique)) { return true; } - - if (last.item.id === 'aggregate-WebEx-RTP-SSD-Aggregate-node-24') { - return true; - } - - return false; -} - -export const navigation = reducer; -- cgit 1.2.3-korg