From 2f94674b78dce39565a5813d0f44cdd508cbceae Mon Sep 17 00:00:00 2001 From: okbel Date: Tue, 8 May 2018 11:08:46 -0300 Subject: [PATCH] Adding CommentDeletedTombstone --- .../src/components/CommentAnimatedEdit.js | 2 +- .../components/CommentDeletedTombstone.css | 5 + .../src/components/CommentDeletedTombstone.js | 8 ++ .../src/components/UserDetailComment.js | 87 +++++++------ .../routes/Moderation/components/Comment.js | 83 ++++++------ .../components/ChangeUsernameDialog.css | 84 ++++++++++++ .../client/components/ChangeUsernameDialog.js | 120 ++++++++++++++++++ 7 files changed, 308 insertions(+), 81 deletions(-) create mode 100644 client/coral-admin/src/components/CommentDeletedTombstone.css create mode 100644 client/coral-admin/src/components/CommentDeletedTombstone.js create mode 100644 plugins/talk-plugin-local-auth/client/components/ChangeUsernameDialog.css create mode 100644 plugins/talk-plugin-local-auth/client/components/ChangeUsernameDialog.js diff --git a/client/coral-admin/src/components/CommentAnimatedEdit.js b/client/coral-admin/src/components/CommentAnimatedEdit.js index 12280b204..f43cb9c89 100644 --- a/client/coral-admin/src/components/CommentAnimatedEdit.js +++ b/client/coral-admin/src/components/CommentAnimatedEdit.js @@ -29,7 +29,7 @@ const CommentAnimatedEdit = ({ children, body }) => { CommentAnimatedEdit.propTypes = { children: PropTypes.node, - body: PropTypes.string, + body: PropTypes.string.isRequired, }; export default CommentAnimatedEdit; diff --git a/client/coral-admin/src/components/CommentDeletedTombstone.css b/client/coral-admin/src/components/CommentDeletedTombstone.css new file mode 100644 index 000000000..81f5ddf7a --- /dev/null +++ b/client/coral-admin/src/components/CommentDeletedTombstone.css @@ -0,0 +1,5 @@ +.tombstone { + background-color: #f0f0f0; + padding: 1em; + color: #1a212f; +} \ No newline at end of file diff --git a/client/coral-admin/src/components/CommentDeletedTombstone.js b/client/coral-admin/src/components/CommentDeletedTombstone.js new file mode 100644 index 000000000..db9a609b1 --- /dev/null +++ b/client/coral-admin/src/components/CommentDeletedTombstone.js @@ -0,0 +1,8 @@ +import React from 'react'; +import styles from './CommentDeletedTombstone.css'; + +const CommentDeletedTombstone = () => ( +
The comment was deleted.
+); + +export default CommentDeletedTombstone; diff --git a/client/coral-admin/src/components/UserDetailComment.js b/client/coral-admin/src/components/UserDetailComment.js index f2ff2e932..f7a500203 100644 --- a/client/coral-admin/src/components/UserDetailComment.js +++ b/client/coral-admin/src/components/UserDetailComment.js @@ -12,6 +12,7 @@ import CommentAnimatedEdit from './CommentAnimatedEdit'; import CommentLabels from '../containers/CommentLabels'; import ApproveButton from './ApproveButton'; import RejectButton from 'coral-admin/src/components/RejectButton'; +import CommentDeletedTombstone from './CommentDeletedTombstone'; import t, { timeago } from 'coral-framework/services/i18n'; @@ -83,49 +84,53 @@ class UserDetailComment extends React.Component { } - -
-
- - - {t('comment.view_context')} - -
-
- - - {/* TODO: translate string */} - Contains Link - - -
- - +
+ +
+ + + {/* TODO: translate string */} + Contains Link + + +
+ + +
-
- + + ) : ( + + )}
@@ -152,7 +157,7 @@ UserDetailComment.propTypes = { comment: PropTypes.shape({ id: PropTypes.string.isRequired, status: PropTypes.string.isRequired, - body: PropTypes.string.isRequired, + body: PropTypes.string, actions: PropTypes.array, created_at: PropTypes.string.isRequired, asset: PropTypes.shape({ diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.js b/client/coral-admin/src/routes/Moderation/components/Comment.js index 28dcf8ca8..137bd9381 100644 --- a/client/coral-admin/src/routes/Moderation/components/Comment.js +++ b/client/coral-admin/src/routes/Moderation/components/Comment.js @@ -13,6 +13,7 @@ import IfHasLink from 'coral-admin/src/components/IfHasLink'; import cn from 'classnames'; import ApproveButton from 'coral-admin/src/components/ApproveButton'; import RejectButton from 'coral-admin/src/components/RejectButton'; +import CommentDeletedTombstone from '../../../components/CommentDeletedTombstone'; import t, { timeago } from 'coral-framework/services/i18n'; @@ -133,48 +134,52 @@ class Comment extends React.Component { )}
- -
-
- -
- - {t('comment.view_context')} - + {comment.body ? ( + + -
- - - {/* TODO: translate string */} - Contains Link - - -
- - +
+ + + {/* TODO: translate string */} + Contains Link + + +
+ + +
+
-
-
-
+ + ) : ( + + )}
{ + this.setState({ + showError: true, + }); + }; + + confirmChanges = async () => { + if (this.formHasError()) { + this.showError(); + return; + } + + if (!this.props.canUsernameBeUpdated) { + this.props.notify( + 'error', + t('talk-plugin-local-auth.change_username.change_username_attempt') + ); + return; + } + + await this.props.saveChanges(); + this.props.closeDialog(); + }; + + formHasError = () => + this.props.formData.confirmNewUsername !== this.props.formData.newUsername; + + render() { + return ( + + + × + +

+ {t('talk-plugin-local-auth.change_username.confirm_username_change')} +

+
+

+ {t('talk-plugin-local-auth.change_username.description')} +

+
+ + {t('talk-plugin-local-auth.change_username.old_username')}:{' '} + {this.props.username} + + + {t('talk-plugin-local-auth.change_username.new_username')}:{' '} + {this.props.formData.newUsername} + +
+
+ + + {t('talk-plugin-local-auth.change_username.bottom_note')} + + +
+
+ + +
+
+
+ ); + } +} + +ChangeUsernameDialog.propTypes = { + saveChanges: PropTypes.func, + closeDialog: PropTypes.func, + showDialog: PropTypes.bool, + onChange: PropTypes.func, + username: PropTypes.string, + formData: PropTypes.object, + canUsernameBeUpdated: PropTypes.bool.isRequired, + notify: PropTypes.func.isRequired, +}; + +export default ChangeUsernameDialog;