You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by sh...@apache.org on 2024/07/09 07:33:35 UTC
(incubator-answer) 01/04: fix: ask question page use switch component replace checkbox component
This is an automated email from the ASF dual-hosted git repository.
shuai pushed a commit to branch feat/1.3.6/ui
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 2a7d3a07e41982b5849efbf1cb8008ef35636ad3
Author: shuai <li...@sifou.com>
AuthorDate: Mon Jul 8 11:28:37 2024 +0800
fix: ask question page use switch component replace checkbox component
---
ui/src/pages/Questions/Ask/index.tsx | 76 +++++++++++++--------------
ui/src/pages/Search/components/Tips/index.tsx | 2 +-
2 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/ui/src/pages/Questions/Ask/index.tsx b/ui/src/pages/Questions/Ask/index.tsx
index 40ff73e2..2b370de0 100644
--- a/ui/src/pages/Questions/Ask/index.tsx
+++ b/ui/src/pages/Questions/Ask/index.tsx
@@ -487,52 +487,17 @@ const Ask = () => {
/>
</Form.Group>
- {isEdit && (
- <Form.Group controlId="edit_summary" className="my-3">
- <Form.Label>{t('form.fields.edit_summary.label')}</Form.Label>
- <Form.Control
- type="text"
- defaultValue={formData.edit_summary.value}
- isInvalid={formData.edit_summary.isInvalid}
- placeholder={t('form.fields.edit_summary.placeholder')}
- onChange={handleSummaryChange}
- contentEditable
- />
- <Form.Control.Feedback type="invalid">
- {formData.edit_summary.errorMsg}
- </Form.Control.Feedback>
- </Form.Group>
- )}
- {!checked && (
- <div className="mt-3">
- <Button type="submit" className="me-2">
- {isEdit ? t('btn_save_edits') : t('btn_post_question')}
- </Button>
- {isEdit && (
- <Button variant="link" onClick={backPage}>
- {t('cancel', { keyPrefix: 'btns' })}
- </Button>
- )}
-
- {hasDraft && (
- <Button variant="link" onClick={deleteDraft}>
- {t('discard_draft', { keyPrefix: 'btns' })}
- </Button>
- )}
- </div>
- )}
{!isEdit && (
<>
- <Form.Check
- className="mt-5"
+ <Form.Switch
checked={checked}
- type="checkbox"
+ type="switch"
label={t('answer_question')}
onChange={(e) => setCheckState(e.target.checked)}
id="radio-answer"
/>
{checked && (
- <Form.Group controlId="answer" className="mt-4">
+ <Form.Group controlId="answer" className="mt-3">
<Form.Label>{t('form.fields.answer.label')}</Form.Label>
<Editor
value={formData.answer_content.value}
@@ -562,6 +527,41 @@ const Ask = () => {
)}
</>
)}
+
+ {isEdit && (
+ <Form.Group controlId="edit_summary" className="my-3">
+ <Form.Label>{t('form.fields.edit_summary.label')}</Form.Label>
+ <Form.Control
+ type="text"
+ defaultValue={formData.edit_summary.value}
+ isInvalid={formData.edit_summary.isInvalid}
+ placeholder={t('form.fields.edit_summary.placeholder')}
+ onChange={handleSummaryChange}
+ contentEditable
+ />
+ <Form.Control.Feedback type="invalid">
+ {formData.edit_summary.errorMsg}
+ </Form.Control.Feedback>
+ </Form.Group>
+ )}
+ {!checked && (
+ <div className="mt-3">
+ <Button type="submit" className="me-2">
+ {isEdit ? t('btn_save_edits') : t('btn_post_question')}
+ </Button>
+ {isEdit && (
+ <Button variant="link" onClick={backPage}>
+ {t('cancel', { keyPrefix: 'btns' })}
+ </Button>
+ )}
+
+ {hasDraft && (
+ <Button variant="link" onClick={deleteDraft}>
+ {t('discard_draft', { keyPrefix: 'btns' })}
+ </Button>
+ )}
+ </div>
+ )}
{checked && (
<div className="mt-3">
<Button type="submit">{t('post_question&answer')}</Button>
diff --git a/ui/src/pages/Search/components/Tips/index.tsx b/ui/src/pages/Search/components/Tips/index.tsx
index 2fd151f8..fe6a63d9 100644
--- a/ui/src/pages/Search/components/Tips/index.tsx
+++ b/ui/src/pages/Search/components/Tips/index.tsx
@@ -26,7 +26,7 @@ const Index: FC = () => {
return (
<Card>
<Card.Header>{t('search.tips.title')}</Card.Header>
- <Card.Body className="small ext-secondary">
+ <Card.Body>
<div className="mb-1">
<Trans i18nKey="search.tips.tag" components={{ 1: <code /> }} />
</div>