Skip to content

Commit

Permalink
refactor(actions): make SET_SAVE_AS_MODE an FSA
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Sep 24, 2017
1 parent 65fd47d commit 0207dc2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
@@ -1,5 +1,6 @@
import { getSaveButtonStatus, hasTranslationChanged }
from '../utils/phrase-util'
import { createAction } from 'redux-actions'
import {
copyFromAlignedSource,
undoEdit,
Expand Down Expand Up @@ -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'.
Expand All @@ -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) => {
Expand Down
Expand Up @@ -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:
Expand Down
Expand Up @@ -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)
Expand Down

0 comments on commit 0207dc2

Please sign in to comment.