Skip to content

Commit 4b2dc88

Browse files
committed
setup publish via apm
1 parent 01af1b2 commit 4b2dc88

File tree

15 files changed

+174
-13
lines changed

15 files changed

+174
-13
lines changed

lib/actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ exports.tutorialPageAdd = tutorial_1.tutorialPageAdd;
1919
exports.tutorialTaskAdd = tutorial_1.tutorialTaskAdd;
2020
exports.tutorialHintAdd = tutorial_1.tutorialHintAdd;
2121
exports.tutorialActionAdd = tutorial_1.tutorialActionAdd;
22+
exports.tutorialPublish = tutorial_1.tutorialPublish;
2223
var window_1 = require('./modules/window');
2324
exports.windowToggle = window_1.windowToggle;
2425
exports.quit = window_1.quit;
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"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+
};
16+
var React = require('react');
17+
var react_redux_1 = require('react-redux');
18+
var Dialog_1 = require('material-ui/Dialog');
19+
var FlatButton_1 = require('material-ui/FlatButton');
20+
var RaisedButton_1 = require('material-ui/RaisedButton');
21+
var actions_1 = require('../../actions');
22+
var styles = {
23+
cancel: {
24+
float: 'right',
25+
},
26+
};
27+
var PublishOptionsModal = (function (_super) {
28+
__extends(PublishOptionsModal, _super);
29+
function PublishOptionsModal() {
30+
_super.apply(this, arguments);
31+
}
32+
PublishOptionsModal.prototype.publish = function (type) {
33+
this.props.tutorialPublish(type);
34+
};
35+
PublishOptionsModal.prototype.render = function () {
36+
return (React.createElement("div", null,
37+
React.createElement(Dialog_1.default, {title: 'Dialog With Actions', modal: true, open: this.props.open, onRequestClose: this.props.handleClose},
38+
"Select version change:",
39+
React.createElement(FlatButton_1.default, {label: 'Patch', primary: true, disabled: false, onTouchTap: this.publish.bind(this, 'patch')}),
40+
React.createElement(FlatButton_1.default, {label: 'Minor', disabled: false, onTouchTap: this.publish.bind(this, 'minor')}),
41+
React.createElement(FlatButton_1.default, {label: 'Major', disabled: false, onTouchTap: this.publish.bind(this, 'major')}),
42+
React.createElement("br", null),
43+
React.createElement(RaisedButton_1.default, {style: styles.cancel, label: 'Cancel', secondary: true, onTouchTap: this.props.handleClose}))
44+
));
45+
};
46+
PublishOptionsModal = __decorate([
47+
react_redux_1.connect(null, { tutorialPublish: actions_1.tutorialPublish }),
48+
__metadata('design:paramtypes', [])
49+
], PublishOptionsModal);
50+
return PublishOptionsModal;
51+
}(React.Component));
52+
Object.defineProperty(exports, "__esModule", { value: true });
53+
exports.default = PublishOptionsModal;

lib/components/Publish/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var actions_1 = require('../../actions');
2121
var TopPanel_1 = require('../TopPanel');
2222
var Stepper_1 = require('material-ui/Stepper');
2323
var publishStep_1 = require('./publishStep');
24+
var PublishOptions_1 = require('./PublishOptions');
2425
var styles = {
2526
card: {
2627
margin: '10px',
@@ -42,6 +43,7 @@ var TutorialPublish = (function (_super) {
4243
_super.call(this, props);
4344
this.state = {
4445
stepIndex: 0,
46+
modalOpen: false,
4547
};
4648
}
4749
TutorialPublish.prototype.componentWillMount = function () {
@@ -59,7 +61,15 @@ var TutorialPublish = (function (_super) {
5961
};
6062
TutorialPublish.prototype.selectStep = function (index) {
6163
this.setState({
62-
stepIndex: index
64+
stepIndex: index,
65+
modalOpen: false,
66+
});
67+
};
68+
TutorialPublish.prototype.handleDialog = function (open) {
69+
console.log('onClose', open);
70+
this.setState({
71+
stepIndex: this.state.stepIndex,
72+
modalOpen: open,
6373
});
6474
};
6575
TutorialPublish.prototype.render = function () {
@@ -85,7 +95,8 @@ var TutorialPublish = (function (_super) {
8595
: null,
8696
React.createElement("div", {style: styles.buttons},
8797
React.createElement(RaisedButton_1.default, {style: styles.button, label: 'Validate', primary: true, onTouchTap: this.validate.bind(this)}),
88-
React.createElement(RaisedButton_1.default, {style: styles.button, label: 'Publish', secondary: true, disabled: validation.errors.length > 0, onTouchTap: function () { return alert('Publish not yet implemented'); }}))))
98+
React.createElement(RaisedButton_1.default, {style: styles.button, label: 'Publish', secondary: true, disabled: validation.errors.length > 0, onTouchTap: this.handleDialog.bind(this, true)})),
99+
React.createElement(PublishOptions_1.default, {open: this.state.modalOpen, handleClose: this.handleDialog.bind(this, false)})))
89100
));
90101
};
91102
TutorialPublish = __decorate([

lib/modules/tutorial/actions.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,9 @@ function tutorialHintAdd(taskPosition, hint) {
4949
};
5050
}
5151
exports.tutorialHintAdd = tutorialHintAdd;
52+
function tutorialPublish(type) {
53+
return function (dispatch, getState) {
54+
dispatch({ type: types_1.TUTORIAL_PUBLISH, payload: { type: type } });
55+
};
56+
}
57+
exports.tutorialPublish = tutorialPublish;

lib/modules/tutorial/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ exports.tutorialPageAdd = actions_1.tutorialPageAdd;
77
exports.tutorialTaskAdd = actions_1.tutorialTaskAdd;
88
exports.tutorialHintAdd = actions_1.tutorialHintAdd;
99
exports.tutorialActionAdd = actions_1.tutorialActionAdd;
10+
exports.tutorialPublish = actions_1.tutorialPublish;
1011
var reducer_1 = require('./reducer');
1112
exports.reducer = reducer_1.default;

lib/modules/tutorial/reducer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ function tutorial(t, action) {
4444
return taskUpdate_1.default(t, action.payload.pagePosition, action.payload.taskPosition, 'actions', action.payload.tutorialAction);
4545
case types_1.TUTORIAL_HINT_ADD:
4646
return taskUpdate_1.default(t, action.payload.pagePosition, action.payload.taskPosition, 'hints', action.payload.hint);
47+
case types_1.TUTORIAL_PUBLISH:
48+
var type = action.payload.type;
49+
console.log('publish: ', type);
50+
return t;
4751
default:
4852
return t;
4953
}

lib/modules/tutorial/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ exports.TUTORIAL_PAGE_ADD = 'TUTORIAL_PAGE_ADD';
66
exports.TUTORIAL_TASK_ADD = 'TUTORIAL_TASK_ADD';
77
exports.TUTORIAL_HINT_ADD = 'TUTORIAL_HINT_ADD';
88
exports.TUTORIAL_ACTION_ADD = 'TUTORIAL_ACTION_ADD';
9+
exports.TUTORIAL_PUBLISH = 'TUTORIAL_PUBLISH';

src/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export {pjSave, pjLoad} from './modules/package-json';
44
export {setupVerify, setupPackage} from './modules/setup';
55
export {
66
tutorialInit, tutorialLoad, tutorialBuild, tutorialPageAdd,
7-
tutorialTaskAdd, tutorialHintAdd, tutorialActionAdd
7+
tutorialTaskAdd, tutorialHintAdd, tutorialActionAdd, tutorialPublish
88
} from './modules/tutorial';
99
export {windowToggle, quit} from './modules/window';
1010
export {validateTutorial} from './modules/validate-tutorial';
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import * as React from 'react';
2+
import {connect} from 'react-redux';
3+
import Dialog from 'material-ui/Dialog';
4+
import FlatButton from 'material-ui/FlatButton';
5+
import RaisedButton from 'material-ui/RaisedButton';
6+
import {tutorialPublish} from '../../actions';
7+
8+
const styles = {
9+
cancel: {
10+
float: 'right',
11+
},
12+
};
13+
14+
@connect(null, {tutorialPublish})
15+
export default class PublishOptionsModal extends React.Component<{
16+
open: boolean, handleClose: () => any,
17+
tutorialPublish: (type: string) => Redux.ActionCreator,
18+
}, {}> {
19+
publish(type: string) {
20+
this.props.tutorialPublish(type);
21+
}
22+
render() {
23+
return (
24+
<div>
25+
<Dialog
26+
title='Dialog With Actions'
27+
modal={true}
28+
open={this.props.open}
29+
onRequestClose={this.props.handleClose}
30+
>
31+
Select version change:
32+
<FlatButton
33+
label='Patch'
34+
primary={true}
35+
disabled={false}
36+
onTouchTap={this.publish.bind(this, 'patch')}
37+
/>
38+
<FlatButton
39+
label='Minor'
40+
disabled={false}
41+
onTouchTap={this.publish.bind(this, 'minor')}
42+
/>
43+
<FlatButton
44+
label='Major'
45+
disabled={false}
46+
onTouchTap={this.publish.bind(this, 'major')}
47+
/>
48+
<br/>
49+
<RaisedButton
50+
style={styles.cancel}
51+
label='Cancel'
52+
secondary={true}
53+
onTouchTap={this.props.handleClose}
54+
/>
55+
</Dialog>
56+
</div>
57+
);
58+
}
59+
}

src/components/Publish/index.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {validateTutorial, pjSave, pjLoad, tutorialLoad, routeSet, editorPjOpen}
66
import {topElement} from '../TopPanel';
77
import {Stepper} from 'material-ui/Stepper';
88
import publishStep from './publishStep';
9+
import PublishOptionsModal from './PublishOptions';
910

1011
const styles = {
1112
card: {
@@ -33,12 +34,14 @@ export default class TutorialPublish extends React.Component<{
3334
validateTutorial?: () => Redux.ActionCreator,
3435
editorPjOpen?: () => Redux.ActionCreator,
3536
}, {
36-
stepIndex: number
37+
stepIndex: number,
38+
modalOpen: boolean,
3739
}> {
3840
constructor(props) {
3941
super(props);
4042
this.state = {
4143
stepIndex: 0,
44+
modalOpen: false,
4245
};
4346
}
4447
componentWillMount() {
@@ -56,7 +59,15 @@ export default class TutorialPublish extends React.Component<{
5659
}
5760
selectStep(index) {
5861
this.setState({
59-
stepIndex: index
62+
stepIndex: index,
63+
modalOpen: false,
64+
});
65+
}
66+
handleDialog(open: boolean) {
67+
console.log('onClose', open);
68+
this.setState({
69+
stepIndex: this.state.stepIndex,
70+
modalOpen: open,
6071
});
6172
}
6273
render() {
@@ -112,10 +123,15 @@ export default class TutorialPublish extends React.Component<{
112123
label='Publish'
113124
secondary={true}
114125
disabled={validation.errors.length > 0}
115-
onTouchTap={() => alert('Publish not yet implemented')}
126+
onTouchTap={this.handleDialog.bind(this, true)}
116127
/>
117128
</div>
118129

130+
<PublishOptionsModal
131+
open={this.state.modalOpen}
132+
handleClose={this.handleDialog.bind(this, false)}
133+
/>
134+
119135
</CardText>
120136
</Card>
121137
</section>

0 commit comments

Comments
 (0)