Skip to content

Commit 996a73e

Browse files
committed
Merge branch 'packageRefactor'
2 parents 4d3bdbc + f4b5f92 commit 996a73e

File tree

167 files changed

+1342
-1236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+1342
-1236
lines changed

lib/actions/_types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ exports.ALERT_TOGGLE = 'ALERT_TOGGLE';
44
exports.COMPLETE_CHAPTER = 'COMPLETE_CHAPTER';
55
exports.COMPLETE_PAGE = 'COMPLETE_PAGE';
66
exports.COMPLETE_TUTORIAL = 'COMPLETE_TUTORIAL';
7-
exports.GLOBALS_SET = 'GLOBALS_SET';
87
exports.HINT_POSITION_SET = 'HINT_POSITION_SET';
98
exports.HINT_SHOW = 'HINT_SHOW';
109
exports.PACKAGE_SET = 'PACKAGE_SET';
11-
exports.PAGE_NEXT = 'PAGE_NEXT';
1210
exports.PAGE_SET = 'PAGE_SET';
1311
exports.POSITION_SET = 'POSITION_SET';
12+
exports.PROGRESS_LOAD = 'PROGRESS_LOAD';
1413
exports.ROUTE_SET = 'ROUTE_SET';
1514
exports.SETUP_VERIFY = 'SETUP_VERIFY';
1615
exports.TEST_COMPLETE = 'TEST_COMPLETE';
1716
exports.TEST_RESULT = 'TEST_RESULT';
1817
exports.TEST_RUN = 'TEST_RUN';
18+
exports.TESTS_LOAD = 'TESTS_LOAD';
1919
exports.TUTORIAL_SET = 'TUTORIAL_SET';
2020
exports.TUTORIAL_UPDATE = 'TUTORIAL_UPDATE';
2121
exports.TUTORIALS_FIND = 'TUTORIALS_FIND';

lib/actions/alert.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ var _types_1 = require('./_types');
44
function alertToggle(alert) {
55
var isOpen = store_1.store.getState().alert.open;
66
if (!alert) {
7-
alert = { message: '', action: '', open: false };
7+
alert = {
8+
action: '',
9+
message: '',
10+
open: false,
11+
};
812
}
913
else {
1014
alert = Object.assign({}, { open: !isOpen }, alert);
1115
}
12-
return { type: _types_1.ALERT_TOGGLE, payload: { alert: alert } };
16+
return {
17+
payload: { alert: alert },
18+
type: _types_1.ALERT_TOGGLE,
19+
};
1320
}
1421
exports.alertToggle = alertToggle;
1522
function alertReplay() {

lib/actions/globals.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

lib/actions/hint.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
"use strict";
22
var _types_1 = require('./_types');
33
function hintPositionSet(hintPosition) {
4-
return { type: _types_1.HINT_POSITION_SET, payload: { hintPosition: hintPosition } };
4+
return {
5+
payload: { hintPosition: hintPosition },
6+
type: _types_1.HINT_POSITION_SET,
7+
};
58
}
69
exports.hintPositionSet = hintPositionSet;
710
function hintShow() {

lib/actions/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
var alert_1 = require('./alert');
33
exports.alertToggle = alert_1.alertToggle;
44
exports.alertReplay = alert_1.alertReplay;
5-
var complete_1 = require('./complete');
6-
exports.completePage = complete_1.completePage;
7-
exports.completeChapter = complete_1.completeChapter;
8-
exports.completeTutorial = complete_1.completeTutorial;
9-
var globals_1 = require('./globals');
10-
exports.globalsSet = globals_1.globalsSet;
5+
var progress_1 = require('./progress');
6+
exports.progressLoad = progress_1.progressLoad;
7+
exports.completePage = progress_1.completePage;
8+
exports.completeChapter = progress_1.completeChapter;
9+
exports.completeTutorial = progress_1.completeTutorial;
1110
var hint_1 = require('./hint');
1211
exports.hintShow = hint_1.hintShow;
1312
exports.hintPositionSet = hint_1.hintPositionSet;
@@ -24,7 +23,7 @@ var test_1 = require('./test');
2423
exports.testRun = test_1.testRun;
2524
exports.testComplete = test_1.testComplete;
2625
exports.testResult = test_1.testResult;
26+
exports.testsLoad = test_1.testsLoad;
2727
var tutorial_1 = require('./tutorial');
2828
exports.tutorialsFind = tutorial_1.tutorialsFind;
29-
exports.tutorialUpdate = tutorial_1.tutorialUpdate;
3029
exports.tutorialSet = tutorial_1.tutorialSet;

lib/actions/page.js

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,49 @@
11
"use strict";
22
var _types_1 = require('./_types');
3+
var index_1 = require('./index');
34
var store_1 = require('../store');
4-
var tutorial_package_1 = require('../services/tutorial-package');
5+
var _position = {
6+
chapter: 0,
7+
page: 0,
8+
};
59
function pageNext() {
6-
var position = store_1.store.getState().position;
7-
var nextPosition = tutorial_package_1.default.getNextPosition(position);
8-
return pageSet(nextPosition);
10+
var position = null;
11+
var _a = store_1.store.getState().position, page = _a.page, chapter = _a.chapter;
12+
var chapters = store_1.store.getState().tutorial.chapters;
13+
if (page < chapters[chapter].pages.length - 1) {
14+
position = {
15+
chapter: chapter,
16+
page: page + 1,
17+
};
18+
}
19+
else if (chapter < chapters.length - 1) {
20+
store_1.store.dispatch(index_1.completePage());
21+
position = {
22+
chapter: chapter + 1,
23+
page: 0,
24+
};
25+
}
26+
else {
27+
store_1.store.dispatch(index_1.completeTutorial());
28+
position = {
29+
chapter: chapter,
30+
page: page
31+
};
32+
}
33+
return { type: _types_1.PAGE_SET, payload: { position: position } };
934
}
1035
exports.pageNext = pageNext;
11-
function pageSet(selectedPosition) {
12-
if (selectedPosition === void 0) { selectedPosition = { chapter: 0, page: 0 }; }
13-
if (selectedPosition.completed) {
14-
return { type: _types_1.ROUTE_SET, payload: { route: 'final' } };
36+
function pageSet(position) {
37+
if (position === void 0) { position = _position; }
38+
if (position.completed) {
39+
return {
40+
payload: { route: 'final' },
41+
type: _types_1.ROUTE_SET,
42+
};
1543
}
16-
var page = tutorial_package_1.default.getPage(selectedPosition);
17-
var tasks = tutorial_package_1.default.getTasks(selectedPosition);
18-
var taskTests = [].concat.apply([], tasks.map(function (task) { return task.tests || []; }));
19-
var actions = tasks.map(function (task) { return task.actions || []; });
20-
return { type: _types_1.PAGE_SET, payload: { page: page, tasks: tasks, position: selectedPosition, taskTests: taskTests, actions: actions } };
44+
return {
45+
payload: { position: position },
46+
type: _types_1.PAGE_SET,
47+
};
2148
}
2249
exports.pageSet = pageSet;

lib/actions/position.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"use strict";
22
var _types_1 = require('./_types');
33
function positionSet(position) {
4-
return { type: _types_1.POSITION_SET, payload: { position: position } };
4+
return {
5+
payload: { position: position },
6+
type: _types_1.POSITION_SET,
7+
};
58
}
69
exports.positionSet = positionSet;

lib/actions/complete.js renamed to lib/actions/progress.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
"use strict";
22
var _types_1 = require('./_types');
33
var store_1 = require('../store');
4+
function progressLoad() {
5+
return { type: _types_1.PROGRESS_LOAD };
6+
}
7+
exports.progressLoad = progressLoad;
48
function completePage() {
59
var position = store_1.store.getState().position;
610
var pageLength = store_1.store.getState().progress.chapters[position.chapter].pages.length;
711
if (position.page >= pageLength - 1) {
812
return completeChapter();
913
}
10-
return { type: _types_1.COMPLETE_PAGE, payload: { position: position } };
14+
return {
15+
payload: { position: position },
16+
type: _types_1.COMPLETE_PAGE,
17+
};
1118
}
1219
exports.completePage = completePage;
1320
function completeChapter() {
@@ -16,7 +23,10 @@ function completeChapter() {
1623
if (chapter >= chapterLength - 1) {
1724
return completeTutorial();
1825
}
19-
return { type: _types_1.COMPLETE_CHAPTER, payload: { chapter: chapter } };
26+
return {
27+
payload: { chapter: chapter },
28+
type: _types_1.COMPLETE_CHAPTER,
29+
};
2030
}
2131
exports.completeChapter = completeChapter;
2232
function completeTutorial() {

lib/actions/route.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ function setRoute(route) {
1010
store_1.store.dispatch(tutorial_1.tutorialsFind());
1111
}
1212
previous = route;
13-
return { type: _types_1.ROUTE_SET, payload: { route: route } };
13+
return {
14+
payload: { route: route },
15+
type: _types_1.ROUTE_SET,
16+
};
1417
}
1518
}
1619
exports.setRoute = setRoute;

lib/actions/test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ function testRun() {
77
exports.testRun = testRun;
88
function testResult(result) {
99
var actions = store_1.store.getState().editorActions;
10-
return { type: _types_1.TEST_RESULT, payload: { result: result, actions: actions } };
10+
return {
11+
payload: { result: result, actions: actions },
12+
type: _types_1.TEST_RESULT,
13+
};
1114
}
1215
exports.testResult = testResult;
1316
function testComplete() {
1417
return { type: _types_1.TEST_COMPLETE };
1518
}
1619
exports.testComplete = testComplete;
20+
function testsLoad() {
21+
return { type: _types_1.TESTS_LOAD };
22+
}
23+
exports.testsLoad = testsLoad;

0 commit comments

Comments
 (0)