From 0fd70ec4419d5d79a1cf2d8c03fb9ce571f93c95 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 23 Dec 2016 17:07:21 -0300 Subject: [PATCH] Ivan - Add error messages for admin articles view [skip ci] --- client/src/app-components/articles-list.js | 7 +++++++ client/src/app-components/people-list.js | 2 +- client/src/data/languages/en.js | 1 + client/src/reducers/articles-reducer.js | 11 +++++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/client/src/app-components/articles-list.js b/client/src/app-components/articles-list.js index ed77d30c..586babc3 100644 --- a/client/src/app-components/articles-list.js +++ b/client/src/app-components/articles-list.js @@ -11,6 +11,7 @@ import TopicEditModal from 'app-components/topic-edit-modal'; import Loading from 'core-components/loading'; import Button from 'core-components/button'; import Icon from 'core-components/icon'; +import Message from 'core-components/message'; class ArticlesList extends React.Component { @@ -18,6 +19,7 @@ class ArticlesList extends React.Component { editable: React.PropTypes.bool, articlePath: React.PropTypes.string, loading: React.PropTypes.bool, + errored: React.PropTypes.bool, topics: React.PropTypes.array, retrieveOnMount: React.PropTypes.bool }; @@ -34,6 +36,10 @@ class ArticlesList extends React.Component { } render() { + if(this.props.errored) { + return {i18n('ERROR_RETRIEVING_ARTICLES')}; + } + return (this.props.loading) ? : this.renderContent(); } @@ -84,6 +90,7 @@ class ArticlesList extends React.Component { export default connect((store) => { return { topics: store.articles.topics, + errored: store.articles.errored, loading: store.articles.loading }; })(ArticlesList); diff --git a/client/src/app-components/people-list.js b/client/src/app-components/people-list.js index 70a37feb..6a636bd3 100644 --- a/client/src/app-components/people-list.js +++ b/client/src/app-components/people-list.js @@ -10,7 +10,7 @@ class PeopleList extends React.Component { static propTypes = { list: React.PropTypes.arrayOf(React.PropTypes.shape({ profilePic: React.PropTypes.string, - name: React.PropTypes.string, + name: React.PropTypes.node, assignedTickets: React.PropTypes.number, closedTickets: React.PropTypes.number, lastLogin: React.PropTypes.number diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index 0f3e9c88..7ab3af00 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -165,6 +165,7 @@ export default { 'ERROR_RETRIEVING_USERS': 'An error occurred while trying to retrieve users.', 'ERROR_RETRIEVING_BAN_LIST': 'An error occurred while trying to retrieve the list of banned emails.', 'ERROR_BANNING_EMAIL': 'An error occurred while trying to ban the email.', + 'ERROR_RETRIEVING_ARTICLES': 'An error occurred while trying to retrieve articles.', //MESSAGES 'SIGNUP_SUCCESS': 'You have registered successfully in our support system.', diff --git a/client/src/reducers/articles-reducer.js b/client/src/reducers/articles-reducer.js index fcc5a537..5bdf9ace 100644 --- a/client/src/reducers/articles-reducer.js +++ b/client/src/reducers/articles-reducer.js @@ -9,6 +9,7 @@ class ArticlesReducer extends Reducer { return { retrieved: false, loading: true, + errored: false, topics: [] }; } @@ -16,6 +17,7 @@ class ArticlesReducer extends Reducer { getTypeHandlers() { return { 'GET_ARTICLES_FULFILLED': this.onArticlesRetrieved, + 'GET_ARTICLES_REJECTED': this.onArticlesRejected, 'INIT_ARTICLES': this.onInitArticles }; } @@ -26,10 +28,19 @@ class ArticlesReducer extends Reducer { return _.extend({}, state, { retrieved: true, loading: false, + errored: false, topics: payload.data }); } + onArticlesRejected(state) { + return _.extend({}, state, { + retrieved: true, + loading: false, + errored: true + }); + } + onInitArticles(state) { let topics = SessionStore.getItem('topics');