2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 import {actionTypes} from './FlowsConstants.js';
23 export default (state = {}, action) => {
24 switch (action.type) {
25 case actionTypes.FLOW_LIST_LOADED:
28 flowList: action.results,
29 flowParticipants: action.participants,
30 serviceID: action.serviceID,
31 diagramType: action.diagramType
33 case actionTypes.ADD_OR_UPDATE_FLOW:
34 case actionTypes.ARTIFACT_LOADED:
35 let flowList = state.flowList || [];
36 let index = flowList.findIndex(flow => flow.uniqueId === action.flow.uniqueId);
38 index = flowList.length;
40 let flowToBeUpdated = flowList[index];
42 ...flowList.slice(0, index),
43 {...flowToBeUpdated, ...action.flow},
44 ...flowList.slice(index + 1)
49 serviceID: action.flow.serviceID,
50 diagramType: action.flow.artifactType || state.diagramType
52 case actionTypes.CURRENT_FLOW_DATA_CHANGED:
60 case actionTypes.DELETE_FLOW:
63 flowList: state.flowList.filter(flow => flow.uniqueId !== action.flow.uniqueId)
65 case actionTypes.OPEN_FLOW_DETAILS_EDITOR:
68 currentFlow: action.flow,
70 isModalInEditMode: Boolean(action.flow && action.flow.uniqueId)
73 case actionTypes.CLOSE_FLOW_DETAILS_EDITOR:
76 currentFlow: undefined,
77 isDisplayModal: false,
78 isModalInEditMode: false
80 case actionTypes.OPEN_FLOW_DIAGRAM_EDITOR:
83 currentFlow: action.flow,
84 shouldShowWorkflowsEditor: false
86 case actionTypes.CLOSE_FLOW_DIAGRAM_EDITOR:
89 currentFlow: undefined,
90 shouldShowWorkflowsEditor: true
92 case actionTypes.RESET: