Skip to content

Commit 9b335a2

Browse files
committed
fix progress page canActivate & icons
1 parent c557e98 commit 9b335a2

File tree

12 files changed

+40
-17
lines changed

12 files changed

+40
-17
lines changed

lib/components/Progress/ProgressPage/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var ProgressPage = (function (_super) {
3030
}
3131
ProgressPage.prototype.render = function () {
3232
var _a = this.props, page = _a.page, pagePosition = _a.pagePosition, index = _a.index, progress = _a.progress, selectPage = _a.selectPage;
33-
var canActivate = index <= pagePosition + 1;
33+
var canActivate = index <= pagePosition;
3434
return (React.createElement(List_1.ListItem, {key: index, style: Object.assign({}, styles, canActivate ? {} : { color: colors_1.grey400 }), primaryText: (index + 1) + ". " + page.title, secondaryText: page.description, leftIcon: progressIcon_1.progressIcon(progress.pages, pagePosition, index), onClick: canActivate
3535
? selectPage.bind(this, index)
3636
: function () { return; }}));

lib/components/Progress/progressIcon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ var check_box_outline_blank_1 = require('material-ui/svg-icons/toggle/check-box-
77
function progressIcon(pages, index, pagePosition) {
88
console.log(index, pagePosition);
99
switch (true) {
10-
case index === pagePosition:
11-
return React.createElement(play_circle_filled_1.default, {style: { fill: colors_1.pink500 }});
1210
case pages[pagePosition]:
1311
return React.createElement(check_box_1.default, {style: { fill: colors_1.green300 }});
12+
case index === pagePosition:
13+
return React.createElement(play_circle_filled_1.default, {style: { fill: colors_1.pink500 }});
1414
default:
1515
return React.createElement(check_box_outline_blank_1.default, null);
1616
}

lib/components/Tutorials/SelectTutorial/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ var SelectTutorial = (function (_super) {
4141
return {
4242
selectTutorial: function (name) {
4343
dispatch(actions_1.tutorialSet(name));
44-
dispatch(actions_1.pagePositionSet(0));
4544
dispatch(actions_1.progressLoad());
4645
dispatch(actions_1.routeSet('progress'));
4746
},

lib/reducers/page-position/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function pagePositionReducer(pagePosition, action) {
66
switch (action.type) {
77
case _types_1.PAGE_POSITION_LOAD:
88
var pages = store_1.default.getState().progress.pages;
9-
var firstFail = pages.indexOf(function (x) { return !x; });
9+
var firstFail = pages.indexOf(false);
1010
return firstFail < 0 ? pages.length - 1 : firstFail;
1111
case _types_1.PAGE_SET:
1212
case _types_1.PAGE_POSITION_SET:

lib/store/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
"use strict";
22
var redux_1 = require('redux');
33
var reducers_1 = require('../reducers');
4-
var initialState = {};
5-
var store = redux_1.createStore(reducers_1.default, initialState);
4+
var createLogger = require('redux-logger');
5+
var devMode = true;
6+
var store = null;
7+
if (devMode) {
8+
var logger = createLogger();
9+
store = redux_1.createStore(reducers_1.default, redux_1.applyMiddleware(logger));
10+
}
11+
else {
12+
var initialState = {};
13+
store = redux_1.createStore(reducers_1.default, initialState);
14+
}
615
Object.defineProperty(exports, "__esModule", { value: true });
716
exports.default = store;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"react-dom": "15.0.2",
4646
"react-redux": "4.4.5",
4747
"react-tap-event-plugin": "1.0.0",
48-
"redux": "3.5.2"
48+
"redux": "3.5.2",
49+
"redux-logger": "2.6.1"
4950
},
5051
"scripts": {
5152
"compile": "tsc"

src/components/Progress/ProgressPage/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class ProgressPage extends React.Component<{
2424
pagePosition: CR.PagePosition, index: number, selectPage?: () => void}, {}> {
2525
render() {
2626
const {page, pagePosition, index, progress, selectPage} = this.props;
27-
const canActivate: boolean = index <= pagePosition + 1;
27+
const canActivate: boolean = index <= pagePosition;
2828
return (
2929
<ListItem
3030
key={index}

src/components/Progress/progressIcon.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ export function progressIcon(
99
) {
1010
console.log(index, pagePosition);
1111
switch (true) {
12-
// current
13-
case index === pagePosition:
14-
return <PlayCircleFilled style={{fill: pink500}} />;
1512
// completed
1613
case pages[pagePosition]:
1714
return <CheckBox style={{fill: green300}} />;
15+
// current
16+
case index === pagePosition:
17+
return <PlayCircleFilled style={{fill: pink500}} />;
1818
// other
1919
default:
2020
return <CheckBoxOutlineBlank />;

src/components/Tutorials/SelectTutorial/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ function displayName(name: string): string {
1818
return {
1919
selectTutorial: (name: string) => {
2020
dispatch(tutorialSet(name));
21-
dispatch(pagePositionSet(0));
2221
dispatch(progressLoad());
2322
dispatch(routeSet('progress'));
2423
},

src/reducers/page-position/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function pagePositionReducer(
1010

1111
case PAGE_POSITION_LOAD:
1212
const pages = store.getState().progress.pages;
13-
const firstFail = pages.indexOf(x => !x);
13+
const firstFail = pages.indexOf(false);
1414
return firstFail < 0 ? pages.length - 1 : firstFail;
1515

1616
case PAGE_SET:

src/reducers/test-run/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export default function runTestReducer(
1212
): boolean {
1313
switch (action.type) {
1414

15+
// case TESTS_LOAD:
16+
// TODO: More performant test loading
17+
1518
case TEST_RUN:
1619
let current = new Date().getTime();
1720
if (current - previous > pageTimeout) {

src/store/index.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
import {createStore} from 'redux';
1+
import { applyMiddleware, createStore } from 'redux';
22
import reducer from '../reducers';
3+
import * as createLogger from 'redux-logger';
34

4-
const initialState = {};
5-
const store = createStore(reducer, initialState);
5+
const devMode = true;
6+
let store = null;
7+
8+
if (devMode) {
9+
const logger = createLogger();
10+
store = createStore(
11+
reducer,
12+
applyMiddleware(logger)
13+
);
14+
} else {
15+
const initialState = {};
16+
store = createStore(reducer, initialState);
17+
}
618
export default store;

0 commit comments

Comments
 (0)