2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 import { actionTypes, FLOWS_EDITOR_FORM } from './FlowsConstants.js';
18 export default (state = {}, action) => {
19 switch (action.type) {
20 case actionTypes.FLOW_LIST_LOADED:
23 flowList: action.results,
24 flowParticipants: action.participants,
25 serviceID: action.serviceID,
26 diagramType: action.diagramType,
27 readonly: action.readonly
29 case actionTypes.ADD_OR_UPDATE_FLOW:
30 case actionTypes.ARTIFACT_LOADED:
31 let flowList = state.flowList || [];
32 let index = flowList.findIndex(
33 flow => flow.uniqueId === action.flow.uniqueId
36 index = flowList.length;
38 let flowToBeUpdated = flowList[index];
40 ...flowList.slice(0, index),
41 { ...flowToBeUpdated, ...action.flow },
42 ...flowList.slice(index + 1)
47 serviceID: action.flow.serviceID,
48 diagramType: action.flow.artifactType || state.diagramType
50 case actionTypes.DELETE_FLOW:
53 flowList: state.flowList.filter(
54 flow => flow.uniqueId !== action.flow.uniqueId
57 case actionTypes.OPEN_FLOW_DETAILS_EDITOR:
60 formName: FLOWS_EDITOR_FORM,
66 validations: [{ type: 'required', data: true }]
71 validations: [{ type: 'required', data: true }]
77 case actionTypes.CLOSE_FLOW_DETAILS_EDITOR:
82 case actionTypes.OPEN_FLOW_DIAGRAM_EDITOR:
86 shouldShowWorkflowsEditor: false
88 case actionTypes.CLOSE_FLOW_DIAGRAM_EDITOR:
92 shouldShowWorkflowsEditor: true
94 case actionTypes.RESET: