2016-06-18 21:53:18 +02:00
|
|
|
'use strict';
|
|
|
|
const React = require('react');
|
|
|
|
const Router = require('react-router');
|
|
|
|
const Menu = require('./components/Menu');
|
|
|
|
const ErrorMessages = require('./components/ErrorMessages');
|
|
|
|
const initalizer = require('./stores/initalizer');
|
|
|
|
const FeatureToggleStore = require('./stores/FeatureToggleStore');
|
|
|
|
const StrategyStore = require('./stores/StrategyStore');
|
|
|
|
const ArchiveStore = require('./stores/ArchivedToggleStore');
|
|
|
|
const Link = Router.Link;
|
|
|
|
const RouteHandler = Router.RouteHandler;
|
2015-03-17 22:21:49 +01:00
|
|
|
|
2016-06-18 21:53:18 +02:00
|
|
|
const UnleashApp = React.createClass({
|
2015-03-24 21:25:32 +01:00
|
|
|
contextTypes: {
|
2016-06-18 21:55:46 +02:00
|
|
|
router: React.PropTypes.func,
|
2015-03-24 21:25:32 +01:00
|
|
|
},
|
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
getInitialState () {
|
2015-03-27 22:19:56 +01:00
|
|
|
return {
|
2016-06-18 21:55:46 +02:00
|
|
|
features: FeatureToggleStore.getFeatureToggles(),
|
|
|
|
strategies: StrategyStore.getStrategies(),
|
|
|
|
archivedFeatures: ArchiveStore.getArchivedToggles(),
|
2015-03-27 22:19:56 +01:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
onFeatureToggleChange () {
|
2015-03-27 22:19:56 +01:00
|
|
|
this.setState({
|
2016-06-18 21:55:46 +02:00
|
|
|
features: FeatureToggleStore.getFeatureToggles(),
|
2015-03-27 22:19:56 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
onStrategiesChange () {
|
2015-03-27 22:19:56 +01:00
|
|
|
this.setState({
|
2016-06-18 21:55:46 +02:00
|
|
|
strategies: StrategyStore.getStrategies(),
|
2015-03-27 22:19:56 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
onArchiveChange () {
|
2015-03-27 22:19:56 +01:00
|
|
|
this.setState({
|
2016-06-18 21:55:46 +02:00
|
|
|
archivedFeatures: ArchiveStore.getArchivedToggles(),
|
2015-03-27 22:19:56 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
componentDidMount () {
|
2015-03-27 22:19:56 +01:00
|
|
|
this.unsubscribeFS = FeatureToggleStore.listen(this.onFeatureToggleChange);
|
|
|
|
this.unsubscribeSS = StrategyStore.listen(this.onStrategiesChange);
|
|
|
|
this.unsubscribeAS = ArchiveStore.listen(this.onArchiveChange);
|
|
|
|
},
|
2016-07-02 11:54:50 +02:00
|
|
|
componentWillUnmount () {
|
2015-03-27 22:19:56 +01:00
|
|
|
this.unsubscribeFS();
|
|
|
|
this.unsubscribeSS();
|
|
|
|
this.unsubscribeAS();
|
|
|
|
},
|
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
componentWillMount () {
|
2015-03-17 22:52:10 +01:00
|
|
|
initalizer(30);
|
2015-03-17 22:21:49 +01:00
|
|
|
},
|
2015-03-24 21:25:32 +01:00
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
renderLink (id, label) {
|
2015-03-27 10:55:42 +01:00
|
|
|
return (
|
|
|
|
<Link to={id} className="nav-element centerify" activeClassName="nav-active">
|
|
|
|
<span className="topbar-nav-svg-caption caption showbydefault no-break">{label}</span>
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
render () {
|
2015-03-17 22:21:49 +01:00
|
|
|
return (
|
|
|
|
<div>
|
2015-03-24 21:25:32 +01:00
|
|
|
<Menu>
|
2016-06-18 21:55:46 +02: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>
|
|
|
|
);
|
2016-06-18 21:55:46 +02:00
|
|
|
},
|
2015-03-17 22:21:49 +01:00
|
|
|
});
|
|
|
|
|
2015-03-24 21:25:32 +01:00
|
|
|
|
2015-03-17 22:21:49 +01:00
|
|
|
module.exports = UnleashApp;
|