var React = require('react'); var Col = require('react-bootstrap/lib/Col'); var Badge = require('react-bootstrap/lib/Badge'); var Button = require('react-bootstrap/lib/Button'); var ButtonGroup = require('react-bootstrap/lib/ButtonGroup'); var Glyphicon = require('react-bootstrap/lib/Glyphicon'); var MenuStore = require('../stores/MenuStore'); var MenuActions = require('../actions/MenuActions'); var MiddlePanelActions = require('../actions/MiddlePanelActions'); var FeedItem = React.createClass({ propTypes: {feed_id: React.PropTypes.number.isRequired, title: React.PropTypes.string.isRequired, unread: React.PropTypes.number.isRequired, error_count: React.PropTypes.number.isRequired, icon_url: React.PropTypes.string, active: React.PropTypes.bool.isRequired, }, render: function() { var icon = null; var badge_unread = null; if(this.props.icon_url){ icon = (); } else { icon = ; } if(this.props.unread){ badge_unread = {this.props.unread}; } var classes = "nav-feed"; if(this.props.active) { classes += " bg-primary"; } if(this.props.error_count >= MenuStore._datas.max_error) { classes += " bg-danger"; } else if(this.props.error_count > MenuStore._datas.error_threshold) { classes += " bg-warning"; } var title = {this.props.title}; return (
  • {icon}{title}{badge_unread}
  • ); }, handleClick: function() { MiddlePanelActions.setFeedFilter(this.props.feed_id); }, }); var Category = React.createClass({ propTypes: {category_id: React.PropTypes.number, active_type: React.PropTypes.string, active_id: React.PropTypes.number}, render: function() { var classes = "nav-cat"; if((this.props.active_type == 'category_id' || this.props.category_id == null) && this.props.active_id == this.props.category_id) { classes += " bg-primary"; } return (
  • {this.props.children}
  • ); }, handleClick: function(evnt) { // hack to avoid selection when clicking on folding icon if(!evnt.target.classList.contains('glyphicon')) { if(this.props.category_id != null) { MiddlePanelActions.setCategoryFilter(this.props.category_id); } else { MiddlePanelActions.removeParentFilter(); } } }, }); var CategoryGroup = React.createClass({ propTypes: {cat_id: React.PropTypes.number.isRequired, filter: React.PropTypes.string.isRequired, active_type: React.PropTypes.string, active_id: React.PropTypes.number, name: React.PropTypes.string.isRequired, feeds: React.PropTypes.array.isRequired, unread: React.PropTypes.number.isRequired, folded: React.PropTypes.bool.isRequired, }, getInitialState: function() { return {folded: this.props.folded}; }, componentWillReceiveProps: function(nextProps) { this.setState({folded: nextProps.folded}); }, render: function() { // hidden the no category if empty if(!this.props.cat_id && !this.props.feeds.length) { return