From 74947520199fe0698f807c6e6312ee3a06b0674f Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Thu, 19 Oct 2017 11:20:09 -0300 Subject: [PATCH] Translations, Proptypes, NoComments Component --- .../src/components/AllCommentsPane.js | 116 +++++++++++------- .../src/components/NoComments.css | 6 + .../src/components/NoComments.js | 25 ++++ locales/en.yml | 2 + locales/es.yml | 2 + 5 files changed, 108 insertions(+), 43 deletions(-) create mode 100644 client/coral-embed-stream/src/components/NoComments.css create mode 100644 client/coral-embed-stream/src/components/NoComments.js diff --git a/client/coral-embed-stream/src/components/AllCommentsPane.js b/client/coral-embed-stream/src/components/AllCommentsPane.js index 7602902df..2967b9972 100644 --- a/client/coral-embed-stream/src/components/AllCommentsPane.js +++ b/client/coral-embed-stream/src/components/AllCommentsPane.js @@ -1,10 +1,11 @@ import React from 'react'; - +import PropTypes from 'prop-types'; import LoadMore from './LoadMore'; import NewCount from './NewCount'; import {TransitionGroup} from 'react-transition-group'; import {forEachError} from 'coral-framework/utils'; import Comment from '../containers/Comment'; +import NoComments from './NoComments'; const hasComment = (nodes, id) => nodes.some((node) => node.id === id); @@ -144,53 +145,82 @@ class AllCommentsPane extends React.Component { } = this.props; const {loadingState} = this.state; - const view = this.getVisibleComments(); + const visibleComments = this.getVisibleComments(); return ( -
- - - {view.map((comment) => { - return ( - - ); - })} - - +
+ {visibleComments.length ? ( +
+ + + {visibleComments.map((comment) => { + return ( + + ); + })} + + +
+ ) : ( + + )}
); } } +AllCommentsPane.propTypes = { + data: PropTypes.object, + root: PropTypes.object, + comments: PropTypes.object, + commentClassNames: PropTypes.array, + setActiveReplyBox: PropTypes.func, + activeReplyBox: PropTypes.string, + notify: PropTypes.func, + disableReply: PropTypes.bool, + postComment: PropTypes.func, + asset: PropTypes.object, + currentUser: PropTypes.object, + postFlag: PropTypes.func, + postDontAgree: PropTypes.func, + loadNewReplies: PropTypes.func, + deleteAction: PropTypes.func, + showSignInDialog: PropTypes.func, + charCountEnable: PropTypes.bool, + maxCharCount: PropTypes.number, + editComment: PropTypes.func, + emit: PropTypes.func, +}; + export default AllCommentsPane; diff --git a/client/coral-embed-stream/src/components/NoComments.css b/client/coral-embed-stream/src/components/NoComments.css new file mode 100644 index 000000000..51dc053f5 --- /dev/null +++ b/client/coral-embed-stream/src/components/NoComments.css @@ -0,0 +1,6 @@ +.message { + padding: 20px 10px; + background-color: #f7f7f7; + margin: 20px 0; + text-align: center; +} \ No newline at end of file diff --git a/client/coral-embed-stream/src/components/NoComments.js b/client/coral-embed-stream/src/components/NoComments.js new file mode 100644 index 000000000..378c908d6 --- /dev/null +++ b/client/coral-embed-stream/src/components/NoComments.js @@ -0,0 +1,25 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import cn from 'classnames'; +import t from 'coral-framework/services/i18n'; +import styles from './NoComments.css'; + +const NoComments = ({assetClosed}) => ( +
+ {assetClosed ? ( +
+ {t('stream.no_comments_and_closed')} +
+ ) : ( +
+ {t('stream.no_comments')} +
+ )} +
+); + +NoComments.propTypes = { + assetClosed: PropTypes.bool, +}; + +export default NoComments; diff --git a/locales/en.yml b/locales/en.yml index 76e0f4bac..2d560fedc 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -325,6 +325,8 @@ en: all_comments: "All Comments" temporarily_suspended: "In accordance with {0}'s community guidelines, your account has been temporarily suspended. Please rejoin the conversation {1}." comment_not_found: "Comment was not found" + no_comments: "There are no comments yet, why don’t you write one?" + no_comments_and_closed: "There were no comments on this article." step_1_header: "Report an issue" step_2_header: "Help us understand" step_3_header: "Thank you for your input" diff --git a/locales/es.yml b/locales/es.yml index de3d06692..3f01b8457 100644 --- a/locales/es.yml +++ b/locales/es.yml @@ -350,6 +350,8 @@ es: all_comments: "Todos los comentarios" temporarily_suspended: "De acuerdo con la guía de la comunidad de {0}, su cuenta ha sido temporalmente suspendida. Por favor unirse a la conversación {1}." comment_not_found: "Comentario no encontrado" + no_comments: "Todavía no hay comentarios. ¿Por qué no escribes uno?" + no_comments_and_closed: "No hubo comentarios en este artículo." streams: all: "Todos" article: "Artículo"