2015-03-17 22:21:49 +01:00
|
|
|
var React = require('react');
|
2015-03-27 10:55:42 +01:00
|
|
|
var Router = require('react-router');
|
2015-03-24 21:25:32 +01:00
|
|
|
var Menu = require('./components/Menu');
|
2015-03-17 22:21:49 +01:00
|
|
|
var ErrorMessages = require('./components/ErrorMessages');
|
2015-03-17 22:52:10 +01:00
|
|
|
var initalizer = require('./stores/initalizer');
|
2015-03-27 22:19:56 +01:00
|
|
|
var FeatureToggleStore = require('./stores/FeatureToggleStore');
|
|
|
|
var StrategyStore = require('./stores/StrategyStore');
|
|
|
|
var ArchiveStore = require('./stores/ArchivedToggleStore');
|
2015-03-24 21:25:32 +01:00
|
|
|
var Link = Router.Link;
|
|
|
|
var RouteHandler = Router.RouteHandler;
|
2015-03-17 22:21:49 +01:00
|
|
|
|
|
|
|
var UnleashApp = React.createClass({
|
2015-03-24 21:25:32 +01:00
|
|
|
contextTypes: {
|
|
|
|
router: React.PropTypes.func
|
|
|
|
},
|
|
|
|
|
2015-03-27 22:19:56 +01:00
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
features: FeatureToggleStore.getFeatureToggles(),
|
|
|
|
strategies: StrategyStore.getStrategies(),
|
|
|
|
archivedFeatures: ArchiveStore.getArchivedToggles()
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
onFeatureToggleChange: function() {
|
|
|
|
this.setState({
|
|
|
|
features: FeatureToggleStore.getFeatureToggles()
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onStrategiesChange: function() {
|
|
|
|
this.setState({
|
|
|
|
strategies: StrategyStore.getStrategies()
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onArchiveChange: function() {
|
|
|
|
this.setState({
|
|
|
|
archivedFeatures: ArchiveStore.getArchivedToggles()
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount: function() {
|
|
|
|
this.unsubscribeFS = FeatureToggleStore.listen(this.onFeatureToggleChange);
|
|
|
|
this.unsubscribeSS = StrategyStore.listen(this.onStrategiesChange);
|
|
|
|
this.unsubscribeAS = ArchiveStore.listen(this.onArchiveChange);
|
|
|
|
},
|
|
|
|
componentWillUnmount: function() {
|
|
|
|
this.unsubscribeFS();
|
|
|
|
this.unsubscribeSS();
|
|
|
|
this.unsubscribeAS();
|
|
|
|
},
|
|
|
|
|
2015-03-17 22:52:10 +01:00
|
|
|
componentWillMount: function() {
|
|
|
|
initalizer(30);
|
2015-03-17 22:21:49 +01:00
|
|
|
},
|
2015-03-24 21:25:32 +01:00
|
|
|
|
2015-03-27 10:55:42 +01:00
|
|
|
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>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2015-03-17 22:21:49 +01:00
|
|
|
render: function () {
|
|
|
|
return (
|
|
|
|
<div>
|
2015-03-24 21:25:32 +01:00
|
|
|
<Menu>
|
2015-03-27 10:55:42 +01:00
|
|
|
{this.renderLink("features", "Toggles")}
|
|
|
|
{this.renderLink("strategies", "Strategies")}
|
|
|
|
{this.renderLink("log", "Log")}
|
|
|
|
{this.renderLink("archive", "Archive")}
|
2015-03-24 21:25:32 +01:00
|
|
|
</Menu>
|
2015-03-17 22:21:49 +01:00
|
|
|
<div className="container">
|
|
|
|
<div className="page">
|
|
|
|
<ErrorMessages />
|
2015-03-24 21:25:32 +01:00
|
|
|
<div className="mod shadow mrn pan">
|
|
|
|
<div className="inner pan">
|
|
|
|
<div className="bd">
|
2015-03-27 22:19:56 +01:00
|
|
|
<RouteHandler
|
|
|
|
features={this.state.features}
|
|
|
|
strategies={this.state.strategies}
|
|
|
|
archivedFeatures={this.state.archivedFeatures}
|
|
|
|
/>
|
2015-03-24 21:25:32 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2015-03-17 22:21:49 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-03-24 21:25:32 +01:00
|
|
|
|
2015-03-17 22:21:49 +01:00
|
|
|
module.exports = UnleashApp;
|