diff options
Diffstat (limited to 'web/src/js/ducks')
-rw-r--r-- | web/src/js/ducks/flows.js | 12 | ||||
-rw-r--r-- | web/src/js/ducks/ui/flow.js | 24 |
2 files changed, 21 insertions, 15 deletions
diff --git a/web/src/js/ducks/flows.js b/web/src/js/ducks/flows.js index f96653a9..404db0d1 100644 --- a/web/src/js/ducks/flows.js +++ b/web/src/js/ducks/flows.js @@ -1,5 +1,6 @@ import { fetchApi } from '../utils' import reduceList, * as listActions from './utils/list' +import { selectRelative } from './flowView' import * as msgQueueActions from './msgQueue' import * as websocketActions from './websocket' @@ -210,5 +211,14 @@ export function updateFlow(item) { * @private */ export function removeFlow(id) { - return { type: REMOVE, id } + return (dispatch, getState) => { + let currentIndex = getState().flowView.indexOf[getState().flows.selected[0]] + let maxIndex = getState().flowView.data.length - 1 + let deleteLastEntry = maxIndex == 0 + if (deleteLastEntry) + dispatch(select()) + else + dispatch(selectRelative(currentIndex == maxIndex ? -1 : 1) ) + dispatch({ type: REMOVE, id }) + } } diff --git a/web/src/js/ducks/ui/flow.js b/web/src/js/ducks/ui/flow.js index 22a8c22d..4a6d64cd 100644 --- a/web/src/js/ducks/ui/flow.js +++ b/web/src/js/ducks/ui/flow.js @@ -16,7 +16,7 @@ export const SET_CONTENT_VIEW = 'UI_FLOWVIEW_SET_CONTENT_VIEW', const defaultState = { displayLarge: false, - contentViewDescription: '', + viewDescription: '', showFullContent: false, modifiedFlow: false, contentView: 'Auto', @@ -27,6 +27,10 @@ const defaultState = { export default function reducer(state = defaultState, action) { let wasInEditMode = !!(state.modifiedFlow) + + let content = action.content || state.content + let isFullContentShown = content && content.length <= state.maxContentLines + switch (action.type) { case START_EDIT: @@ -49,8 +53,7 @@ export default function reducer(state = defaultState, action) { modifiedFlow: false, displayLarge: false, contentView: (wasInEditMode ? 'Auto' : state.contentView), - viewDescription: '', - showFullContent: false, + showFullContent: isFullContentShown, } case flowsActions.UPDATE: @@ -63,7 +66,6 @@ export default function reducer(state = defaultState, action) { modifiedFlow: false, displayLarge: false, contentView: (wasInEditMode ? 'Auto' : state.contentView), - viewDescription: '', showFullContent: false } } else { @@ -79,7 +81,7 @@ export default function reducer(state = defaultState, action) { case SET_SHOW_FULL_CONTENT: return { ...state, - showFullContent: action.show + showFullContent: true } case SET_TAB: @@ -98,7 +100,6 @@ export default function reducer(state = defaultState, action) { } case SET_CONTENT: - let isFullContentShown = action.content.length < state.maxContentLines return { ...state, content: action.content, @@ -139,12 +140,8 @@ export function setContentViewDescription(description) { return { type: SET_CONTENT_VIEW_DESCRIPTION, description } } -export function setShowFullContent(show) { - return { type: SET_SHOW_FULL_CONTENT, show } -} - -export function updateEdit(update) { - return { type: UPDATE_EDIT, update } +export function setShowFullContent() { + return { type: SET_SHOW_FULL_CONTENT } } export function setContent(content){ @@ -152,6 +149,5 @@ export function setContent(content){ } export function stopEdit(flow, modifiedFlow) { - let diff = getDiff(flow, modifiedFlow) - return flowsActions.update(flow, diff) + return flowsActions.update(flow, getDiff(flow, modifiedFlow)) } |