Skip to content

Commit d34e3d0

Browse files
committed
remove RAT, break ALERT_TOGGLE into OPEN & CLOSE
1 parent ea9cc35 commit d34e3d0

File tree

22 files changed

+50
-55
lines changed

22 files changed

+50
-55
lines changed

lib/actions/_types.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"use strict";
22
exports.ALERT_REPLAY = 'ALERT_REPLAY';
3-
exports.ALERT_TOGGLE = 'ALERT_TOGGLE';
3+
exports.ALERT_OPEN = 'ALERT_OPEN';
4+
exports.ALERT_CLOSE = 'ALERT_CLOSE';
45
exports.COMPLETE_PAGE = 'COMPLETE_PAGE';
56
exports.COMPLETE_TUTORIAL = 'COMPLETE_TUTORIAL';
67
exports.DEVTOOLS_TOGGLE = 'DEVTOOLS_TOGGLE';
78
exports.HINT_POSITION_SET = 'HINT_POSITION_SET';
89
exports.PAGE_SET = 'PAGE_SET';
9-
exports.PAGE_POSITION_SET = 'POSITION_SET';
1010
exports.PROGRESS_LOAD = 'PROGRESS_LOAD';
1111
exports.PROGRESS_PAGE_POSITION_LOAD = 'PROGRESS_PAGE_POSITION_LOAD';
1212
exports.QUIT = 'QUIT';

lib/actions/alert.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
"use strict";
22
var _types_1 = require('./_types');
3-
function alertToggle(alert) {
3+
function alertOpen(alert) {
44
return function (dispatch, getState) {
5-
dispatch({ type: _types_1.ALERT_TOGGLE, payload: { alert: alert } });
5+
dispatch({ type: _types_1.ALERT_OPEN, payload: { alert: alert } });
66
};
77
}
8-
exports.alertToggle = alertToggle;
8+
exports.alertOpen = alertOpen;
99
function alertReplay() {
1010
return { type: _types_1.ALERT_REPLAY };
1111
}
1212
exports.alertReplay = alertReplay;
13+
function alertClose() {
14+
return { type: _types_1.ALERT_CLOSE };
15+
}
16+
exports.alertClose = alertClose;

lib/actions/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22
var alert_1 = require('./alert');
3-
exports.alertToggle = alert_1.alertToggle;
3+
exports.alertOpen = alert_1.alertOpen;
4+
exports.alertClose = alert_1.alertClose;
45
exports.alertReplay = alert_1.alertReplay;
56
var progress_1 = require('./progress');
67
exports.progressLoad = progress_1.progressLoad;
@@ -12,7 +13,6 @@ exports.hintPositionSet = hint_1.hintPositionSet;
1213
var page_1 = require('./page');
1314
exports.pageSet = page_1.pageSet;
1415
exports.pageNext = page_1.pageNext;
15-
exports.pagePositionSet = page_1.pagePositionSet;
1616
var route_1 = require('./route');
1717
exports.routeSet = route_1.routeSet;
1818
var setup_1 = require('./setup');

lib/actions/page.js

-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,3 @@ function pageSet(pagePosition) {
3030
};
3131
}
3232
exports.pageSet = pageSet;
33-
function pagePositionSet(pagePosition) {
34-
return { type: _types_1.PAGE_POSITION_SET, payload: { pagePosition: pagePosition } };
35-
}
36-
exports.pagePositionSet = pagePositionSet;

lib/actions/progress.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function completePage(completed) {
2828
dispatch(completeTutorial());
2929
}
3030
else {
31-
dispatch(alert_1.alertToggle({
31+
dispatch(alert_1.alertOpen({
3232
message: "Page " + (pagePosition + 1) + " Complete",
3333
action: 'PASS',
3434
}));
@@ -45,7 +45,7 @@ function completeTutorial(completed) {
4545
return function (dispatch, getState) {
4646
var tutorial = getState().tutorial;
4747
dispatch({ type: _types_1.COMPLETE_TUTORIAL, payload: { tutorial: tutorial, completed: completed } });
48-
dispatch('ALER'({
48+
dispatch(alert_1.alertOpen({
4949
message: 'Tutorial Complete',
5050
action: 'PASS',
5151
}));

lib/actions/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function testResult(result) {
3535
});
3636
}
3737
dispatch({ type: _types_1.TEST_RESULT, payload: { result: result, taskActions: taskActions } });
38-
dispatch(alert_1.alertToggle(alert));
38+
dispatch(alert_1.alertOpen(alert));
3939
};
4040
}
4141
exports.testResult = testResult;

lib/actions/tutorial.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function tutorialUpdate(name) {
2020
duration: 3000,
2121
};
2222
dispatch({ type: _types_1.TUTORIAL_UPDATE, payload: { name: name } });
23-
dispatch(alert_1.alertToggle(alert));
23+
dispatch(alert_1.alertOpen(alert));
2424
};
2525
}
2626
exports.tutorialUpdate = tutorialUpdate;

lib/components/Alert/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ var Alert = (function (_super) {
2727
_super.apply(this, arguments);
2828
}
2929
Alert.prototype.render = function () {
30-
var _a = this.props, alert = _a.alert, alertToggle = _a.alertToggle;
30+
var _a = this.props, alert = _a.alert, close = _a.close;
3131
var action = alert.action, message = alert.message, open = alert.open, duration = alert.duration;
32-
return (React.createElement(Snackbar_1.default, {className: "cr-alert " + action, open: open, message: message || '', action: action || 'NOTE', autoHideDuration: duration || 2000, onRequestClose: alertToggle}));
32+
return (React.createElement(Snackbar_1.default, {className: "cr-alert " + action, open: open, message: message || '', action: action || 'NOTE', autoHideDuration: duration || 2000, onRequestClose: close}));
3333
};
3434
Alert = __decorate([
3535
react_redux_1.connect(null, function (dispatch) {
3636
return {
37-
alertToggle: function () { return dispatch(actions_1.alertToggle({ open: false })); }
37+
close: function () { return dispatch(actions_1.alertClose()); }
3838
};
3939
}),
4040
__metadata('design:paramtypes', [])

lib/reducers/alert/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ function alertReducer(alert, action) {
2828
switch (action.type) {
2929
case _types_1.ALERT_REPLAY:
3030
return setAlert(current);
31-
case _types_1.ALERT_TOGGLE:
31+
case _types_1.ALERT_OPEN:
3232
return setAlert(action.payload.alert);
33+
case _types_1.ALERT_CLOSE:
34+
return Object.assign({}, alert, { open: false });
3335
default:
3436
return alert;
3537
}

lib/reducers/page-position/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ function pagePositionReducer(pagePosition, action) {
77
var pages = action.payload.progress.pages;
88
var firstFail = pages.indexOf(false);
99
return firstFail < 0 ? pages.length - 1 : firstFail;
10-
case _types_1.PAGE_SET:
1110
case _types_1.PAGE_POSITION_SET:
1211
return action.payload.pagePosition;
1312
default:

lib/store/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"use strict";
22
var redux_1 = require('redux');
3-
var redux_action_thunk_1 = require('redux-action-thunk');
43
var reducers_1 = require('../reducers');
54
var createLogger = require('redux-logger');
6-
var middlewares = [redux_action_thunk_1.ratMiddleware];
5+
var redux_thunk_1 = require('redux-thunk');
6+
var middlewares = [redux_thunk_1.default];
77
var devMode = true;
88
if (devMode) {
99
var logger = createLogger();

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"react-redux": "4.4.5",
4747
"react-tap-event-plugin": "1.0.0",
4848
"redux": "3.5.2",
49-
"redux-action-thunk": "0.3.0",
5049
"redux-logger": "2.6.1",
5150
"redux-thunk": "2.1.0"
5251
},

src/actions/_types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const ALERT_REPLAY = 'ALERT_REPLAY';
2-
export const ALERT_TOGGLE = 'ALERT_TOGGLE';
2+
export const ALERT_OPEN = 'ALERT_OPEN';
3+
export const ALERT_CLOSE = 'ALERT_CLOSE';
34
export const COMPLETE_PAGE = 'COMPLETE_PAGE';
45
export const COMPLETE_TUTORIAL = 'COMPLETE_TUTORIAL';
56
export const DEVTOOLS_TOGGLE = 'DEVTOOLS_TOGGLE';

src/actions/alert.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
import {ALERT_REPLAY, ALERT_TOGGLE} from './_types';
1+
import {ALERT_REPLAY, ALERT_OPEN, ALERT_CLOSE} from './_types';
22

3-
export function alertToggle(alert: Object): ReduxThunk.ThunkInterface {
3+
export function alertOpen(alert: Object): ReduxThunk.ThunkInterface {
44
return (dispatch, getState): void => {
5-
dispatch({ type: ALERT_TOGGLE, payload: { alert } });
5+
dispatch({ type: ALERT_OPEN, payload: { alert } });
66
};
77
}
88

99
export function alertReplay(): Action {
1010
return { type: ALERT_REPLAY };
1111
}
1212

13-
// import {rat} from 'redux-action-thunk';
14-
//
15-
// rat.add('ALERT_TOGGLE', (dispatch, getState) => (alert) => {
16-
// dispatch({ type: 'ALERT_TOGGLE', payload: { alert } });
17-
// });
18-
//
19-
// rat.add('ALERT_REPLAY');
13+
export function alertClose(): Action {
14+
return { type: ALERT_CLOSE };
15+
}

src/actions/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
export {alertToggle, alertReplay} from './alert';
2-
// import './alert';
1+
export {alertOpen, alertClose, alertReplay} from './alert';
32
export {
43
progressLoad, completePage, completeTutorial,
54
progressPagePositionLoad

src/actions/progress.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
PROGRESS_PAGE_POSITION_LOAD, PROGRESS_LOAD, COMPLETE_PAGE, COMPLETE_TUTORIAL
33
} from './_types';
4-
import {alertToggle} from './alert';
4+
import {alertOpen} from './alert';
55
import {testRun} from './test';
66

77
export function progressPagePositionLoad(): ReduxThunk.ThunkInterface {
@@ -30,7 +30,7 @@ export function completePage(completed = true): ReduxThunk.ThunkInterface {
3030
if (progress.pages.every(x => x.completed)) {
3131
dispatch(completeTutorial());
3232
} else {
33-
dispatch(alertToggle({
33+
dispatch(alertOpen({
3434
message: `Page ${pagePosition + 1} Complete`,
3535
action: 'PASS',
3636
}));
@@ -45,7 +45,7 @@ export function completeTutorial(completed = true): ReduxThunk.ThunkInterface {
4545
return (dispatch, getState): void => {
4646
const {tutorial} = getState();
4747
dispatch({ type: COMPLETE_TUTORIAL, payload: { tutorial, completed } });
48-
dispatch('ALER'({
48+
dispatch(alertOpen({
4949
message: 'Tutorial Complete',
5050
action: 'PASS',
5151
}));

src/actions/test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
} from './_types';
44
import {hintPositionSet} from './hint';
55
import {completePage} from './progress';
6-
import {alertToggle} from './alert';
6+
import {alertOpen} from './alert';
77

88
export function testRun(): ReduxThunk.ThunkInterface {
99
return (dispatch, getState): void => {
@@ -39,7 +39,7 @@ export function testResult(result: Test.Result): ReduxThunk.ThunkInterface {
3939
});
4040
}
4141
dispatch({ type: TEST_RESULT, payload: { result, taskActions } });
42-
dispatch(alertToggle(alert));
42+
dispatch(alertOpen(alert));
4343
};
4444
}
4545

src/actions/tutorial.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
} from './_types';
44
import {progressLoad} from './progress';
55
import {routeSet} from './route';
6-
import {alertToggle} from './alert';
6+
import {alertOpen} from './alert';
77

88
export function tutorialSet(name: string): ReduxThunk.ThunkInterface {
99
return (dispatch, getState): void => {
@@ -22,7 +22,7 @@ export function tutorialUpdate(name: string): ReduxThunk.ThunkInterface {
2222
duration: 3000,
2323
};
2424
dispatch({ type: TUTORIAL_UPDATE, payload: { name } });
25-
dispatch(alertToggle(alert));
25+
dispatch(alertOpen(alert));
2626
};
2727
}
2828

src/components/Alert/index.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import {connect} from 'react-redux';
33
import Snackbar from 'material-ui/Snackbar';
4-
import {alertToggle} from '../../actions';
4+
import {alertClose} from '../../actions';
55

66
const defaultAlert = {
77
message: '',
@@ -10,14 +10,14 @@ const defaultAlert = {
1010

1111
@connect(null, dispatch => {
1212
return {
13-
alertToggle: () => dispatch(alertToggle({open: false}))
13+
close: () => dispatch(alertClose())
1414
};
1515
})
1616
export default class Alert extends React.Component<{
17-
alert: CR.Alert, alertToggle?: any
17+
alert: CR.Alert, close?: any
1818
}, {}> {
1919
render() {
20-
const {alert, alertToggle} = this.props;
20+
const {alert, close} = this.props;
2121
const {action, message, open, duration} = alert;
2222
return (
2323
<Snackbar
@@ -26,7 +26,7 @@ export default class Alert extends React.Component<{
2626
message={message || ''}
2727
action={action || 'NOTE'}
2828
autoHideDuration={duration || 2000}
29-
onRequestClose={alertToggle}
29+
onRequestClose={close}
3030
/>
3131
);
3232
}

src/reducers/alert/index.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
2-
ALERT_REPLAY, ALERT_TOGGLE, TUTORIAL_UPDATE,
3-
TEST_RESULT, COMPLETE_PAGE, COMPLETE_TUTORIAL
2+
ALERT_REPLAY, ALERT_OPEN, ALERT_CLOSE
43
} from '../../actions/_types';
54

65
const _alert: CR.Alert = {
@@ -25,7 +24,6 @@ const colors = {
2524
let current: CR.Alert = _alert;
2625

2726
function setAlert(a: CR.Alert): CR.Alert {
28-
2927
const color = colors[a.action] || colors.NOTE;
3028
let statusBarAlert = <HTMLElement>document.getElementsByClassName('cr-alert-replay')[0];
3129
statusBarAlert.style.color = color;
@@ -40,9 +38,12 @@ export default function alertReducer(
4038
case ALERT_REPLAY:
4139
return setAlert(current);
4240

43-
case ALERT_TOGGLE:
41+
case ALERT_OPEN:
4442
return setAlert(action.payload.alert);
4543

44+
case ALERT_CLOSE:
45+
return Object.assign({}, alert, {open: false});
46+
4647
default:
4748
return alert;
4849
}

src/reducers/tutorial-list/update.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import commandLine from '../../services/command-line';
2-
// import {alertToggle} from '../../actions';
32
import {tutorialsFind} from '../../actions';
43

54
export function tutorialUpdate(name: string): void {

src/store/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { applyMiddleware, createStore } from 'redux';
2-
import {ratMiddleware} from 'redux-action-thunk';
32
import reducer from '../reducers';
43
import * as createLogger from 'redux-logger';
54
import thunk from 'redux-thunk';
65

76
// const middlewares = [ramMiddleware];
8-
const middlewares = [ratMiddleware];
7+
const middlewares = [thunk];
98

109
const devMode = true;
1110
if (devMode) {

0 commit comments

Comments
 (0)