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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 24 additions & 23 deletions
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

Lines changed: 0 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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>

0 commit comments

Comments
 (0)