Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8401dee

Browse files
committed
refactor redux actions (noun + verb), minor fixes
1 parent7942cfa commit8401dee

File tree

119 files changed

+639
-488
lines changed

Some content is hidden

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

119 files changed

+639
-488
lines changed

‎lib/actions/_actions.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"use strict";
2+
varalert_1=require('./alert');
3+
exports.alertToggle=alert_1.alertToggle;
4+
exports.alertReplay=alert_1.alertReplay;
5+
varcomplete_1=require('./complete');
6+
exports.completePage=complete_1.completePage;
7+
exports.completeChapter=complete_1.completeChapter;
8+
exports.completeTutorial=complete_1.completeTutorial;
9+
varglobals_1=require('./globals');
10+
exports.globalsSet=globals_1.globalsSet;
11+
varhint_1=require('./hint');
12+
exports.hintShow=hint_1.hintShow;
13+
exports.hintPositionSet=hint_1.hintPositionSet;
14+
varpage_1=require('./page');
15+
exports.pageSet=page_1.pageSet;
16+
exports.pageNext=page_1.pageNext;
17+
varposition_1=require('./position');
18+
exports.positionSet=position_1.positionSet;
19+
varroute_1=require('./route');
20+
exports.setRoute=route_1.setRoute;
21+
varsetup_1=require('./setup');
22+
exports.setupVerify=setup_1.setupVerify;
23+
vartest_1=require('./test');
24+
exports.testRun=test_1.testRun;
25+
exports.testComplete=test_1.testComplete;
26+
exports.testResult=test_1.testResult;
27+
vartutorial_1=require('./tutorial');
28+
exports.tutorialsFind=tutorial_1.tutorialsFind;
29+
exports.tutorialUpdate=tutorial_1.tutorialUpdate;
30+
exports.tutorialSet=tutorial_1.tutorialSet;

‎lib/actions/_types.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"use strict";
2+
exports.ALERT_REPLAY='ALERT_REPLAY';
3+
exports.ALERT_TOGGLE='ALERT_TOGGLE';
4+
exports.COMPLETE_CHAPTER='COMPLETE_CHAPTER';
5+
exports.COMPLETE_PAGE='COMPLETE_PAGE';
6+
exports.COMPLETE_TUTORIAL='COMPLETE_TUTORIAL';
7+
exports.GLOBALS_SET='GLOBALS_SET';
8+
exports.HINT_POSITION_SET='HINT_POSITION_SET';
9+
exports.HINT_SHOW='HINT_SHOW';
10+
exports.PAGE_NEXT='PAGE_NEXT';
11+
exports.PAGE_SET='PAGE_SET';
12+
exports.POSITION_SET='POSITION_SET';
13+
exports.ROUTE_SET='ROUTE_SET';
14+
exports.SETUP_VERIFY='SETUP_VERIFY';
15+
exports.TEST_COMPLETE='TEST_COMPLETE';
16+
exports.TEST_RESULT='TEST_RESULT';
17+
exports.TEST_RUN='TEST_RUN';
18+
exports.TUTORIAL_SET='TUTORIAL_SET';
19+
exports.TUTORIAL_UPDATE='TUTORIAL_UPDATE';
20+
exports.TUTORIALS_FIND='TUTORIALS_FIND';

‎lib/actions/actionTypes.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
"use strict";
2-
exports.VERIFY_SETUP='VERIFY_SETUP';
3-
exports.SET_GLOBALS='SET_GLOBALS';
4-
exports.SET_TUTORIAL_INFO='SET_TUTORIAL_INFO';
5-
exports.LOAD_TUTORIALS='LOAD_TUTORIALS';
6-
exports.UPDATE_TUTORIAL='UPDATE_TUTORIAL';
7-
exports.SET_ROUTE='SET_ROUTE';
8-
exports.SET_PAGE='SET_PAGE';
9-
exports.NEXT_PAGE='NEXT_PAGE';
10-
exports.SET_POSITION='SET_POSITION';
11-
exports.SET_PROGRESS='SET_PROGRESS';
12-
exports.PAGE_COMPLETE='PAGE_COMPLETE';
13-
exports.CHAPTER_COMPLETE='CHAPTER_COMPLETE';
14-
exports.PROJECT_COMPLETE='PROJECT_COMPLETE';
2+
exports.ALERT_REPLAY='ALERT_REPLAY';
3+
exports.ALERT_TOGGLE='ALERT_TOGGLE';
4+
exports.COMPLETE_CHAPTER='COMPLETE_CHAPTER';
5+
exports.COMPLETE_PAGE='COMPLETE_PAGE';
6+
exports.COMPLETE_TUTORIAL='COMPLETE_TUTORIAL';
157
exports.EDITOR_ACTIONS='EDITOR_ACTIONS';
16-
exports.SHOW_HINT='SHOW_HINT';
17-
exports.SHOW_SOLUTION='SHOW_SOLUTION';
18-
exports.SET_HINT_POSITION='SET_HINT_POSITION';
19-
exports.RUN_TESTS='RUN_TESTS';
8+
exports.GLOBALS_SET='GLOBALS_SET';
9+
exports.HINT_POSITION_SET='HINT_POSITION_SET';
10+
exports.HINT_SHOW='HINT_SHOW';
11+
exports.LOG_TOGGLE='LOG_TOGGLE';
12+
exports.PAGE_SET='PAGE_SET';
13+
exports.POSITION_SET='POSITION_SET';
14+
exports.PROGRESS_SET='PROGRESS_SET';
15+
exports.ROUTE_SET='ROUTE_SET';
16+
exports.SETUP_VERIFY='SETUP_VERIFY';
2017
exports.TEST_COMPLETE='TEST_COMPLETE';
2118
exports.TEST_RESULT='TEST_RESULT';
22-
exports.TOGGLE_LOG='CHECK_LOG';
23-
exports.TOGGLE_ALERT='TOGGLE_ALERT';
24-
exports.REPLAY_ALERT='SHOW_ALERT';
19+
exports.TEST_RUN='TEST_RUN';
20+
exports.TUTORIAL_INFO_SET='TUTORIAL_INFO_SET';
21+
exports.TUTORIALS_LOAD='TUTORIALS_LOAD';
22+
exports.TUTORIAL_UPDATE='TUTORIAL_UPDATE';

‎lib/actions/actions.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ exports.replayAlert = alert_1.replayAlert;
2626
varroutes_1=require('./routes');
2727
exports.setRoute=routes_1.setRoute;
2828
functionsetGlobals(packageJson){
29-
return{type:actionTypes_1.SET_GLOBALS,payload:{packageJson:packageJson}};
29+
return{type:actionTypes_1.GLOBALS_SET,payload:{packageJson:packageJson}};
3030
}
3131
exports.setGlobals=setGlobals;
3232
functionverifySetup(){
33-
return{type:actionTypes_1.VERIFY_SETUP};
33+
return{type:actionTypes_1.SETUP_VERIFY};
3434
}
3535
exports.verifySetup=verifySetup;
3636
functionsetProgress(){
37-
return{type:actionTypes_1.SET_PROGRESS};
37+
return{type:actionTypes_1.PROGRESS_SET};
3838
}
3939
exports.setProgress=setProgress;
4040
functionsetPosition(position){
41-
return{type:actionTypes_1.SET_POSITION,payload:{position:position}};
41+
return{type:actionTypes_1.POSITION_SET,payload:{position:position}};
4242
}
4343
exports.setPosition=setPosition;
4444
functionloadTutorial(tutorial){
@@ -50,6 +50,6 @@ function loadTutorial(tutorial) {
5050
exports.loadTutorial=loadTutorial;
5151
functiontoggleLog(){
5252
varopen=!store_1.store.getState().log.open;
53-
return{type:actionTypes_1.TOGGLE_LOG,payload:{open:open}};
53+
return{type:actionTypes_1.LOG_TOGGLE,payload:{open:open}};
5454
}
5555
exports.toggleLog=toggleLog;

‎lib/actions/alert.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
"use strict";
22
varstore_1=require('../store/store');
3-
varactionTypes_1=require('./actionTypes');
4-
functiontoggleAlert(alert){
3+
var_types_1=require('./_types');
4+
functionalertToggle(alert){
55
varisOpen=store_1.store.getState().alert.open;
66
if(!alert){
77
alert={message:'',action:'',open:false};
88
}
99
else{
1010
alert=Object.assign({},{open:!isOpen},alert);
1111
}
12-
return{type:actionTypes_1.TOGGLE_ALERT,payload:{alert:alert}};
12+
return{type:_types_1.ALERT_TOGGLE,payload:{alert:alert}};
1313
}
14-
exports.toggleAlert=toggleAlert;
15-
functionreplayAlert(){
16-
return{type:actionTypes_1.REPLAY_ALERT};
14+
exports.alertToggle=alertToggle;
15+
functionalertReplay(){
16+
return{type:_types_1.ALERT_REPLAY};
1717
}
18-
exports.replayAlert=replayAlert;
18+
exports.alertReplay=alertReplay;

‎lib/actions/complete.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"use strict";
2+
var_types_1=require('./_types');
3+
varstore_1=require('../store/store');
4+
functioncompletePage(){
5+
varposition=store_1.store.getState().position;
6+
varpageLength=store_1.store.getState().progress.chapters[position.chapter].pages.length;
7+
if(position.page>=pageLength-1){
8+
returncompleteChapter();
9+
}
10+
return{type:_types_1.COMPLETE_PAGE,payload:{position:position}};
11+
}
12+
exports.completePage=completePage;
13+
functioncompleteChapter(){
14+
varchapter=store_1.store.getState().position.chapter;
15+
varchapterLength=store_1.store.getState().progress.chapters.length;
16+
if(chapter>=chapterLength-1){
17+
returncompleteTutorial();
18+
}
19+
return{type:_types_1.COMPLETE_CHAPTER,payload:{chapter:chapter}};
20+
}
21+
exports.completeChapter=completeChapter;
22+
functioncompleteTutorial(){
23+
return{type:_types_1.COMPLETE_TUTORIAL};
24+
}
25+
exports.completeTutorial=completeTutorial;

‎lib/actions/globals.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"use strict";
2+
var_types_1=require('./_types');
3+
functionglobalsSet(packageJson){
4+
return{type:_types_1.GLOBALS_SET,payload:{packageJson:packageJson}};
5+
}
6+
exports.globalsSet=globalsSet;

‎lib/actions/hint.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use strict";
2+
var_types_1=require('./_types');
3+
functionhintPositionSet(hintPosition){
4+
return{type:_types_1.HINT_POSITION_SET,payload:{hintPosition:hintPosition}};
5+
}
6+
exports.hintPositionSet=hintPositionSet;
7+
functionhintShow(){
8+
return{type:_types_1.HINT_SHOW};
9+
}
10+
exports.hintShow=hintShow;

‎lib/actions/page-actions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ var tutorial_package_1 = require('../services/tutorial-package');
55
functionsetPage(selectedPosition){
66
if(selectedPosition===void0){selectedPosition={chapter:0,page:0};}
77
if(selectedPosition.completed){
8-
return{type:actionTypes_1.SET_ROUTE,payload:{route:'final'}};
8+
return{type:actionTypes_1.ROUTE_SET,payload:{route:'final'}};
99
}
1010
varpage=tutorial_package_1.default.getPage(selectedPosition);
1111
vartasks=tutorial_package_1.default.getTasks(selectedPosition);
1212
vartaskTests=[].concat.apply([],tasks.map(function(task){returntask.tests||[];}));
1313
varactions=tasks.map(function(task){returntask.actions||[];});
14-
return{type:actionTypes_1.SET_PAGE,payload:{page:page,tasks:tasks,position:selectedPosition,taskTests:taskTests,actions:actions}};
14+
return{type:actionTypes_1.PAGE_SET,payload:{page:page,tasks:tasks,position:selectedPosition,taskTests:taskTests,actions:actions}};
1515
}
1616
exports.setPage=setPage;
1717
functionnextPage(){

‎lib/actions/page.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"use strict";
2+
var_types_1=require('./_types');
3+
varstore_1=require('../store/store');
4+
vartutorial_package_1=require('../services/tutorial-package');
5+
functionpageNext(){
6+
varposition=store_1.store.getState().position;
7+
varnextPosition=tutorial_package_1.default.getNextPosition(position);
8+
returnpageSet(nextPosition);
9+
}
10+
exports.pageNext=pageNext;
11+
functionpageSet(selectedPosition){
12+
if(selectedPosition===void0){selectedPosition={chapter:0,page:0};}
13+
if(selectedPosition.completed){
14+
return{type:_types_1.ROUTE_SET,payload:{route:'final'}};
15+
}
16+
varpage=tutorial_package_1.default.getPage(selectedPosition);
17+
vartasks=tutorial_package_1.default.getTasks(selectedPosition);
18+
vartaskTests=[].concat.apply([],tasks.map(function(task){returntask.tests||[];}));
19+
varactions=tasks.map(function(task){returntask.actions||[];});
20+
return{type:_types_1.PAGE_SET,payload:{page:page,tasks:tasks,position:selectedPosition,taskTests:taskTests,actions:actions}};
21+
}
22+
exports.pageSet=pageSet;

‎lib/actions/position.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"use strict";
2+
var_types_1=require('./_types');
3+
functionpositionSet(position){
4+
return{type:_types_1.POSITION_SET,payload:{position:position}};
5+
}
6+
exports.positionSet=positionSet;

‎lib/actions/progress-actions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function pageComplete() {
77
if(position.page>=pageLength-1){
88
returnchapterComplete();
99
}
10-
return{type:actionTypes_1.PAGE_COMPLETE,payload:{position:position}};
10+
return{type:actionTypes_1.COMPLETE_PAGE,payload:{position:position}};
1111
}
1212
exports.pageComplete=pageComplete;
1313
functionchapterComplete(){
@@ -16,10 +16,10 @@ function chapterComplete() {
1616
if(chapter>=chapterLength-1){
1717
returnprojectComplete();
1818
}
19-
return{type:actionTypes_1.CHAPTER_COMPLETE,payload:{chapter:chapter}};
19+
return{type:actionTypes_1.COMPLETE_CHAPTER,payload:{chapter:chapter}};
2020
}
2121
exports.chapterComplete=chapterComplete;
2222
functionprojectComplete(){
23-
return{type:actionTypes_1.PROJECT_COMPLETE};
23+
return{type:actionTypes_1.COMPLETE_TUTORIAL};
2424
}
2525
exports.projectComplete=projectComplete;

‎lib/actions/route.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"use strict";
2+
varstore_1=require('../store/store');
3+
var_types_1=require('./_types');
4+
var_actions_1=require('./_actions');
5+
varprevious=null;
6+
functionsetRoute(route){
7+
if(route&&route!==previous){
8+
switch(route){
9+
case'tutorials':
10+
store_1.store.dispatch(_actions_1.tutorialsFind());
11+
}
12+
previous=route;
13+
return{type:_types_1.ROUTE_SET,payload:{route:route}};
14+
}
15+
}
16+
exports.setRoute=setRoute;

‎lib/actions/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function setRoute(route) {
1010
store_1.store.dispatch(actions_1.loadTutorials());
1111
}
1212
previous=route;
13-
return{type:actionTypes_1.SET_ROUTE,payload:{route:route}};
13+
return{type:actionTypes_1.ROUTE_SET,payload:{route:route}};
1414
}
1515
}
1616
exports.setRoute=setRoute;

‎lib/actions/setup.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"use strict";
2+
var_types_1=require('./_types');
3+
functionsetupVerify(){
4+
return{type:_types_1.SETUP_VERIFY};
5+
}
6+
exports.setupVerify=setupVerify;

‎lib/actions/task-actions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
varactionTypes_1=require('./actionTypes');
33
varstore_1=require('../store/store');
44
functionshowHint(){
5-
return{type:actionTypes_1.SHOW_HINT};
5+
return{type:actionTypes_1.HINT_SHOW};
66
}
77
exports.showHint=showHint;
88
functionrunTests(){
9-
return{type:actionTypes_1.RUN_TESTS};
9+
return{type:actionTypes_1.TEST_RUN};
1010
}
1111
exports.runTests=runTests;
1212
functiontestResult(result){
@@ -19,6 +19,6 @@ function testComplete() {
1919
}
2020
exports.testComplete=testComplete;
2121
functionsetHintPosition(hintPosition){
22-
return{type:actionTypes_1.SET_HINT_POSITION,payload:{hintPosition:hintPosition}};
22+
return{type:actionTypes_1.HINT_POSITION_SET,payload:{hintPosition:hintPosition}};
2323
}
2424
exports.setHintPosition=setHintPosition;

‎lib/actions/test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"use strict";
2+
var_types_1=require('./_types');
3+
varstore_1=require('../store/store');
4+
functiontestRun(){
5+
return{type:_types_1.TEST_RUN};
6+
}
7+
exports.testRun=testRun;
8+
functiontestResult(result){
9+
varactions=store_1.store.getState().editorActions;
10+
return{type:_types_1.TEST_RESULT,payload:{result:result,actions:actions}};
11+
}
12+
exports.testResult=testResult;
13+
functiontestComplete(){
14+
return{type:_types_1.TEST_COMPLETE};
15+
}
16+
exports.testComplete=testComplete;

‎lib/actions/tutorial.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"use strict";
2+
var_types_1=require('./_types');
3+
functiontutorialSet(){
4+
return{type:_types_1.TUTORIAL_SET};
5+
}
6+
exports.tutorialSet=tutorialSet;
7+
functiontutorialUpdate(name){
8+
return{type:_types_1.TUTORIAL_UPDATE,payload:{name:name}};
9+
}
10+
exports.tutorialUpdate=tutorialUpdate;
11+
functiontutorialsFind(){
12+
return{type:_types_1.TUTORIALS_FIND};
13+
}
14+
exports.tutorialsFind=tutorialsFind;

‎lib/actions/tutorials.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"use strict";
22
varactionTypes_1=require('./actionTypes');
33
functionsetTutorialInfo(){
4-
return{type:actionTypes_1.SET_TUTORIAL_INFO};
4+
return{type:actionTypes_1.TUTORIAL_INFO_SET};
55
}
66
exports.setTutorialInfo=setTutorialInfo;
77
functionloadTutorials(){
8-
return{type:actionTypes_1.LOAD_TUTORIALS};
8+
return{type:actionTypes_1.TUTORIALS_LOAD};
99
}
1010
exports.loadTutorials=loadTutorials;
1111
functionupdateTutorial(name){
12-
return{type:actionTypes_1.UPDATE_TUTORIAL,payload:{name:name}};
12+
return{type:actionTypes_1.TUTORIAL_UPDATE,payload:{name:name}};
1313
}
1414
exports.updateTutorial=updateTutorial;

‎lib/atom/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var render_1 = require('../components/render');
33
varpolyfills_1=require('../services/polyfills');
44
varsubscriptions_1=require('./subscriptions');
55
varstore_1=require('../store/store');
6-
varactions_1=require('../actions/actions');
6+
var_actions_1=require('../actions/_actions');
77
functionsetDir(){
88
if(atom.project.rootDirectories.length>0){
99
returnatom.project.rootDirectories[0].path;
@@ -22,7 +22,7 @@ var Main = (function () {
2222
dir:setDir(),
2323
win:setWin()
2424
};
25-
store_1.store.dispatch(actions_1.verifySetup());
25+
store_1.store.dispatch(_actions_1.setupVerify());
2626
this.root=render_1.initRoot();
2727
}
2828
Main.prototype.activate=function(){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp