From bbe6556bfc1b6c9cc6e2f24abf3228d101ad0398 Mon Sep 17 00:00:00 2001 From: Clemens Date: Fri, 19 Aug 2016 14:12:32 +0200 Subject: added tests --- web/src/js/ducks/ui/flow.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'web/src/js/ducks') diff --git a/web/src/js/ducks/ui/flow.js b/web/src/js/ducks/ui/flow.js index 22a8c22d..0360321c 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){ -- cgit v1.2.3