Skip to content

Commit f56e959

Browse files
committed
Add state mgmt logic for updating instructions
1 parent 54487ad commit f56e959

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/actions/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
unhideComponent,
1616
toggleComponent,
1717
updateProjectSource,
18+
updateProjectInstructions,
1819
} from './projects';
1920

2021
import {
@@ -69,6 +70,7 @@ export {
6970
createSnapshot,
7071
changeCurrentProject,
7172
updateProjectSource,
73+
updateProjectInstructions,
7274
toggleLibrary,
7375
userAuthenticated,
7476
userLoggedOut,

src/actions/projects.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export const updateProjectSource = createAction(
1818
(_projectKey, _language, _newValue, timestamp = Date.now()) => ({timestamp}),
1919
);
2020

21+
export const updateProjectInstructions = createAction(
22+
'UPDATE_PROJECT_INSTRUCTIONS',
23+
(projectKey, newValue) => ({projectKey, newValue}),
24+
);
25+
2126
export const toggleLibrary = createAction(
2227
'TOGGLE_LIBRARY',
2328
(projectKey, libraryKey) => ({projectKey, libraryKey}),

src/reducers/projects.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ export default function reduceProjects(stateIn, action) {
115115
action.meta.timestamp,
116116
);
117117

118+
case 'UPDATE_PROJECT_INSTRUCTIONS':
119+
return state.setIn(
120+
[action.payload.projectKey, 'instructions'],
121+
action.payload.newValue,
122+
);
123+
118124
case 'PROJECT_CREATED':
119125
return removePristineExcept(state, action.payload.projectKey).set(
120126
action.payload.projectKey,

src/reducers/ui.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ export default function ui(stateIn, action) {
225225
return state.setIn(['workspace', 'isEditingInstructions'], true);
226226

227227
case 'STOP_EDITING_INSTRUCTIONS':
228+
case 'UPDATE_PROJECT_INSTRUCTIONS':
228229
return state.setIn(['workspace', 'isEditingInstructions'], false);
229230

230231
default:

0 commit comments

Comments
 (0)