From b92251b852237c53b51eecc684ab4cf995bb597b Mon Sep 17 00:00:00 2001 From: Wille Marcel Date: Mon, 21 Nov 2022 19:24:48 -0300 Subject: [PATCH] Use SwitchToggle to enable/disable comment preview --- .../src/components/projectDetail/messages.js | 8 +++--- .../projectDetail/questionsAndComments.js | 25 +++++++------------ .../tests/questionsAndComments.test.js | 10 ++++---- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/frontend/src/components/projectDetail/messages.js b/frontend/src/components/projectDetail/messages.js index c516838909..e4423207cc 100644 --- a/frontend/src/components/projectDetail/messages.js +++ b/frontend/src/components/projectDetail/messages.js @@ -133,14 +133,14 @@ export default defineMessages({ id: 'project.detail.questionsAndComments.login', defaultMessage: 'Log in to be able to post comments.', }, - write: { - id: 'project.detail.questionsAndComments.write', - defaultMessage: 'Write', - }, preview: { id: 'project.detail.questionsAndComments.preview', defaultMessage: 'Preview', }, + previewComment: { + id: 'project.detail.questionsAndComments.previewComment', + defaultMessage: 'Preview comment', + }, post: { id: 'project.detail.questionsAndComments.button', defaultMessage: 'Post', diff --git a/frontend/src/components/projectDetail/questionsAndComments.js b/frontend/src/components/projectDetail/questionsAndComments.js index 82de2b9791..aca3bc0b72 100644 --- a/frontend/src/components/projectDetail/questionsAndComments.js +++ b/frontend/src/components/projectDetail/questionsAndComments.js @@ -13,6 +13,7 @@ import { MessageStatus } from '../comments/status'; import { CurrentUserAvatar, UserAvatar } from '../user/avatar'; import { htmlFromMarkdown, formatUserNamesToLink } from '../../utils/htmlFromMarkdown'; import { pushToLocalJSONAPI, fetchLocalJSONAPI } from '../../network/genericJSONRequest'; +import { SwitchToggle } from '../formInputs'; export const PostProjectComment = ({ projectId, updateComments, contributors }) => { const token = useSelector((state) => state.auth.token); @@ -35,22 +36,6 @@ export const PostProjectComment = ({ projectId, updateComments, contributors })
-
- setIsShowPreview(false)} - > - - - setIsShowPreview(true)} - > - - -
+
+ setIsShowPreview(!isShowPreview)} + isChecked={isShowPreview} + label={} + labelPosition='right' + /> +