var React = require('react'); var createReactClass = require('create-react-class'); 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 PropTypes = require('prop-types'); var MenuStore = require('../stores/MenuStore'); var MenuActions = require('../actions/MenuActions'); var MiddlePanelActions = require('../actions/MiddlePanelActions'); var FeedItem = createReactClass({ propTypes: {feed_id: PropTypes.number.isRequired, title: PropTypes.string.isRequired, unread: PropTypes.number.isRequired, error_count: PropTypes.number.isRequired, icon_url: PropTypes.string, active: 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 = createReactClass({ propTypes: {category_id: PropTypes.number, active_type: PropTypes.string, active_id: 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 = createReactClass({ propTypes: {cat_id: PropTypes.number.isRequired, filter: PropTypes.string.isRequired, active_type: PropTypes.string, active_id: PropTypes.number, name: PropTypes.string.isRequired, feeds: PropTypes.array.isRequired, unread: PropTypes.number.isRequired, folded: PropTypes.bool, }, getInitialState: function() { return {folded: false}; }, componentWillReceiveProps: function(nextProps) { if(nextProps.folded != null) { this.setState({folded: nextProps.folded}); } }, render: function() { // hidden the no category if empty if(!this.props.cat_id && !this.props.feeds.length) { return