pitaya-launcher/js/app.jsx

45 lines
1.1 KiB
JavaScript

var React = require('react');
var minimist = require('minimist');
var gui = global.window.require('nw.gui');
var LauncherView = require('./components/launcher-view.jsx');
var EditView = require('./components/edit-view.jsx');
var Provider = require('react-redux').Provider;
var stores = require('./stores');
// Internal constants
var DEFAULT_PROFILE = './default-profile.json';
var PROCESS_OPTS = minimist(gui.App.argv);
// Main component
var App = React.createClass({
getInitialState: function() {
return {
profilePath: PROCESS_OPTS.profile,
editMode: PROCESS_OPTS.edit || false
};
},
render: function() {
var view = this.state.editMode ?
<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>
;
return (
<div id="pitaya">
{view}
</div>
);
},
});
React.render(<App />, document.body);