From 332e5f0cd5c93d99ee81f58d8000cfedd71b8017 Mon Sep 17 00:00:00 2001 From: Mehak Nasir <67791278+mehaknasir@users.noreply.github.com> Date: Mon, 22 Aug 2022 23:29:00 +0500 Subject: [PATCH] MFE fixes (#256) * fix: add response section closed on switching post * fix: response and comments actions removed from close post * fix: undo/redo button moved to first place in editor toolbar * fix: tests are added for closed posts --- src/components/TinyMCEEditor.jsx | 4 ++-- src/discussions/comments/CommentsView.jsx | 11 ++++++++--- src/discussions/comments/CommentsView.test.jsx | 17 +++++++++++++++++ src/discussions/comments/comment/Comment.jsx | 14 +++++++++++--- .../comments/comment/ResponseEditor.jsx | 6 +++++- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/components/TinyMCEEditor.jsx b/src/components/TinyMCEEditor.jsx index 3b935a82..75ca1fcb 100644 --- a/src/components/TinyMCEEditor.jsx +++ b/src/components/TinyMCEEditor.jsx @@ -94,12 +94,12 @@ export default function TinyMCEEditor(props) { autosave_interval: '1s', autosave_restore_when_empty: true, plugins: 'autosave codesample link lists image imagetools code emoticons charmap', - toolbar: 'formatselect | bold italic underline' + toolbar: 'undo redo' + + ' | formatselect | bold italic underline' + ' | link blockquote openedx_code image' + ' | bullist numlist outdent indent' + ' | removeformat' + ' | openedx_html' - + ' | undo redo' + ' | emoticons' + ' | charmap', content_css: false, diff --git a/src/discussions/comments/CommentsView.jsx b/src/discussions/comments/CommentsView.jsx index 1a6c5c43..70e7d160 100644 --- a/src/discussions/comments/CommentsView.jsx +++ b/src/discussions/comments/CommentsView.jsx @@ -58,6 +58,7 @@ function DiscussionCommentsView({ postId, intl, endorsed, + isClosed, }) { const { comments, @@ -74,9 +75,9 @@ function DiscussionCommentsView({
{comments.map(comment => ( - + ))} - {!!comments.length + {!!comments.length && !isClosed && } {hasMorePages && !isLoading && ( + <> + {!isClosedPost + && ( + + )} + ) )}
@@ -137,11 +143,13 @@ Comment.propTypes = { postType: PropTypes.oneOf(['discussion', 'question']).isRequired, comment: commentShape.isRequired, showFullThread: PropTypes.bool, + isClosedPost: PropTypes.bool, intl: intlShape.isRequired, }; Comment.defaultProps = { showFullThread: true, + isClosedPost: false, }; export default injectIntl(Comment); diff --git a/src/discussions/comments/comment/ResponseEditor.jsx b/src/discussions/comments/comment/ResponseEditor.jsx index b95a5b7f..e0f650bd 100644 --- a/src/discussions/comments/comment/ResponseEditor.jsx +++ b/src/discussions/comments/comment/ResponseEditor.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; @@ -16,6 +16,10 @@ function ResponseEditor({ }) { const [addingResponse, setAddingResponse] = useState(false); + useEffect(() => { + setAddingResponse(false); + }, [postId]); + return addingResponse ? (