From 00ba122b5d6b0929ba6078fc7c1d128cf6e5236e Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Fri, 22 Jan 2016 23:39:12 +0100 Subject: displaying error --- src/web/js/actions/MenuActions.js | 1 + src/web/js/components/Menu.react.js | 38 ++++++++++++++++++++++++------------- src/web/js/stores/MenuStore.js | 4 +++- src/web/views/views.py | 4 ++++ 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/web/js/actions/MenuActions.js b/src/web/js/actions/MenuActions.js index 9502eb6d..c3cc95bc 100644 --- a/src/web/js/actions/MenuActions.js +++ b/src/web/js/actions/MenuActions.js @@ -10,6 +10,7 @@ var MenuActions = { JarrDispatcher.dispatch({ type: MenuActionTypes.RELOAD_MENU, categories: payload.categories, + feed_in_error: payload.feed_in_error, all_unread_count: payload.all_unread_count, }); }); diff --git a/src/web/js/components/Menu.react.js b/src/web/js/components/Menu.react.js index 7f5f17bc..d44e7bd3 100644 --- a/src/web/js/components/Menu.react.js +++ b/src/web/js/components/Menu.react.js @@ -1,6 +1,7 @@ var React = require('react'); var Button = require('react-bootstrap/lib/Button'); var ButtonGroup = require('react-bootstrap/lib/ButtonGroup'); +var Badge = require('react-bootstrap/lib/Badge'); var MenuStore = require('../stores/MenuStore'); var MenuActions = require('../actions/MenuActions'); @@ -10,25 +11,28 @@ 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, }, render: function() { - var unread = undefined; - var icon = undefined; + var icon = null; + var badge_unread = null; + var badge_error = null; if(this.props.icon_url){ icon = (); } else { icon = (); } if(this.props.unread){ - unread = ( - - {this.props.unread} - - ); + badge_unread = {this.props.unread}; + } + if(this.props.error_count == 6) { + badge_unread = error; + } else if(this.props.error_count > 3) { + badge_unread = warn; } return (
  • - {icon} {this.props.title} {unread} + {icon}{this.props.title}{badge_unread}{badge_error}
  • ); }, @@ -56,6 +60,7 @@ var Category = React.createClass({ }).map(function(feed) { return (); }); var unread = undefined; @@ -79,10 +84,18 @@ var Category = React.createClass({ var Menu = React.createClass({ getInitialState: function() { - return {filter: 'all', categories: [], all_unread_count: 0}; + return {filter: 'all', categories: [], + feed_in_error: false, all_unread_count: 0}; }, render: function() { var filter = this.state.filter; + var error_button = null; + if (this.state.feed_in_error) { + error_button = ( + ); + } return (