Skip to content

Commit e9b224e

Browse files
committed
window module, various fixes
1 parent 3f197cf commit e9b224e

File tree

24 files changed

+75
-104
lines changed

24 files changed

+75
-104
lines changed

lib/actions/_types.js

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ exports.HINT_POSITION_SET = 'HINT_POSITION_SET';
66
exports.PAGE_SET = 'PAGE_SET';
77
exports.PROGRESS_LOAD = 'PROGRESS_LOAD';
88
exports.PROGRESS_PAGE_POSITION_LOAD = 'PROGRESS_PAGE_POSITION_LOAD';
9-
exports.QUIT = 'QUIT';
109
exports.ROUTE_SET = 'ROUTE_SET';
1110
exports.TEST_SAVE = 'TEST_SAVE';
1211
exports.SETUP_PACKAGE = 'SETUP_PACKAGE';
@@ -17,4 +16,3 @@ exports.TEST_RUN = 'TEST_RUN';
1716
exports.TUTORIAL_SET = 'TUTORIAL_SET';
1817
exports.TUTORIAL_UPDATE = 'TUTORIAL_UPDATE';
1918
exports.TUTORIALS_FIND = 'TUTORIALS_FIND';
20-
exports.WINDOW_TOGGLE = 'WINDOW_TOGGLE';

lib/actions/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,4 @@ exports.tutorialsFind = tutorial_1.tutorialsFind;
2828
exports.tutorialSet = tutorial_1.tutorialSet;
2929
exports.tutorialUpdate = tutorial_1.tutorialUpdate;
3030
var toggle_1 = require('./toggle');
31-
exports.windowToggle = toggle_1.windowToggle;
3231
exports.devToolsToggle = toggle_1.devToolsToggle;
33-
exports.quit = toggle_1.quit;

lib/actions/toggle.js

-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
"use strict";
22
var _types_1 = require('./_types');
3-
function windowToggle() {
4-
return { type: _types_1.WINDOW_TOGGLE };
5-
}
6-
exports.windowToggle = windowToggle;
73
function devToolsToggle() {
84
return { type: _types_1.DEVTOOLS_TOGGLE };
95
}
106
exports.devToolsToggle = devToolsToggle;
11-
function quit() {
12-
return { type: _types_1.QUIT };
13-
}
14-
exports.quit = quit;

lib/atom/subscriptions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var subscriptions = null;
77
function onActivate() {
88
subscriptions = new CompositeDisposable;
99
subscriptions.add(atom.commands.add('atom-workspace', {
10-
'cr-viewer:toggle': function () { return store_1.default.dispatch(actions_1.windowToggle()); }
10+
'cr-viewer:toggle': function () { return store_1.default.dispatch({ type: 'WINDOW_TOGGLE' }); }
1111
}));
1212
atom.workspace.observeTextEditors(function (editor) {
1313
subscriptions.add(editor.onDidSave(function () {

lib/components/AppMenu/Quit/index.js

+2-34
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,11 @@
11
"use strict";
2-
var __extends = (this && this.__extends) || function (d, b) {
3-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4-
function __() { this.constructor = d; }
5-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6-
};
7-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
8-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11-
return c > 3 && r && Object.defineProperty(target, key, r), r;
12-
};
13-
var __metadata = (this && this.__metadata) || function (k, v) {
14-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
15-
};
162
var React = require('react');
17-
var react_redux_1 = require('react-redux');
18-
var actions_1 = require('../../../actions');
193
var MenuItem_1 = require('material-ui/MenuItem');
4+
var subscriptions_1 = require('../../../atom/subscriptions');
205
var styles = {
216
textAlign: 'center',
227
padding: '0px 2px',
238
};
24-
var Quit = (function (_super) {
25-
__extends(Quit, _super);
26-
function Quit() {
27-
_super.apply(this, arguments);
28-
}
29-
Quit.prototype.render = function () {
30-
return (React.createElement(MenuItem_1.default, {style: styles, key: 'quit', onClick: this.props.quit}, "quit"));
31-
};
32-
Quit = __decorate([
33-
react_redux_1.connect(null, function (dispatch) {
34-
return {
35-
quit: function () { return dispatch(actions_1.quit()); }
36-
};
37-
}),
38-
__metadata('design:paramtypes', [])
39-
], Quit);
40-
return Quit;
41-
}(React.Component));
9+
var Quit = function () { return (React.createElement(MenuItem_1.default, {style: styles, key: 'quit', onClick: subscriptions_1.onDeactivate}, "quit")); };
4210
Object.defineProperty(exports, "__esModule", { value: true });
4311
exports.default = Quit;

lib/modules/alert/Alert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var Alert = (function (_super) {
3333
Alert.prototype.render = function () {
3434
var _a = this.props, alert = _a.alert, close = _a.close;
3535
var action = alert.action, message = alert.message, open = alert.open, duration = alert.duration, color = alert.color;
36-
return (React.createElement(Snackbar_1.default, {style: styles, bodyStyle: { color: color }, open: open, message: message || '', action: action || '', autoHideDuration: duration || 2000, onRequestClose: close}));
36+
return (React.createElement(Snackbar_1.default, {style: styles, bodyStyle: { color: color }, open: open, message: message || '', action: action || '', autoHideDuration: duration || 2000, onActionTouchTap: close, onRequestClose: close}));
3737
};
3838
Alert = __decorate([
3939
react_redux_1.connect(null, function (dispatch) {

lib/modules/window/actions.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"use strict";
2+
var types_1 = require('./types');
3+
function windowToggle() {
4+
return { type: types_1.WINDOW_TOGGLE };
5+
}
6+
exports.windowToggle = windowToggle;

lib/modules/window/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"use strict";
2+
var reducer_1 = require('./reducer');
3+
exports.reducer = reducer_1.default;
4+
var actions_1 = require('./actions');
5+
exports.windowToggle = actions_1.windowToggle;

lib/modules/window/reducer.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use strict";
2+
var types_1 = require('./types');
3+
function windowToggle(open, action) {
4+
if (open === void 0) { open = false; }
5+
switch (action.type) {
6+
case types_1.WINDOW_TOGGLE:
7+
return !open;
8+
default:
9+
return open;
10+
}
11+
}
12+
Object.defineProperty(exports, "__esModule", { value: true });
13+
exports.default = windowToggle;

lib/modules/window/types.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"use strict";
2+
exports.WINDOW_TOGGLE = 'WINDOW_TOGGLE';

lib/reducers/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22
var redux_1 = require('redux');
33
var alert_1 = require('../modules/alert');
4+
var window_1 = require('../modules/window');
45
var checks_1 = require('./checks');
56
var devTools_toggle_1 = require('./devTools-toggle');
67
var dir_1 = require('./dir');
@@ -17,11 +18,10 @@ var task_tests_1 = require('./task-tests');
1718
var test_run_1 = require('./test-run');
1819
var tutorial_1 = require('./tutorial');
1920
var tutorial_list_1 = require('./tutorial-list');
20-
var window_toggle_1 = require('./window-toggle');
2121
Object.defineProperty(exports, "__esModule", { value: true });
2222
exports.default = redux_1.combineReducers({
2323
alert: alert_1.reducer, checks: checks_1.default, devToolsToggle: devTools_toggle_1.default, dir: dir_1.default, hintPosition: hint_position_1.default,
2424
packageJson: package_json_1.default, page: page_1.default, pagePosition: page_position_1.default, progress: progress_1.default, route: route_1.default, tasks: tasks_1.default,
2525
tutorial: tutorial_1.default, tutorialList: tutorial_list_1.default,
26-
taskActions: task_actions_1.default, taskPosition: task_position_1.default, taskTests: task_tests_1.default, testRun: test_run_1.default, windowToggle: window_toggle_1.default
26+
taskActions: task_actions_1.default, taskPosition: task_position_1.default, taskTests: task_tests_1.default, testRun: test_run_1.default, windowToggle: window_1.reducer
2727
});

src/actions/_types.ts

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export const HINT_POSITION_SET = 'HINT_POSITION_SET';
55
export const PAGE_SET = 'PAGE_SET';
66
export const PROGRESS_LOAD = 'PROGRESS_LOAD';
77
export const PROGRESS_PAGE_POSITION_LOAD = 'PROGRESS_PAGE_POSITION_LOAD';
8-
export const QUIT = 'QUIT';
98
export const ROUTE_SET = 'ROUTE_SET';
109
export const TEST_SAVE = 'TEST_SAVE';
1110
export const SETUP_PACKAGE = 'SETUP_PACKAGE';
@@ -16,4 +15,3 @@ export const TEST_RUN = 'TEST_RUN';
1615
export const TUTORIAL_SET = 'TUTORIAL_SET';
1716
export const TUTORIAL_UPDATE = 'TUTORIAL_UPDATE';
1817
export const TUTORIALS_FIND = 'TUTORIALS_FIND';
19-
export const WINDOW_TOGGLE = 'WINDOW_TOGGLE';

src/actions/toggle.ts

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
import {WINDOW_TOGGLE, DEVTOOLS_TOGGLE, QUIT} from './_types';
2-
3-
export function windowToggle(): Action {
4-
return { type: WINDOW_TOGGLE };
5-
}
1+
import {DEVTOOLS_TOGGLE} from './_types';
62

73
export function devToolsToggle(): Action {
84
return { type: DEVTOOLS_TOGGLE };
95
}
10-
11-
export function quit(): Action {
12-
return { type: QUIT };
13-
}

src/atom/subscriptions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const CompositeDisposable = require('atom').CompositeDisposable;
22
import store from '../store';
3-
import {testRun, alertReplay, windowToggle} from '../actions';
3+
import {testRun, alertReplay} from '../actions';
44
import Root from '../components/root';
55

66
let subscriptions = null;
@@ -11,7 +11,7 @@ export function onActivate(): AtomCore.Disposable {
1111

1212
subscriptions.add(
1313
atom.commands.add('atom-workspace', {
14-
'cr-viewer:toggle': () => store.dispatch(windowToggle())
14+
'cr-viewer:toggle': () => store.dispatch({ type: 'WINDOW_TOGGLE'})
1515
})
1616
);
1717

src/components/AppMenu/Quit/index.tsx

+11-20
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,20 @@ import * as React from 'react';
22
import {connect} from 'react-redux';
33
import {quit} from '../../../actions';
44
import MenuItem from 'material-ui/MenuItem';
5+
import {onDeactivate} from '../../../atom/subscriptions';
56

67
const styles = {
78
textAlign: 'center',
89
padding: '0px 2px',
910
};
1011

11-
@connect(null, (dispatch) => {
12-
return {
13-
quit: () => dispatch(quit())
14-
};
15-
})
16-
export default class Quit extends React.Component<{
17-
quit?: any
18-
}, {}> {
19-
render() {
20-
return (
21-
<MenuItem
22-
style={styles}
23-
key='quit'
24-
onClick={this.props.quit}
25-
>
26-
quit
27-
</MenuItem>
28-
);
29-
}
30-
}
12+
const Quit = () => (
13+
<MenuItem
14+
style={styles}
15+
key='quit'
16+
onClick={onDeactivate}
17+
>
18+
quit
19+
</MenuItem>
20+
);
21+
export default Quit;

src/components/AppMenu/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import AppBar from 'material-ui/AppBar';
33
import CloseWindow from './CloseWindow';
44
import menuRight from './menuRight';
5+
import {onDeactivate} from '../../atom/subscriptions';
56

67
const styles = {
78
zIndex: '1 !important'

src/modules/alert/Alert.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default class Alert extends React.Component<{
3232
message={message || ''}
3333
action={action || ''}
3434
autoHideDuration={duration || 2000}
35+
onActionTouchTap={close}
3536
onRequestClose={close}
3637
/>
3738
);

src/modules/window/actions.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {WINDOW_TOGGLE} from './types';
2+
3+
export function windowToggle(): Action {
4+
return { type: WINDOW_TOGGLE };
5+
}

src/modules/window/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {default as reducer} from './reducer';
2+
export {windowToggle} from './actions';

src/modules/window/reducer.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {WINDOW_TOGGLE} from './types';
2+
3+
export default function windowToggle(
4+
open = false, action: Action
5+
): boolean {
6+
switch (action.type) {
7+
8+
case WINDOW_TOGGLE:
9+
return !open;
10+
11+
default:
12+
return open;
13+
}
14+
}

src/modules/window/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const WINDOW_TOGGLE = 'WINDOW_TOGGLE';

src/reducers/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {combineReducers} from 'redux';
22

33
import {reducer as alert} from '../modules/alert';
4+
import {reducer as windowToggle} from '../modules/window';
45
import checks from './checks';
56
import devToolsToggle from './devTools-toggle';
67
import dir from './dir';
@@ -17,7 +18,6 @@ import taskTests from './task-tests';
1718
import testRun from './test-run';
1819
import tutorial from './tutorial';
1920
import tutorialList from './tutorial-list';
20-
import windowToggle from './window-toggle';
2121

2222
export default combineReducers({
2323
alert, checks, devToolsToggle, dir, hintPosition,

src/reducers/window-toggle/index.ts

-19
This file was deleted.

tsconfig.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
"src/modules/alert/index.ts",
8080
"src/modules/alert/reducer.ts",
8181
"src/modules/alert/types.ts",
82+
"src/modules/window/actions.ts",
83+
"src/modules/window/index.ts",
84+
"src/modules/window/reducer.ts",
85+
"src/modules/window/types.ts",
8286
"src/reducers/checks/action-setup.ts",
8387
"src/reducers/checks/action-system.ts",
8488
"src/reducers/checks/check-system.ts",
@@ -112,7 +116,6 @@
112116
"src/reducers/tutorial/config-paths.ts",
113117
"src/reducers/tutorial/index.ts",
114118
"src/reducers/tutorial/tutorial-config.ts",
115-
"src/reducers/window-toggle/index.ts",
116119
"src/services/command-line.ts",
117120
"src/services/exists.ts",
118121
"src/services/polyfills.ts",

0 commit comments

Comments
 (0)