pitaya-launcher/js/app.jsx

40 lines
884 B
React
Raw Normal View History

2015-08-27 18:24:29 +02:00
var React = require('react');
2015-08-27 22:52:30 +02:00
var minimist = require('minimist');
var gui = global.window.require('nw.gui');
2015-08-28 14:20:07 +02:00
var LauncherView = require('./components/launcher-view.jsx');
var EditView = require('./components/edit-view.jsx');
2015-08-27 22:52:30 +02:00
// Internal constants
var DEFAULT_PROFILE = './default-profile.json';
var PROCESS_OPTS = minimist(gui.App.argv);
2015-08-27 18:24:29 +02:00
2015-08-28 10:06:25 +02:00
// Main component
2015-08-27 18:24:29 +02:00
var App = React.createClass({
getInitialState: function() {
return {
2015-08-28 14:20:07 +02:00
profilePath: PROCESS_OPTS.profile,
editMode: PROCESS_OPTS.edit || false
2015-08-27 18:24:29 +02:00
};
},
render: function() {
2015-08-27 22:52:30 +02:00
2015-08-28 14:20:07 +02:00
var view = this.state.editMode ?
<EditView profilePath={this.state.profilePath} /> :
<LauncherView profilePath={this.state.profilePath ? this.state.profilePath : DEFAULT_PROFILE } />
2015-08-27 22:52:30 +02:00
;
2015-08-27 18:24:29 +02:00
return (
2015-08-28 14:20:07 +02:00
<div id="pitaya">
{view}
2015-08-27 18:24:29 +02:00
</div>
);
2015-08-27 22:52:30 +02:00
},
2015-08-27 18:24:29 +02:00
});
2015-08-28 14:20:07 +02:00
React.render(<App />, document.body);