@@ -15,6 +15,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
1515} ;
1616var React = require ( 'react' ) ;
1717var react_redux_1 = require ( 'react-redux' ) ;
18+ var path_1 = require ( 'path' ) ;
1819var TextField_1 = require ( 'material-ui/TextField' ) ;
1920var SelectField_1 = require ( 'material-ui/SelectField' ) ;
2021var Card_1 = require ( 'material-ui/Card' ) ;
@@ -23,18 +24,22 @@ var actions_1 = require('../../actions');
2324var languageItems_1 = require ( './languageItems' ) ;
2425var runnerItems_1 = require ( './runnerItems' ) ;
2526var styles = {
26- margin : '10px' ,
27- padding : '30px 20px' ,
28- textAlign : 'center' ,
29- } ;
30- var buttonStyles = {
31- margin : '30px 10px 20px 10px' ,
27+ card : {
28+ margin : '10px' ,
29+ padding : '30px 20px' ,
30+ textAlign : 'center' ,
31+ } ,
32+ button : {
33+ margin : '30px 10px 20px 10px' ,
34+ } ,
3235} ;
3336var TutorialConfig = ( function ( _super ) {
3437 __extends ( TutorialConfig , _super ) ;
3538 function TutorialConfig ( props ) {
3639 _super . call ( this , props ) ;
37- this . state = this . props . packageJson ;
40+ this . state = {
41+ pj : this . props . packageJson
42+ } ;
3843 }
3944 TutorialConfig . prototype . handleText = function ( prop , event ) {
4045 this . handleChange ( prop , event . target . value ) ;
@@ -48,12 +53,13 @@ var TutorialConfig = (function (_super) {
4853 var target = null ;
4954 switch ( prop ) {
5055 case 'name' :
51- this . setState ( Object . assign ( { } , this . state , obj ) ) ;
56+ this . setState ( { pj : Object . assign ( { } , this . state . pj , obj ) } ) ;
5257 break ;
5358 case 'language' :
5459 case 'runner' :
55- var config = Object . assign ( { } , this . state . config , obj ) ;
56- this . setState ( Object . assign ( { } , this . state , { config : config } ) ) ;
60+ var config = Object . assign ( { } , this . state . pj . config , obj ) ;
61+ var pj = Object . assign ( { } , this . state . pj , { config : config } ) ;
62+ this . setState ( { pj : pj } ) ;
5763 return ;
5864 case 'repo' :
5965 var repo = {
@@ -62,24 +68,25 @@ var TutorialConfig = (function (_super) {
6268 url : prop
6369 } ,
6470 bugs : {
65- url : prop + '/ issues'
71+ url : path_1 . resolve ( prop , ' issues')
6672 }
6773 } ;
68- this . setState ( Object . assign ( { } , this . state , repo ) ) ;
74+ this . setState ( { pj : Object . assign ( { } , this . state . pj , repo ) } ) ;
6975 return ;
7076 }
7177 } ;
7278 TutorialConfig . prototype . save = function ( ) {
73- this . props . save ( this . state ) ;
79+ this . props . save ( this . state . pj ) ;
7480 } ;
7581 TutorialConfig . prototype . render = function ( ) {
76- return ( React . createElement ( Card_1 . Card , { style : styles } , React . createElement ( Card_1 . CardHeader , { title : 'Tutorial Configuration' } ) , React . createElement ( TextField_1 . default , { floatingLabelText : 'Tutorial Package Name' , defaultValue : this . state . name , onChange : this . handleText . bind ( this , 'name' ) } ) , React . createElement ( "br" , null ) , React . createElement ( SelectField_1 . default , { floatingLabelText : 'Language' , value : this . state . config . language , onChange : this . handleSelect . bind ( this , 'language' ) } , languageItems_1 . default ( ) ) , React . createElement ( "br" , null ) , React . createElement ( SelectField_1 . default , { floatingLabelText : 'Test Runner' , value : this . state . config . runner , onChange : this . handleSelect . bind ( this , 'runner' ) } , runnerItems_1 . default ( this . state . config . language ) ) , React . createElement ( "br" , null ) , React . createElement ( RaisedButton_1 . default , { style : buttonStyles , label : 'Save' , primary : true , onTouchTap : this . save . bind ( this ) } ) , React . createElement ( RaisedButton_1 . default , { style : buttonStyles , label : 'Continue' , secondary : true , onTouchTap : this . props . routeToInfo . bind ( this ) } ) ) ) ;
82+ var pj = this . state . pj ;
83+ return ( React . createElement ( Card_1 . Card , { style : styles . card } , React . createElement ( Card_1 . CardHeader , { title : 'Tutorial Configuration' } ) , React . createElement ( TextField_1 . default , { floatingLabelText : 'Tutorial Package Name' , defaultValue : pj . name , onChange : this . handleText . bind ( this , 'name' ) } ) , React . createElement ( "br" , null ) , React . createElement ( SelectField_1 . default , { floatingLabelText : 'Language' , value : pj . config . language , onChange : this . handleSelect . bind ( this , 'language' ) } , languageItems_1 . default ( ) ) , React . createElement ( "br" , null ) , React . createElement ( SelectField_1 . default , { floatingLabelText : 'Test Runner' , value : pj . config . runner , onChange : this . handleSelect . bind ( this , 'runner' ) } , runnerItems_1 . default ( pj . config . language ) ) , React . createElement ( "br" , null ) , React . createElement ( RaisedButton_1 . default , { style : styles . button , label : 'Save' , primary : true , onTouchTap : this . save . bind ( this ) } ) , React . createElement ( RaisedButton_1 . default , { style : styles . button , label : 'Continue' , secondary : true , onTouchTap : this . props . routeToInfo . bind ( this ) } ) ) ) ;
7784 } ;
7885 TutorialConfig = __decorate ( [
7986 react_redux_1 . connect ( null , function ( dispatch ) {
8087 return {
81- save : function ( config ) { return dispatch ( actions_1 . tutorialConfigSave ( config ) ) ; } ,
82- routeToInfo : function ( ) { return dispatch ( actions_1 . routeSet ( 'tutorialInfo ' ) ) ; }
88+ save : function ( pj ) { return dispatch ( actions_1 . tutorialConfigSave ( pj ) ) ; } ,
89+ routeToPage : function ( ) { return dispatch ( actions_1 . routeSet ( 'page ' ) ) ; }
8390 } ;
8491 } ) ,
8592 __metadata ( 'design:paramtypes' , [ Object ] )
0 commit comments