Skip to content

Commit 216a791

Browse files
committed
delete TESTS_LOAD, move functionality into PAGE_SET
1 parent e37ff77 commit 216a791

File tree

28 files changed

+38
-116
lines changed

28 files changed

+38
-116
lines changed

lib/actions/_types.js

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ exports.SETUP_VERIFY = 'SETUP_VERIFY';
1818
exports.TEST_COMPLETE = 'TEST_COMPLETE';
1919
exports.TEST_RESULT = 'TEST_RESULT';
2020
exports.TEST_RUN = 'TEST_RUN';
21-
exports.TESTS_LOAD = 'TESTS_LOAD';
2221
exports.TUTORIAL_SET = 'TUTORIAL_SET';
2322
exports.TUTORIAL_UPDATE = 'TUTORIAL_UPDATE';
2423
exports.TUTORIALS_FIND = 'TUTORIALS_FIND';

lib/reducers/tasks/config-task-tests.js renamed to lib/actions/config-task-tests.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
var path_1 = require('path');
3-
var system_1 = require('../../services/system');
3+
var system_1 = require('../services/system');
44
function configTestString(dir, tutorial, config, name, testPath) {
55
if (system_1.isWindows) {
66
testPath = testPath.split('/').join('\\');

lib/actions/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ exports.testRun = test_1.testRun;
2323
exports.testComplete = test_1.testComplete;
2424
exports.testResult = test_1.testResult;
2525
exports.testSave = test_1.testSave;
26-
exports.testsLoad = test_1.testsLoad;
2726
var tutorial_1 = require('./tutorial');
2827
exports.tutorialsFind = tutorial_1.tutorialsFind;
2928
exports.tutorialSet = tutorial_1.tutorialSet;

lib/actions/page.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
2-
var test_1 = require('./test');
32
var _types_1 = require('./_types');
3+
var config_task_tests_1 = require('./config-task-tests');
44
function pageNext() {
55
return function (dispatch, getState) {
66
var _a = getState(), pagePosition = _a.pagePosition, tutorial = _a.tutorial;
@@ -11,7 +11,6 @@ function pageNext() {
1111
else {
1212
pagePosition += 1;
1313
dispatch(pageSet(pagePosition));
14-
dispatch(test_1.testsLoad(pagePosition));
1514
}
1615
};
1716
}
@@ -20,11 +19,12 @@ function pageSet(pagePosition) {
2019
if (pagePosition === void 0) { pagePosition = 0; }
2120
return function (dispatch, getState) {
2221
var _a = getState(), dir = _a.dir, progress = _a.progress, tutorial = _a.tutorial;
22+
var tasks = config_task_tests_1.default(dir, tutorial, tutorial.pages[pagePosition].tasks || []);
2323
if (pagePosition >= progress.pages.length) {
2424
dispatch({ type: _types_1.ROUTE_SET, payload: { route: 'final' } });
2525
}
2626
dispatch({
27-
type: _types_1.PAGE_SET, payload: { dir: dir, pagePosition: pagePosition, tutorial: tutorial, progress: progress }
27+
type: _types_1.PAGE_SET, payload: { dir: dir, pagePosition: pagePosition, tutorial: tutorial, progress: progress, tasks: tasks }
2828
});
2929
};
3030
}

lib/actions/test.js

-11
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,3 @@ function testSave() {
2424
return { type: _types_1.TEST_SAVE };
2525
}
2626
exports.testSave = testSave;
27-
function testsLoad(pagePosition) {
28-
return function (dispatch, getState) {
29-
var _a = getState(), tasks = _a.tasks, progress = _a.progress, tutorial = _a.tutorial, dir = _a.dir;
30-
dispatch({
31-
type: _types_1.TESTS_LOAD, payload: {
32-
pagePosition: pagePosition, tasks: tasks, progress: progress, tutorial: tutorial, dir: dir
33-
}
34-
});
35-
};
36-
}
37-
exports.testsLoad = testsLoad;

lib/components/Progress/ProgressPage/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ var ProgressPage = (function (_super) {
4141
return {
4242
selectPage: function (pagePosition) {
4343
dispatch(actions_1.pageSet(pagePosition));
44-
dispatch(actions_1.testsLoad(pagePosition));
4544
dispatch(actions_1.routeSet('page'));
4645
}
4746
};

lib/reducers/checks/action-setup.js

-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
var path_1 = require('path');
33
var editor_1 = require('../../atom/editor');
44
var editor_2 = require('../../atom/editor');
5-
var actions_1 = require('../../actions');
6-
var store_1 = require('../../store');
75
var packageData = "{\n \"name\": \"demo\",\n \"dependencies\": {\n \"coderoad-functional-school\": \"^0.2.2\"\n }\n}";
86
function createPackageJson(dir) {
97
var packagePath = path_1.join(dir, 'package.json');
@@ -12,7 +10,6 @@ function createPackageJson(dir) {
1210
setTimeout(function () { return resolve(); });
1311
}).then(function () {
1412
editor_1.set(packageData);
15-
store_1.default.dispatch(actions_1.setupVerify());
1613
});
1714
}
1815
exports.createPackageJson = createPackageJson;

lib/reducers/checks/action-system.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
"use strict";
22
var command_line_1 = require('../../services/command-line');
3-
var store_1 = require('../../store');
4-
var actions_1 = require('../../actions');
53
function updateNpm() {
64
command_line_1.default('npm', 'update -g npm')
75
.then(function (res) {
8-
store_1.default.dispatch(actions_1.setupVerify());
96
});
107
}
118
exports.updateNpm = updateNpm;

lib/reducers/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ var tutorial_1 = require('./tutorial');
1919
var tutorial_list_1 = require('./tutorial-list');
2020
var window_toggle_1 = require('./window-toggle');
2121
Object.defineProperty(exports, "__esModule", { value: true });
22-
exports.default = redux_1.combineReducers({
23-
alert: alert_1.default, checks: checks_1.default, dir: dir_1.default, devToolsToggle: devTools_toggle_1.default, taskActions: task_actions_1.default, hintPosition: hint_position_1.default, page: page_1.default,
24-
packageJson: package_json_1.default, pagePosition: page_position_1.default, progress: progress_1.default, route: route_1.default, taskPosition: task_position_1.default,
22+
exports.default = redux_1.combineReducers(Object.assign({}, {
23+
alert: alert_1.default, checks: checks_1.default, dir: dir_1.default, devToolsToggle: devTools_toggle_1.default, taskActions: task_actions_1.default, hintPosition: hint_position_1.default,
24+
packageJson: package_json_1.default, page: page_1.default, pagePosition: page_position_1.default, progress: progress_1.default, route: route_1.default, taskPosition: task_position_1.default,
2525
taskTests: task_tests_1.default, tasks: tasks_1.default, testRun: test_run_1.default, tutorial: tutorial_1.default, tutorialList: tutorial_list_1.default, windowToggle: window_toggle_1.default
26-
});
26+
}));

lib/reducers/page/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use strict";
22
var _types_1 = require('../../actions/_types');
3-
var editor_1 = require('../../atom/editor');
43
var _page = {
54
title: '',
65
description: '',
@@ -12,7 +11,6 @@ function pageReducer(p, action) {
1211
case _types_1.PAGE_SET:
1312
var _a = action.payload, pagePosition = _a.pagePosition, tutorial = _a.tutorial;
1413
var _b = tutorial.pages[pagePosition], title = _b.title, description = _b.description, onPageComplete = _b.onPageComplete, completed = _b.completed;
15-
editor_1.clearConsole();
1614
return {
1715
title: title,
1816
description: description,

lib/reducers/task-actions/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function taskActionsReducer(taskActions, action) {
1414
if (taskActions === void 0) { taskActions = []; }
1515
var actions = null;
1616
switch (action.type) {
17-
case _types_1.TESTS_LOAD:
17+
case _types_1.PAGE_SET:
1818
var _a = action.payload, tasks = _a.tasks, pagePosition = _a.pagePosition, progress = _a.progress;
1919
var isCompleted = progress.pages[pagePosition];
2020
if (!isCompleted) {

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

-38
This file was deleted.

lib/reducers/task-tests/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var _types_1 = require('../../actions/_types');
44
function taskTestsReducer(taskTests, action) {
55
if (taskTests === void 0) { taskTests = ''; }
66
switch (action.type) {
7-
case _types_1.TESTS_LOAD:
7+
case _types_1.PAGE_SET:
88
var _a = action.payload, tutorial = _a.tutorial, tasks = _a.tasks;
99
return [].concat.apply([], tasks.map(function (task) { return task.tests || []; })).reduce(function (output, file) {
1010
try {

lib/reducers/tasks/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use strict";
22
var _types_1 = require('../../actions/_types');
3-
var config_task_tests_1 = require('./config-task-tests');
43
var _tasks = [{
54
actions: [],
65
completed: false,
@@ -12,8 +11,7 @@ function tasksReducer(tasks, action) {
1211
if (tasks === void 0) { tasks = _tasks; }
1312
switch (action.type) {
1413
case _types_1.PAGE_SET:
15-
var _a = action.payload, dir = _a.dir, tutorial = _a.tutorial, pagePosition = _a.pagePosition;
16-
return config_task_tests_1.default(dir, tutorial, tutorial.pages[pagePosition].tasks || []);
14+
return action.payload.tasks;
1715
default:
1816
return tasks;
1917
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"atom": ">=1.0.0 <2.0.0"
3939
},
4040
"dependencies": {
41+
"coderoad-core": "^0.1.0",
4142
"highlights": "1.3.1",
4243
"marked": "0.3.5",
4344
"material-ui": "0.15.0",

src/actions/_types.ts

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const SETUP_VERIFY = 'SETUP_VERIFY';
1717
export const TEST_COMPLETE = 'TEST_COMPLETE';
1818
export const TEST_RESULT = 'TEST_RESULT';
1919
export const TEST_RUN = 'TEST_RUN';
20-
export const TESTS_LOAD = 'TESTS_LOAD';
2120
export const TUTORIAL_SET = 'TUTORIAL_SET';
2221
export const TUTORIAL_UPDATE = 'TUTORIAL_UPDATE';
2322
export const TUTORIALS_FIND = 'TUTORIALS_FIND';

src/reducers/tasks/config-task-tests.ts renamed to src/actions/config-task-tests.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {join} from 'path';
2-
import {isWindows} from '../../services/system';
2+
import {isWindows} from '../services/system';
33

44
function configTestString(
55
dir: string, tutorial: CR.Tutorial, config: Tutorial.Config,

src/actions/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export {pageSet, pageNext, pagePositionLoad, pagePositionSet} from './page';
77
export {routeSet} from './route';
88
export {setupVerify} from './setup';
99
export {
10-
testRun, testComplete, testResult, testSave, testsLoad
10+
testRun, testComplete, testResult, testSave
1111
} from './test';
1212
export {
1313
tutorialsFind, tutorialSet, tutorialUpdate

src/actions/page.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {testsLoad} from './test';
21
import {
32
ROUTE_SET, PAGE_SET, PAGE_POSITION_SET, PAGE_POSITION_LOAD
43
} from './_types';
4+
import configTaskTests from './config-task-tests';
55

66
export function pageNext(): ReduxThunk.ThunkInterface | Action {
77
return (dispatch, getState): void => {
@@ -11,21 +11,23 @@ export function pageNext(): ReduxThunk.ThunkInterface | Action {
1111
dispatch({ type: ROUTE_SET, payload: { route: 'final' } });
1212
} else {
1313
pagePosition += 1;
14-
// call TESTS_LOAD after PAGE_SET
1514
dispatch(pageSet(pagePosition));
16-
dispatch(testsLoad(pagePosition));
1715
}
1816
};
1917
}
2018

2119
export function pageSet(pagePosition = 0): ReduxThunk.ThunkInterface {
2220
return (dispatch, getState): void => {
2321
const {dir, progress, tutorial} = getState();
22+
// create absolute paths for 'task-tests'
23+
const tasks = configTaskTests(
24+
dir, tutorial, tutorial.pages[pagePosition].tasks || []
25+
);
2426
if (pagePosition >= progress.pages.length) {
2527
dispatch({ type: ROUTE_SET, payload: { route: 'final' } });
2628
}
2729
dispatch({
28-
type: PAGE_SET, payload: { dir, pagePosition, tutorial, progress }
30+
type: PAGE_SET, payload: { dir, pagePosition, tutorial, progress, tasks }
2931
});
3032
};
3133
}

src/actions/test.ts

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
TEST_RUN, TEST_RESULT, TEST_COMPLETE, TESTS_LOAD, TEST_SAVE
2+
TEST_RUN, TEST_RESULT, TEST_COMPLETE, TEST_SAVE
33
} from './_types';
44

55
export function testRun(): ReduxThunk.ThunkInterface {
@@ -25,16 +25,3 @@ export function testComplete(): Action {
2525
export function testSave(): Action {
2626
return { type: TEST_SAVE };
2727
}
28-
29-
export function testsLoad(
30-
pagePosition: CR.PagePosition
31-
): ReduxThunk.ThunkInterface {
32-
return (dispatch, getState): void => {
33-
const {tasks, progress, tutorial, dir} = getState();
34-
dispatch({
35-
type: TESTS_LOAD, payload: {
36-
pagePosition, tasks, progress, tutorial, dir
37-
}
38-
});
39-
};
40-
}

src/components/Progress/ProgressPage/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import {connect} from 'react-redux';
3-
import {pageSet, routeSet, testsLoad} from '../../../actions';
3+
import {pageSet, routeSet} from '../../../actions';
44
import {ListItem} from 'material-ui/List';
55
import progressIcon from '../progressIcon';
66
import {grey400} from 'material-ui/styles/colors';
@@ -14,7 +14,6 @@ const styles = {
1414
return {
1515
selectPage: (pagePosition: CR.PagePosition) => {
1616
dispatch(pageSet(pagePosition));
17-
dispatch(testsLoad(pagePosition));
1817
dispatch(routeSet('page'));
1918
}
2019
};

src/reducers/index.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {combineReducers} from 'redux';
2+
// import {reducers} from 'coderoad-core';
23

34
import alert from './alert';
45
import checks from './checks';
@@ -19,8 +20,10 @@ import tutorial from './tutorial';
1920
import tutorialList from './tutorial-list';
2021
import windowToggle from './window-toggle';
2122

22-
export default combineReducers({
23-
alert, checks, dir, devToolsToggle, taskActions, hintPosition, page,
24-
packageJson, pagePosition, progress, route, taskPosition,
25-
taskTests, tasks, testRun, tutorial, tutorialList, windowToggle
26-
});
23+
export default combineReducers(
24+
Object.assign({}, {
25+
alert, checks, dir, devToolsToggle, taskActions, hintPosition,
26+
packageJson, page, pagePosition, progress, route, taskPosition,
27+
taskTests, tasks, testRun, tutorial, tutorialList, windowToggle
28+
})
29+
);

src/reducers/page/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {PAGE_SET, COMPLETE_PAGE} from '../../actions/_types';
2-
import {clearConsole} from '../../atom/editor';
2+
// import {clearConsole} from '../../atom/editor';
33

44
const _page: CR.Page = {
55
title: '',
@@ -16,7 +16,7 @@ export default function pageReducer(
1616
const {pagePosition, tutorial} = action.payload;
1717
const {title, description, onPageComplete, completed} = tutorial.pages[pagePosition];
1818
// clear dev console
19-
clearConsole();
19+
// clearConsole();
2020
return {
2121
title,
2222
description,

src/reducers/task-actions/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {TESTS_LOAD, TEST_RESULT} from '../../actions/_types';
1+
import {PAGE_SET, TEST_RESULT} from '../../actions/_types';
22
import editorActionReducer from './editor-reducer';
33

44
function handleTaskActions(actions: string[][]): void {
@@ -20,7 +20,7 @@ export default function taskActionsReducer(
2020
let actions: string[][] = null;
2121
switch (action.type) {
2222

23-
case TESTS_LOAD:
23+
case PAGE_SET:
2424
const {tasks, pagePosition, progress} = action.payload;
2525
const isCompleted = progress.pages[pagePosition];
2626
if (!isCompleted) {

src/reducers/task-tests/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {readFileSync} from 'fs';
2-
import {TESTS_LOAD} from '../../actions/_types';
2+
import {PAGE_SET} from '../../actions/_types';
33

44
export default function taskTestsReducer(
55
taskTests = '', action: Action
66
): string {
77
switch (action.type) {
88

9-
case TESTS_LOAD:
9+
case PAGE_SET:
1010
const {tutorial, tasks} = action.payload;
1111
return [].concat.apply([], tasks.map(
1212
task => task.tests || [])

src/reducers/tasks/index.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ export default function tasksReducer(tasks = _tasks,
1414
switch (action.type) {
1515

1616
case PAGE_SET:
17-
const {dir, tutorial, pagePosition} = action.payload;
18-
// create absolute paths for 'task-tests'
19-
return configTaskTests(
20-
dir, tutorial, tutorial.pages[pagePosition].tasks || []
21-
);
17+
return action.payload.tasks;
2218

2319
default:
2420
return tasks;

0 commit comments

Comments
 (0)