var React = require('react'); var _ = require('lodash'); var cx = require('classnames'); var Moment = require('moment'); var Logo = require('naturalCrit/logo/logo.jsx'); var Statusbar = React.createClass({ getDefaultProps: function() { return { //editId: null, shareId : null, isPending : false, lastUpdated : null, info : null, views : 0 }; }, componentDidMount: function() { //Updates the last updated text every 10 seconds if(this.props.lastUpdated){ this.refreshTimer = setInterval(()=>{ this.forceUpdate(); }, 10000) } }, componentWillUnmount: function() { clearInterval(this.refreshTimer); }, renderInfo : function(){ if(!this.props.lastUpdated) return null; return [
Views: {this.props.views}
,
Last updated: {Moment(this.props.lastUpdated).fromNow()}
]; }, renderNewButton : function(){ if(this.props.editId || this.props.shareId) return null; return New Brew }, renderShare : function(){ if(!this.props.shareId) return null; return Share Link }, renderStatus : function(){ if(!this.props.editId) return null; var text = 'Saved.' if(this.props.isPending){ text = 'Saving...' } return
{text}
}, render : function(){ return
The HomeBrewery
{this.renderStatus()} {this.renderInfo()} {this.renderShare()} {this.renderNewButton()}
} }); module.exports = Statusbar;