Skip to content

Commit a0237fe

Browse files
committed
allow "open" actions on completed tutorials
1 parent f0ac9cb commit a0237fe

File tree

6 files changed

+25
-11
lines changed

6 files changed

+25
-11
lines changed

lib/reducers/task-actions/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@ function taskActionsReducer(taskActions, action) {
1616
var actions = null;
1717
switch (action.type) {
1818
case _types_1.TESTS_LOAD:
19-
if (store_1.default.getState().progress.pages[store_1.default.getState().pagePosition]) {
20-
return [];
19+
var tasks = store_1.default.getState().tasks || [];
20+
var pagePosition = store_1.default.getState().pagePosition;
21+
var isCompleted = store_1.default.getState().progress.pages[pagePosition];
22+
if (!isCompleted) {
23+
actions = tasks.map(function (task) { return task.actions || []; });
24+
}
25+
else {
26+
actions = tasks.map(function (task) {
27+
return task.actions.filter(function (a) { return !!a.match(/^open/); });
28+
});
2129
}
2230
taskTracker = 0;
23-
actions = store_1.default.getState().tasks.map(function (task) { return task.actions || []; });
2431
handleTaskActions(actions);
2532
return actions;
2633
case _types_1.TEST_RESULT:

lib/reducers/task-tests/config-task-tests.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ function configTaskTests(tasks) {
3434
return task;
3535
});
3636
}
37-
exports.configTaskTests = configTaskTests;
37+
Object.defineProperty(exports, "__esModule", { value: true });
38+
exports.default = configTaskTests;

lib/reducers/tasks/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function tasksReducer(tasks, action) {
1414
switch (action.type) {
1515
case _types_1.PAGE_SET:
1616
var pagePosition = action.payload.pagePosition;
17-
return config_task_tests_1.configTaskTests(store_1.default.getState().tutorial.pages[pagePosition].tasks || []);
17+
return config_task_tests_1.default(store_1.default.getState().tutorial.pages[pagePosition].tasks || []);
1818
default:
1919
return tasks;
2020
}

src/reducers/task-actions/index.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@ export default function taskActionsReducer(
2222
switch (action.type) {
2323

2424
case TESTS_LOAD:
25-
26-
if (store.getState().progress.pages[store.getState().pagePosition]) {
27-
return [];
25+
let tasks = store.getState().tasks || [];
26+
const pagePosition = store.getState().pagePosition;
27+
const isCompleted = store.getState().progress.pages[pagePosition];
28+
if (!isCompleted) {
29+
actions = tasks.map(task => task.actions || []);
30+
} else {
31+
// filter to only 'open' actions
32+
actions = tasks.map(task => {
33+
return task.actions.filter(a => !!a.match(/^open/));
34+
});
2835
}
2936
taskTracker = 0;
30-
actions = store.getState().tasks.map(task => task.actions || []);
3137
handleTaskActions(actions); // run first action
3238
return actions;
3339

src/reducers/task-tests/config-task-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function configTestString(config: Tutorial.Config, name: string, testPath: strin
2121
return testPath;
2222
}
2323

24-
export function configTaskTests(tasks: CR.Task[]): CR.Task[] {
24+
export default function configTaskTests(tasks: CR.Task[]): CR.Task[] {
2525
const {config, name} = store.getState().tutorial;
2626
return !tasks ? [] : tasks.map((task: CR.Task) => {
2727
if (task.tests) {

src/reducers/tasks/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {PAGE_SET} from '../../actions/_types';
22
import store from '../../store';
3-
import {configTaskTests} from '../task-tests/config-task-tests';
3+
import configTaskTests from '../task-tests/config-task-tests';
44

55
const _tasks: CR.Task[] = [{
66
actions: [],

0 commit comments

Comments
 (0)