From dd5f00573553e9065ba8d2f877d331b2bef3c12e Mon Sep 17 00:00:00 2001 From: David Mason Date: Mon, 25 Sep 2017 12:42:16 +1000 Subject: [PATCH] refactor(actions): make PHRASE_SUGGESTION_FINISHED_COPYING an FSA --- .../app/editor/actions/suggestions-action-types.js | 2 +- .../src/frontend/app/editor/actions/suggestions-actions.js | 7 +++---- .../frontend/app/editor/reducers/suggestions-reducer.js | 4 ++-- .../app/editor/reducers/suggestions-reducer.test.js | 6 ++++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/server/zanata-frontend/src/frontend/app/editor/actions/suggestions-action-types.js b/server/zanata-frontend/src/frontend/app/editor/actions/suggestions-action-types.js index 20775ccee0b..9eb705f61e7 100644 --- a/server/zanata-frontend/src/frontend/app/editor/actions/suggestions-action-types.js +++ b/server/zanata-frontend/src/frontend/app/editor/actions/suggestions-action-types.js @@ -9,7 +9,7 @@ export const TEXT_SUGGESTION_FINISHED_COPYING = export const PHRASE_SUGGESTION_STARTED_COPYING = 'PHRASE_SUGGESTION_STARTED_COPYING' export const PHRASE_SUGGESTION_FINISHED_COPYING = - Symbol('PHRASE_SUGGESTION_FINISHED_COPYING') + 'PHRASE_SUGGESTION_FINISHED_COPYING' export const TEXT_SUGGESTIONS_UPDATED = Symbol('TEXT_SUGGESTIONS_UPDATED') export const SUGGESTION_SEARCH_TEXT_CHANGE = Symbol('SUGGESTION_SEARCH_TEXT_CHANGE') diff --git a/server/zanata-frontend/src/frontend/app/editor/actions/suggestions-actions.js b/server/zanata-frontend/src/frontend/app/editor/actions/suggestions-actions.js index d5542394736..ebf68e84469 100644 --- a/server/zanata-frontend/src/frontend/app/editor/actions/suggestions-actions.js +++ b/server/zanata-frontend/src/frontend/app/editor/actions/suggestions-actions.js @@ -110,6 +110,9 @@ const textSuggestionFinishedCopying = const phraseSuggestionStartedCopying = createAction( PHRASE_SUGGESTION_STARTED_COPYING, (phraseId, index) => ({ phraseId, index })) +const phraseSuggestionFinishedCopying = createAction( + PHRASE_SUGGESTION_FINISHED_COPYING, + (phraseId, index) => ({ phraseId, index })) function copyTextSuggestionN (index) { return (dispatch, getState) => { @@ -138,10 +141,6 @@ function copyPhraseSuggestionN (phraseId, index) { } } -function phraseSuggestionFinishedCopying (phraseId, index) { - return { type: PHRASE_SUGGESTION_FINISHED_COPYING, phraseId, index } -} - export function textSuggestionsUpdated ( {loading, searchStrings, suggestions, timestamp}) { return { diff --git a/server/zanata-frontend/src/frontend/app/editor/reducers/suggestions-reducer.js b/server/zanata-frontend/src/frontend/app/editor/reducers/suggestions-reducer.js index cd392b5bf3f..eb774d4719e 100644 --- a/server/zanata-frontend/src/frontend/app/editor/reducers/suggestions-reducer.js +++ b/server/zanata-frontend/src/frontend/app/editor/reducers/suggestions-reducer.js @@ -46,9 +46,9 @@ const suggestions = (state = defaultState, action) => { case PHRASE_SUGGESTION_FINISHED_COPYING: return update({ searchByPhrase: { - [action.phraseId]: { + [action.payload.phraseId]: { suggestions: { - [action.index]: {copying: {$set: false}} + [action.payload.index]: {copying: {$set: false}} } } } diff --git a/server/zanata-frontend/src/frontend/app/editor/reducers/suggestions-reducer.test.js b/server/zanata-frontend/src/frontend/app/editor/reducers/suggestions-reducer.test.js index a73f9577ef3..bfe96b5fa6a 100644 --- a/server/zanata-frontend/src/frontend/app/editor/reducers/suggestions-reducer.test.js +++ b/server/zanata-frontend/src/frontend/app/editor/reducers/suggestions-reducer.test.js @@ -77,8 +77,10 @@ describe('suggestions-reducer test', () => { }) const doneCopying = suggestionsReducer(copying, { type: PHRASE_SUGGESTION_FINISHED_COPYING, - phraseId: 'p01', - index: 1 + payload: { + phraseId: 'p01', + index: 1 + } }) expect(copying.searchByPhrase['p01'].suggestions[1].copying).toEqual(true) expect(doneCopying.searchByPhrase['p01'].suggestions[1].copying)