var DomainStore = require('../stores').Domains; var React = require('react'); var dateToString = require('../util').dateToString; var DevModeToggle = React.createClass({ getInitialState: function() { return {toggling: false}; }, componentWillReceiveProps: function() { this.setState({toggling: false}); }, toggleDevMode: function() { this.setState({toggling: true}); DomainStore.setDevelopmentMode(this.props.domain, this.props.devMode * 1000 <= Date.now()); }, render: function() { if(this.state.toggling) { return } else if(this.props.devMode * 1000 > Date.now()) { var date = new Date(this.props.devMode*1000); return (
Active until {dateToString(date)}
); } else { return } } }); var PurgeButton = React.createClass({ getInitialState: function() { return {purging: false, failed: false}; }, purgeCache: function() { var self = this; this.setState({purging: true}); var reset = function() { this.setState({purging: false, failed: false}); }.bind(this); DomainStore.purgeCache(this.props.domain).then(function(data) { setTimeout(reset, 5*1000); }, function(error) { self.setState({failed: true}); setTimeout(reset, 10*1000); }); }, render: function() { if(this.state.failed) { return } else if(this.state.purging) { return } else { return } } }); var Settings = React.createClass({ render: function() { if(!this.props.settings.val()) { return
Loading...
} return (
Development Mode
Purge Cache
); } }); module.exports = Settings;