pitaya-launcher/js/app.jsx

45 lines
1.1 KiB
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-09-03 15:50:23 +02:00
var Provider = require('react-redux').Provider;
var stores = require('./stores');
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 ?
2015-09-03 15:50:23 +02:00
<Provider store={stores.editStore}>
{ function() { return <EditView profilePath={this.state.profilePath} />; }.bind(this) }
</Provider> :
<Provider store={stores.launcherStore}>
{ function() { return <LauncherView profilePath={this.state.profilePath ? this.state.profilePath : DEFAULT_PROFILE } />; }.bind(this) }
</Provider>
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);