1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01:00

Clean up entry point

This commit is contained in:
ivaosthu 2015-03-27 10:55:42 +01:00
parent 0c75f92e4c
commit c6c858e94a
4 changed files with 44 additions and 36 deletions

View File

@ -1,20 +1,11 @@
var React = require('react');
var UserStore = require('./stores/UserStore');
var Router = require('react-router');
var Menu = require('./components/Menu');
var ErrorMessages = require('./components/ErrorMessages');
var initalizer = require('./stores/initalizer');
var LogEntriesComponent = require('./components/log/LogEntriesComponent');
var FeatureTogglesComponent = require('./components/feature/FeatureTogglesComponent');
var StrategiesComponent = require('./components/strategy/StrategiesComponent');
var ArchiveFeatureComponent = require('./components/feature/ArchiveFeatureComponent');
var Router = require('react-router');
var DefaultRoute = Router.DefaultRoute;
var Link = Router.Link;
var Route = Router.Route;
var RouteHandler = Router.RouteHandler;
UserStore.init();
var UnleashApp = React.createClass({
contextTypes: {
router: React.PropTypes.func
@ -24,22 +15,22 @@ var UnleashApp = React.createClass({
initalizer(30);
},
renderLink: function(id, label) {
return (
<Link to={id} className="nav-element centerify" activeClassName="nav-active">
<span className="topbar-nav-svg-caption caption showbydefault no-break">{label}</span>
</Link>
);
},
render: function () {
return (
<div>
<Menu>
<Link to="features" className="nav-element centerify" activeClassName="nav-active">
<span className="topbar-nav-svg-caption caption showbydefault no-break">Features</span>
</Link>
<Link to="strategies" className="nav-element centerify" activeClassName="nav-active">
<span className="topbar-nav-svg-caption caption showbydefault no-break">Strategies</span>
</Link>
<Link to="log" className="nav-element centerify" activeClassName="nav-active">
<span className="topbar-nav-svg-caption caption showbydefault no-break">Log</span>
</Link>
<Link to="archive" className="nav-element centerify" activeClassName="nav-active">
<span className="topbar-nav-svg-caption caption showbydefault no-break">Archive</span>
</Link>
{this.renderLink("features", "Toggles")}
{this.renderLink("strategies", "Strategies")}
{this.renderLink("log", "Log")}
{this.renderLink("archive", "Archive")}
</Menu>
<div className="container">
<div className="page">
@ -58,18 +49,5 @@ var UnleashApp = React.createClass({
}
});
var routes = (
<Route name="app" path="/" handler={UnleashApp}>
<Route name="strategies" handler={StrategiesComponent}/>
<Route name="log" handler={LogEntriesComponent}/>
<Route name="archive" handler={ArchiveFeatureComponent}/>
<DefaultRoute name="features" handler={FeatureTogglesComponent}/>
</Route>
);
Router.run(routes, function (Handler) {
React.render(<Handler/>, document.getElementById('content'));
});
module.exports = UnleashApp;

10
public/js/app.jsx Normal file
View File

@ -0,0 +1,10 @@
var React = require('react');
var Router = require('react-router');
var UserStore = require('./stores/UserStore');
var routes = require('./routes');
UserStore.init();
Router.run(routes, function (Handler) {
React.render(<Handler/>, document.getElementById('content'));
});

20
public/js/routes.jsx Normal file
View File

@ -0,0 +1,20 @@
var React = require('react');
var Router = require('react-router');
var UnleashApp = require('./UnleashApp');
var LogEntriesComponent = require('./components/log/LogEntriesComponent');
var FeatureTogglesComponent = require('./components/feature/FeatureTogglesComponent');
var StrategiesComponent = require('./components/strategy/StrategiesComponent');
var ArchiveFeatureComponent = require('./components/feature/ArchiveFeatureComponent');
var DefaultRoute = Router.DefaultRoute;
var Route = Router.Route;
var routes = (
<Route name="app" path="/" handler={UnleashApp}>
<Route name="strategies" handler={StrategiesComponent}/>
<Route name="log" handler={LogEntriesComponent}/>
<Route name="archive" handler={ArchiveFeatureComponent}/>
<DefaultRoute name="features" handler={FeatureTogglesComponent}/>
</Route>
);
module.exports = routes;

View File

@ -7,7 +7,7 @@ var js_root = path.join(path.join(root, 'public'), 'js');
module.exports = {
context: js_root,
entry: 'UnleashApp',
entry: 'app',
output: {
path: js_root,