Skip to content

Commit 85ce2d9

Browse files
committed
alert on update tutorial
1 parent 63f7bce commit 85ce2d9

File tree

16 files changed

+98
-86
lines changed

16 files changed

+98
-86
lines changed

lib/components/AppMenu/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var AppBar_1 = require('material-ui/AppBar');
44
var menuIconLeft_1 = require('./menuIconLeft');
55
var menuRight_1 = require('./menuRight');
66
var styles = {
7-
zIndex: '999 !important'
7+
zIndex: '1 !important'
88
};
99
exports.AppMenu = function (_a) {
1010
var route = _a.route;

lib/components/Page/Task/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ exports.Task = function (_a) {
2828
var task = _a.task, taskPosition = _a.taskPosition, index = _a.index, testRun = _a.testRun;
2929
var backgroundColor = getStatus(index, taskPosition, testRun);
3030
var currentTask = taskPosition === index;
31-
return (React.createElement(List_1.ListItem, {key: index, style: Object.assign({}, styles, { backgroundColor: backgroundColor })}, taskCheckbox_1.taskCheckbox(currentTask, testRun), React.createElement("span", {style: indexStyles}, index + 1, "."), React.createElement("div", {style: descriptionStyles}, React.createElement(index_1.Markdown, null, task.description))));
31+
return (React.createElement(List_1.ListItem, {key: index, style: Object.assign({}, styles, { backgroundColor: backgroundColor })}, taskCheckbox_1.taskCheckbox(task, testRun), React.createElement("span", {style: indexStyles}, index + 1, "."), React.createElement("div", {style: descriptionStyles}, React.createElement(index_1.Markdown, null, task.description))));
3232
};

lib/components/Tutorials/UpdateTutorial/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ var UpdateTutorial = (function (_super) {
2828
_super.apply(this, arguments);
2929
}
3030
UpdateTutorial.prototype.render = function () {
31-
var _a = this.props, name = _a.name, tutorialUpdate = _a.tutorialUpdate;
32-
return (React.createElement(update_1.default, {style: styles, color: colors_1.pink500, onTouchTap: tutorialUpdate.bind(this, name)}));
31+
var _a = this.props, tutorial = _a.tutorial, tutorialUpdate = _a.tutorialUpdate;
32+
return (React.createElement("span", null, React.createElement(update_1.default, {style: styles, color: colors_1.pink500, onTouchTap: tutorialUpdate.bind(this, tutorial.name)}), React.createElement("span", {style: { marginLeft: '10px' }}, tutorial.latest)));
3333
};
3434
UpdateTutorial = __decorate([
3535
react_redux_1.connect(null, function (dispatch) {

lib/components/Tutorials/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ var styles = {
1111
exports.Tutorials = function (_a) {
1212
var tutorials = _a.tutorials;
1313
return (React.createElement("div", {style: styles}, React.createElement(Table_1.Table, null, React.createElement(Table_1.TableHeader, {displaySelectAll: false, adjustForCheckbox: false}, React.createElement(Table_1.TableRow, null, React.createElement(Table_1.TableHeaderColumn, null, "Tutorial"), React.createElement(Table_1.TableHeaderColumn, null, "Version"))), React.createElement(Table_1.TableBody, {displayRowCheckbox: false}, tutorials.map(function tutorialRow(tutorial, index) {
14-
return (React.createElement(Table_1.TableRow, {key: index}, React.createElement(Table_1.TableRowColumn, null, React.createElement(SelectTutorial_1.SelectTutorial, {tutorial: tutorial})), React.createElement(Table_1.TableRowColumn, null, tutorial.version, tutorial.latest
15-
? React.createElement(UpdateTutorial_1.UpdateTutorial, {name: tutorial.name})
14+
return (React.createElement(Table_1.TableRow, {key: index}, React.createElement(Table_1.TableRowColumn, null, React.createElement(SelectTutorial_1.SelectTutorial, {tutorial: tutorial})), React.createElement(Table_1.TableRowColumn, null, tutorial.version, !!tutorial.latest
15+
? React.createElement(UpdateTutorial_1.UpdateTutorial, {tutorial: tutorial})
1616
: null)));
1717
}))), React.createElement("br", null), React.createElement(LoadTutorials_1.LoadTutorials, null)));
1818
};

lib/reducers/alert/index.js

+24-23
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,66 @@ var _alert = {
55
open: false,
66
action: '',
77
};
8+
var open = {
9+
open: true,
10+
pass: true,
11+
};
812
var current = _alert;
913
function alertReducer(alert, action) {
1014
if (alert === void 0) { alert = _alert; }
1115
var statusBarAlert = document.getElementsByClassName('cr-alert-replay')[0];
1216
switch (action.type) {
1317
case _types_1.ALERT_REPLAY:
14-
return Object.assign({}, current, { open: true });
18+
return Object.assign({}, current, open);
1519
case _types_1.ALERT_TOGGLE:
1620
return action.payload.alert || _alert;
21+
case _types_1.TUTORIAL_UPDATE:
22+
current = Object.assign({}, {
23+
message: "run `npm install --save-dev " + action.payload.name + "`",
24+
action: 'note',
25+
duration: 4000,
26+
}, open);
27+
return current;
1728
case _types_1.TEST_RESULT:
1829
var result = action.payload.result;
1930
if (result.pass && result.change > 0) {
2031
statusBarAlert.style.color = '#73C990';
21-
current = {
32+
current = Object.assign({}, {
2233
message: result.msg,
23-
open: true,
24-
action: 'pass',
2534
duration: result.duration || 1500,
26-
};
35+
}, open);
2736
return current;
2837
}
2938
else if (result.pass === false && result.change < 1) {
3039
statusBarAlert.style.color = '#FF4081';
31-
current = {
40+
current = Object.assign({}, {
3241
message: result.msg,
33-
open: true,
3442
action: 'fail',
3543
duration: result.duration || 2500,
36-
};
44+
}, open);
3745
return current;
3846
}
3947
statusBarAlert.style.color = '#9DA5B4';
40-
current = {
48+
current = Object.assign({}, {
4149
message: result.msg,
42-
open: true,
4350
action: 'note',
4451
duration: result.duration || 2500,
45-
};
52+
}, open);
4653
return current;
4754
case _types_1.COMPLETE_PAGE:
48-
current = {
55+
current = Object.assign({}, {
4956
message: "Page " + (action.payload.position.page + 1) + " Complete",
50-
open: true,
51-
action: 'pass',
52-
};
57+
}, open);
5358
return current;
5459
case _types_1.COMPLETE_CHAPTER:
55-
current = {
60+
current = Object.assign({}, {
5661
message: "Chapter " + (action.payload.chapter + 1) + " Complete",
57-
open: true,
58-
action: 'pass',
59-
};
62+
}, open);
6063
return current;
6164
case _types_1.COMPLETE_TUTORIAL:
62-
current = {
65+
current = Object.assign({}, {
6366
message: 'Tutorial Complete',
64-
open: true,
65-
action: 'pass',
66-
};
67+
}, open);
6768
return current;
6869
default:
6970
return alert;

lib/reducers/tutorials/index.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
"use strict";
22
var _types_1 = require('../../actions/_types');
3-
var update_1 = require('./update');
43
var store_1 = require('../../store');
54
var check_1 = require('./check');
65
function tutorialsReducer(tutorials, action) {
76
if (tutorials === void 0) { tutorials = []; }
87
switch (action.type) {
9-
case _types_1.TUTORIAL_UPDATE:
10-
update_1.tutorialUpdate(action.payload.name);
118
case _types_1.TUTORIALS_FIND:
129
var packageJson = store_1.default.getState().packageJson;
1310
return ([]

lib/reducers/tutorials/update.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"use strict";
22
var command_line_1 = require('../../services/command-line');
33
function tutorialUpdate(name) {
4-
alert(name);
4+
console.log("run \"npm install --save-dev " + name + "\"");
55
}
66
exports.tutorialUpdate = tutorialUpdate;
77
function canUpdateTutorial(name, currentVersion) {
88
if (!navigator.onLine) {
9-
return false;
9+
return null;
1010
}
1111
return (command_line_1.default('npm', "outdated " + name).then(function (res) {
1212
console.log(res);
@@ -20,7 +20,7 @@ function canUpdateTutorial(name, currentVersion) {
2020
return true;
2121
}
2222
}
23-
return false;
23+
return null;
2424
}));
2525
}
2626
exports.canUpdateTutorial = canUpdateTutorial;

lib/services/command-line.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function commandLine(root, commands) {
1515
throw root + ' not found. Python may not be installed';
1616
}
1717
}
18-
var run = child_process_1.exec(root + " " + commands);
18+
var run = child_process_1.exec("" + root + (commands ? ' ' + commands : ''));
1919
return new Promise(function (resolve, reject) {
2020
run.stdout.on('data', function (data) { return resolve(data); });
2121
run.stderr.on('data', function (data) { return reject(data); });

src/components/AppMenu/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {menuIconLeft} from './menuIconLeft';
44
import {menuRight} from './menuRight';
55

66
const styles = {
7-
zIndex: '999 !important'
7+
zIndex: '1 !important'
88
};
99

1010
export const AppMenu: React.StatelessComponent<{

src/components/Page/Task/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const Task: React.StatelessComponent<{
4040
key={index}
4141
style={Object.assign({}, styles, {backgroundColor})}
4242
>
43-
{taskCheckbox(currentTask, testRun)}
43+
{taskCheckbox(task, testRun)}
4444
<span style={indexStyles}>{index + 1}.</span>
4545
<div style={descriptionStyles}>
4646
<Markdown >{task.description}</Markdown>

src/components/Tutorials/UpdateTutorial/index.tsx

+10-7
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,19 @@ const styles = {
1515
};
1616
})
1717
export class UpdateTutorial extends React.Component<{
18-
name: string, tutorialUpdate?: any
18+
tutorial: Tutorial.Info, tutorialUpdate?: any
1919
}, {}> {
2020
render() {
21-
const {name, tutorialUpdate} = this.props;
21+
const {tutorial, tutorialUpdate} = this.props;
2222
return (
23-
<Update
24-
style={styles}
25-
color={pink500}
26-
onTouchTap={tutorialUpdate.bind(this, name)}
27-
/>
23+
<span>
24+
<Update
25+
style={styles}
26+
color={pink500}
27+
onTouchTap={tutorialUpdate.bind(this, tutorial.name)}
28+
/>
29+
<span style={{marginLeft: '10px'}}>{tutorial.latest}</span>
30+
</span>
2831
);
2932
}
3033
}

src/components/Tutorials/index.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ export const Tutorials: React.StatelessComponent<{
3838
</TableRowColumn>
3939
<TableRowColumn>
4040
{tutorial.version}
41-
{tutorial.latest
42-
? <UpdateTutorial name={tutorial.name} />
41+
42+
{!!tutorial.latest
43+
? <UpdateTutorial tutorial={tutorial} />
4344
: null
4445
}
46+
4547
</TableRowColumn>
4648
</TableRow>
4749
);

src/reducers/alert/index.ts

+26-24
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
import {
22
ALERT_REPLAY, ALERT_TOGGLE, TEST_RESULT,
3-
COMPLETE_PAGE, COMPLETE_CHAPTER, COMPLETE_TUTORIAL
3+
COMPLETE_PAGE, COMPLETE_CHAPTER, COMPLETE_TUTORIAL,
4+
TUTORIAL_UPDATE
45
} from '../../actions/_types';
56

67
const _alert: CR.Alert = {
78
message: '',
89
open: false,
910
action: '',
1011
};
12+
const open = {
13+
open: true,
14+
pass: true,
15+
};
1116

1217
let current: CR.Alert = _alert;
1318

@@ -17,61 +22,58 @@ export default function alertReducer(
1722
let statusBarAlert = <HTMLElement>document.getElementsByClassName('cr-alert-replay')[0];
1823
switch (action.type) {
1924
case ALERT_REPLAY:
20-
return Object.assign({}, current, {open: true});
25+
return Object.assign({}, current, open);
2126
case ALERT_TOGGLE:
2227
return action.payload.alert || _alert;
28+
case TUTORIAL_UPDATE:
29+
current = Object.assign({}, {
30+
message: `run \`npm install --save-dev ${action.payload.name}\``,
31+
action: 'note',
32+
duration: 4000,
33+
}, open);
34+
return current;
2335
case TEST_RESULT:
2436
let result = action.payload.result;
2537
if (result.pass && result.change > 0) {
2638
// Pass
2739
statusBarAlert.style.color = '#73C990';
28-
current = {
40+
current = Object.assign({}, {
2941
message: result.msg,
30-
open: true,
31-
action: 'pass',
3242
duration: result.duration || 1500,
33-
};
43+
}, open);
3444
return current;
3545
} else if (result.pass === false && result.change < 1) {
3646
// Fail
3747
statusBarAlert.style.color = '#FF4081';
38-
current = {
48+
current = Object.assign({}, {
3949
message: result.msg,
40-
open: true,
4150
action: 'fail',
4251
duration: result.duration || 2500,
43-
};
52+
}, open);
4453
return current;
4554
}
4655
// Alert
4756
statusBarAlert.style.color = '#9DA5B4';
48-
current = {
57+
current = Object.assign({}, {
4958
message: result.msg,
50-
open: true,
5159
action: 'note',
5260
duration: result.duration || 2500,
53-
};
61+
}, open);
5462
return current;
5563
case COMPLETE_PAGE:
56-
current = {
64+
current = Object.assign({}, {
5765
message: `Page ${action.payload.position.page + 1} Complete`,
58-
open: true,
59-
action: 'pass',
60-
};
66+
}, open);
6167
return current;
6268
case COMPLETE_CHAPTER:
63-
current = {
69+
current = Object.assign({}, {
6470
message: `Chapter ${action.payload.chapter + 1} Complete`,
65-
open: true,
66-
action: 'pass',
67-
};
71+
}, open);
6872
return current;
6973
case COMPLETE_TUTORIAL:
70-
current = {
74+
current = Object.assign({}, {
7175
message: 'Tutorial Complete',
72-
open: true,
73-
action: 'pass',
74-
};
76+
}, open);
7577
return current;
7678
default:
7779
return alert;

src/reducers/tutorials/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {TUTORIAL_UPDATE, TUTORIALS_FIND} from '../../actions/_types';
1+
import {TUTORIALS_FIND} from '../../actions/_types';
22
import {tutorialUpdate} from './update';
33
import store from '../../store';
44
import {searchForTutorials} from './check';
@@ -7,8 +7,8 @@ export default function tutorialsReducer(
77
tutorials = [], action: Action
88
): Tutorial.Info[] {
99
switch (action.type) {
10-
case TUTORIAL_UPDATE:
11-
tutorialUpdate(action.payload.name);
10+
// case TUTORIAL_UPDATE:
11+
// tutorialUpdate(action.payload.name);
1212
/* falls through */
1313
case TUTORIALS_FIND:
1414
const packageJson = store.getState().packageJson;

0 commit comments

Comments
 (0)