fix: hide edit reason dropdown while adding a comment or response (#142)

* fix: hide edit reason dropdown while adding a comment or response
This commit is contained in:
Awais Ansari
2022-04-21 22:05:21 +05:00
committed by GitHub
parent 34a0ae8939
commit a77b947e8a
3 changed files with 15 additions and 2 deletions

View File

@@ -112,6 +112,7 @@ function Comment({
threadId: comment.threadId,
parentId: comment.id,
}}
edit={false}
onCloseEditor={() => setReplying(false)}
/>
)

View File

@@ -20,6 +20,7 @@ function CommentEditor({
intl,
comment,
onCloseEditor,
edit,
}) {
const { authenticatedUser } = useContext(AppContext);
const userIsPrivileged = useSelector(selectUserIsPrivileged);
@@ -65,7 +66,9 @@ function CommentEditor({
<Form onSubmit={handleSubmit}>
{(reasonCodesEnabled
&& userIsPrivileged
&& comment.author !== authenticatedUser.username) && (
&& comment.author !== authenticatedUser.username
&& edit
) && (
<Form.Group>
<Form.Control
name="editReasonCode"
@@ -142,6 +145,11 @@ CommentEditor.propTypes = {
}).isRequired,
onCloseEditor: PropTypes.func.isRequired,
intl: intlShape.isRequired,
edit: PropTypes.bool,
};
CommentEditor.defaultProps = {
edit: true,
};
export default injectIntl(CommentEditor);

View File

@@ -14,7 +14,11 @@ function ResponseEditor({
const [addingResponse, setAddingResponse] = useState(false);
return addingResponse
? (
<CommentEditor comment={{ threadId: postId }} onCloseEditor={() => setAddingResponse(false)} />
<CommentEditor
comment={{ threadId: postId }}
edit={false}
onCloseEditor={() => setAddingResponse(false)}
/>
) : (
<div className="actions d-flex">
<Button variant="primary" onClick={() => setAddingResponse(true)}>