From 0207dc2d86037562e4ca4793534884e7cd4535e8 Mon Sep 17 00:00:00 2001 From: David Mason Date: Mon, 25 Sep 2017 08:59:24 +1000 Subject: [PATCH] refactor(actions): make SET_SAVE_AS_MODE an FSA --- .../app/editor/actions/key-shortcuts-actions.js | 15 +++++++-------- .../app/editor/reducers/phrase-reducer/index.js | 2 +- .../phrase-reducer/phrase-reducer.test.js | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/server/zanata-frontend/src/frontend/app/editor/actions/key-shortcuts-actions.js b/server/zanata-frontend/src/frontend/app/editor/actions/key-shortcuts-actions.js index b39e3583c27..a1896dfe543 100644 --- a/server/zanata-frontend/src/frontend/app/editor/actions/key-shortcuts-actions.js +++ b/server/zanata-frontend/src/frontend/app/editor/actions/key-shortcuts-actions.js @@ -1,5 +1,6 @@ import { getSaveButtonStatus, hasTranslationChanged } from '../utils/phrase-util' +import { createAction } from 'redux-actions' import { copyFromAlignedSource, undoEdit, @@ -170,6 +171,12 @@ function saveAsCurrentActionCreator (event) { } } +/** +* Indicate that save-as mode is active or inactive. +*/ +export const SET_SAVE_AS_MODE = 'SET_SAVE_AS_MODE' +export const setSaveAsMode = createAction(SET_SAVE_AS_MODE) + /** * This is to mimic sequence shortcut. * e.g. press ctrl-shift-s then press 'n' to save as 'needs work'. @@ -184,14 +191,6 @@ function saveAsModeActionCreator (event) { } } -export const SET_SAVE_AS_MODE = Symbol('SET_SAVE_AS_MODE') -/** - * Indicate that save-as mode is active or inactive. - */ -export function setSaveAsMode (active) { - return { type: SET_SAVE_AS_MODE, active } -} - function saveAs (status) { return (event) => { return (dispatch, getState) => { diff --git a/server/zanata-frontend/src/frontend/app/editor/reducers/phrase-reducer/index.js b/server/zanata-frontend/src/frontend/app/editor/reducers/phrase-reducer/index.js index 8d36826428b..d213a984aba 100644 --- a/server/zanata-frontend/src/frontend/app/editor/reducers/phrase-reducer/index.js +++ b/server/zanata-frontend/src/frontend/app/editor/reducers/phrase-reducer/index.js @@ -228,7 +228,7 @@ export const phraseReducer = (state = defaultState, action) => { case SET_SAVE_AS_MODE: return update({ - saveAsMode: {$set: action.active} + saveAsMode: {$set: action.payload} }) case TRANSLATION_TEXT_INPUT_CHANGED: diff --git a/server/zanata-frontend/src/frontend/app/editor/reducers/phrase-reducer/phrase-reducer.test.js b/server/zanata-frontend/src/frontend/app/editor/reducers/phrase-reducer/phrase-reducer.test.js index 487b3034a02..c5e84603baa 100644 --- a/server/zanata-frontend/src/frontend/app/editor/reducers/phrase-reducer/phrase-reducer.test.js +++ b/server/zanata-frontend/src/frontend/app/editor/reducers/phrase-reducer/phrase-reducer.test.js @@ -755,11 +755,11 @@ describe('phrase-reducer test', () => { it('can set save as mode on and off', () => { const saveAs = phraseReducer(undefined, { type: SET_SAVE_AS_MODE, - active: true + payload: true }) const notSaveAs = phraseReducer(saveAs, { type: SET_SAVE_AS_MODE, - active: false + payload: false }) expect(saveAs.saveAsMode).toEqual(true) expect(notSaveAs.saveAsMode).toEqual(false)