aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/ducks/ui/flow.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/js/ducks/ui/flow.js')
-rw-r--r--web/src/js/ducks/ui/flow.js33
1 files changed, 18 insertions, 15 deletions
diff --git a/web/src/js/ducks/ui/flow.js b/web/src/js/ducks/ui/flow.js
index 100bc771..c9435676 100644
--- a/web/src/js/ducks/ui/flow.js
+++ b/web/src/js/ducks/ui/flow.js
@@ -8,7 +8,6 @@ export const SET_CONTENT_VIEW = 'UI_FLOWVIEW_SET_CONTENT_VIEW',
SET_TAB = "UI_FLOWVIEW_SET_TAB",
START_EDIT = 'UI_FLOWVIEW_START_EDIT',
UPDATE_EDIT = 'UI_FLOWVIEW_UPDATE_EDIT',
- STOP_EDIT = 'UI_FLOWVIEW_STOP_EDIT',
UPLOAD_CONTENT = 'UI_FLOWVIEW_UPLOAD_CONTENT'
@@ -34,12 +33,6 @@ export default function reducer(state = defaultState, action) {
modifiedFlow: _.merge({}, state.modifiedFlow, action.update)
}
- case STOP_EDIT:
- return {
- ...state,
- modifiedFlow: false
- }
-
case flowsActions.SELECT:
return {
...state,
@@ -47,6 +40,21 @@ export default function reducer(state = defaultState, action) {
displayLarge: false,
}
+ case flowsActions.UPDATE:
+ // There is no explicit "stop edit" event.
+ // We stop editing when we receive an update for
+ // the currently edited flow from the server
+ if (action.item.id === state.modifiedFlow.id) {
+ return {
+ ...state,
+ modifiedFlow: false,
+ displayLarge: false,
+ }
+ } else {
+ return state
+ }
+
+
case SET_TAB:
return {
...state,
@@ -90,12 +98,7 @@ export function updateEdit(update) {
return { type: UPDATE_EDIT, update }
}
-export function stopEdit(flow, modified_flow) {
- let diff = getDiff(flow, modified_flow)
- return (dispatch) => {
- dispatch(flowsActions.update(flow, diff)).then(() => {
- dispatch(flowsActions.updateFlow(modified_flow))
- dispatch({ type: STOP_EDIT })
- })
- }
+export function stopEdit(flow, modifiedFlow) {
+ let diff = getDiff(flow, modifiedFlow)
+ return flowsActions.update(flow, diff)
}