Skip to content

Commit 011b0e6

Browse files
committed
setup load task action and call
1 parent 09de7a4 commit 011b0e6

File tree

14 files changed

+66
-11
lines changed

14 files changed

+66
-11
lines changed

lib/components/Tutorials/SelectTutorial/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ var SelectTutorial = (function (_super) {
2424
}
2525
SelectTutorial.prototype.render = function () {
2626
var _a = this.props, tutorial = _a.tutorial, tutorialSet = _a.tutorialSet;
27-
var name = tutorial.name;
28-
return (React.createElement(FlatButton_1.default, {label: this.displayName(name), primary: true, onTouchTap: tutorialSet.bind(this, name)}));
27+
var name = tutorial.name, version = tutorial.version;
28+
console.log(name, version);
29+
return (React.createElement(FlatButton_1.default, {label: this.displayName(name), primary: true, onTouchTap: tutorialSet.bind(this, { name: name, version: version })}));
2930
};
3031
SelectTutorial.prototype.displayName = function (name) {
3132
switch (true) {

lib/modules/tests/actions.js

+16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ function testRun() {
1414
};
1515
}
1616
exports.testRun = testRun;
17+
function testLoad() {
18+
return function (dispatch, getState) {
19+
var _a = getState(), dir = _a.dir, pagePosition = _a.pagePosition, tutorial = _a.tutorial;
20+
dispatch({
21+
type: types_1.TEST_LOAD, payload: {
22+
dir: dir,
23+
pagePosition: pagePosition,
24+
tutorial: {
25+
name: tutorial.name,
26+
version: tutorial.version
27+
}
28+
}
29+
});
30+
};
31+
}
32+
exports.testLoad = testLoad;
1733
function testResult(result) {
1834
return function (dispatch, getState) {
1935
var _a = getState(), taskActions = _a.taskActions, progress = _a.progress, pagePosition = _a.pagePosition;

lib/modules/tests/test-run/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use strict";
22
var types_1 = require('../types');
3+
var load_1 = require('./load');
34
var run_1 = require('./run');
45
var pageSetTimeout = 1200;
56
var testCompleteTimeout = 800;
@@ -22,6 +23,7 @@ function runTest(testRun, action) {
2223
time: performance.now() + testCompleteTimeout,
2324
};
2425
case 'PAGE_SET':
26+
load_1.default();
2527
return {
2628
running: false,
2729
time: performance.now() + pageSetTimeout,

lib/modules/tests/test-run/load.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"use strict";
2+
function loadTaskTests() {
3+
console.log('load');
4+
}
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
exports.default = loadTaskTests;

lib/modules/tests/types.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
22
exports.TEST_COMPLETE = 'TEST_COMPLETE';
3+
exports.TEST_LOAD = 'TEST_LOAD';
34
exports.TEST_RESULT = 'TEST_RESULT';
45
exports.TEST_RUN = 'TEST_RUN';

lib/modules/tutorial/actions.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"use strict";
22
var types_1 = require('./types');
33
var core_coderoad_1 = require('core-coderoad');
4-
function tutorialSet(name) {
4+
function tutorialSet(_a) {
5+
var name = _a.name, version = _a.version;
56
return function (dispatch, getState) {
67
var dir = getState().dir;
7-
dispatch({ type: types_1.TUTORIAL_SET, payload: { name: name, dir: dir } });
8+
dispatch({ type: types_1.TUTORIAL_SET, payload: { name: name, dir: dir, version: version } });
89
dispatch(core_coderoad_1.routeSet('progress'));
910
};
1011
}

lib/modules/tutorial/reducer.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var config_1 = require('./utils/config');
55
var config_paths_1 = require('./utils/config-paths');
66
var _tutorial = {
77
name: null,
8+
version: null,
89
info: null,
910
pages: [],
1011
packageJson: null,
@@ -15,7 +16,7 @@ function tutorialReducer(t, action) {
1516
if (t === void 0) { t = _tutorial; }
1617
switch (action.type) {
1718
case types_1.TUTORIAL_SET:
18-
var _a = action.payload, name_1 = _a.name, dir = _a.dir;
19+
var _a = action.payload, name_1 = _a.name, dir = _a.dir, version = _a.version;
1920
var packagePath = path_1.join(dir, 'node_modules', name_1);
2021
var packageJson = require(path_1.join(packagePath, 'package.json'));
2122
var config = config_1.tutorialConfig(packageJson, dir);
@@ -27,6 +28,7 @@ function tutorialReducer(t, action) {
2728
configured.push(name_1);
2829
return {
2930
name: packageJson.name,
31+
version: version,
3032
info: info,
3133
pages: pages,
3234
packageJson: packageJson,

src/components/Tutorials/SelectTutorial/index.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ export default class SelectTutorial extends React.Component<{
1010
}, {}> {
1111
public render() {
1212
const {tutorial, tutorialSet} = this.props;
13-
const {name} = tutorial;
13+
const {name, version} = tutorial;
14+
console.log(name, version);
1415
return (
1516
<FlatButton
1617
label={this.displayName(name)}
1718
primary={true}
18-
onTouchTap={tutorialSet.bind(this, name)}
19+
onTouchTap={tutorialSet.bind(this, {name, version})}
1920
/>
2021
);
2122
}

src/modules/tests/actions.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {alertOpen, hintPositionSet, progressCompletePage} from '../../actions';
2-
import {TEST_COMPLETE, TEST_RESULT, TEST_RUN} from './types';
2+
import {TEST_COMPLETE, TEST_LOAD, TEST_RESULT, TEST_RUN} from './types';
33

44
export function testRun(): ReduxThunk.ThunkInterface {
55
return (dispatch, getState): void => {
@@ -15,6 +15,22 @@ export function testRun(): ReduxThunk.ThunkInterface {
1515
};
1616
}
1717

18+
export function testLoad() {
19+
return (dispatch, getState): void => {
20+
const { dir, pagePosition, tutorial } = getState();
21+
dispatch({
22+
type: TEST_LOAD, payload: {
23+
dir,
24+
pagePosition,
25+
tutorial: {
26+
name: tutorial.name,
27+
version: tutorial.version
28+
}
29+
}
30+
});
31+
};
32+
}
33+
1834
export function testResult(result: Test.Result): ReduxThunk.ThunkInterface {
1935
return (dispatch, getState): void => {
2036
const {taskActions, progress, pagePosition} = getState();

src/modules/tests/test-run/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {TEST_COMPLETE, TEST_RUN} from '../types';
2+
import loadTaskTests from './load';
23
import runTaskTests from './run';
34

45
// timeouts = throttle test runs
@@ -35,6 +36,7 @@ export default function runTest(
3536
};
3637

3738
case 'PAGE_SET':
39+
loadTaskTests();
3840
// add extra time, as page loading takes longer
3941
return {
4042
running: false,

src/modules/tests/test-run/load.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default function loadTaskTests() {
2+
console.log('load')
3+
// tutorialConfig.run({});
4+
}

src/modules/tests/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const TEST_COMPLETE = 'TEST_COMPLETE';
2+
export const TEST_LOAD = 'TEST_LOAD';
23
export const TEST_RESULT = 'TEST_RESULT';
34
export const TEST_RUN = 'TEST_RUN';

src/modules/tutorial/actions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {TUTORIAL_SET} from './types';
22
import {routeSet} from 'core-coderoad';
33

4-
export function tutorialSet(name: string): ReduxThunk.ThunkInterface {
4+
export function tutorialSet({name, version}): ReduxThunk.ThunkInterface {
55
return (dispatch, getState) => {
66
const {dir} = getState();
7-
dispatch({ type: TUTORIAL_SET, payload: {name, dir }});
7+
dispatch({ type: TUTORIAL_SET, payload: {name, dir, version }});
88
dispatch(routeSet('progress'));
99
};
1010
}

src/modules/tutorial/reducer.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import configPaths from './utils/config-paths';
66

77
const _tutorial: CR.Tutorial = {
88
name: null,
9+
version: null,
910
info: null,
1011
pages: [],
1112
packageJson: null,
@@ -20,7 +21,7 @@ export default function tutorialReducer(
2021
switch (action.type) {
2122

2223
case TUTORIAL_SET:
23-
const {name, dir} = action.payload;
24+
const {name, dir, version} = action.payload;
2425

2526
// get tutorial package.json
2627
const packagePath: string = join(dir, 'node_modules', name);
@@ -39,6 +40,7 @@ export default function tutorialReducer(
3940
// return tutorial (info, pages) & tutorial package.json
4041
return {
4142
name: packageJson.name,
43+
version,
4244
info,
4345
pages,
4446
packageJson,

0 commit comments

Comments
 (0)