From 399c33c946f0e75cb2a5a7adae63e93bd5aea987 Mon Sep 17 00:00:00 2001 From: shuai Date: Thu, 9 Feb 2023 16:32:24 +0800 Subject: [PATCH 1/6] fix: prompt that the browser version is too low #192 --- ui/public/index.html | 82 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/ui/public/index.html b/ui/public/index.html index 0cbf8d29..756d074c 100644 --- a/ui/public/index.html +++ b/ui/public/index.html @@ -16,6 +16,10 @@ #spin-mask { display: none !important; } + + #protect-brower { + display: none; + }
+
+ From 1111becfd010407be06de7323d4d2128eafc6e03 Mon Sep 17 00:00:00 2001 From: shuai Date: Thu, 9 Feb 2023 16:39:03 +0800 Subject: [PATCH 2/6] fix: punctuation marks --- .vscode/extensions.json | 5 +++++ ui/public/index.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..28d95959 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "github.copilot" + ] +} diff --git a/ui/public/index.html b/ui/public/index.html index 756d074c..d4bd25a0 100644 --- a/ui/public/index.html +++ b/ui/public/index.html @@ -135,7 +135,7 @@ if (notSupport) { const div = document.getElementById('protect-brower'); - div.innerText = 'The current browser version is too low, in order not to affect the normal use of the function, please upgrade the browser to the latest version' + div.innerText = 'The current browser version is too low, in order not to affect the normal use of the function, please upgrade the browser to the latest version.' } From d005507d551bb8ff324fbefcdcf4717e9fcdfeba Mon Sep 17 00:00:00 2001 From: shuai Date: Mon, 13 Feb 2023 15:23:20 +0800 Subject: [PATCH 3/6] fix: cancel the front-end verification on the question page --- ui/src/pages/Questions/Ask/index.tsx | 58 ++++------------------------ ui/src/utils/common.ts | 7 ++++ 2 files changed, 14 insertions(+), 51 deletions(-) diff --git a/ui/src/pages/Questions/Ask/index.tsx b/ui/src/pages/Questions/Ask/index.tsx index b5cce8db..da0897f3 100644 --- a/ui/src/pages/Questions/Ask/index.tsx +++ b/ui/src/pages/Questions/Ask/index.tsx @@ -110,25 +110,25 @@ const Ask = () => { const handleTitleChange = (e: React.ChangeEvent) => { setFormData({ ...formData, - title: { ...formData.title, value: e.currentTarget.value }, + title: { ...formData.title, value: e.currentTarget.value, errorMsg: '' }, }); }; const handleContentChange = (value: string) => { setFormData({ ...formData, - content: { ...formData.content, value }, + content: { ...formData.content, value, errorMsg: '' }, }); }; const handleTagsChange = (value) => setFormData({ ...formData, - tags: { ...formData.tags, value }, + tags: { ...formData.tags, value, errorMsg: '' }, }); const handleAnswerChange = (value: string) => setFormData({ ...formData, - answer: { ...formData.answer, value }, + answer: { ...formData.answer, value, errorMsg: '' }, }); const handleSummaryChange = (evt: React.ChangeEvent) => @@ -140,55 +140,9 @@ const Ask = () => { }, }); - const checkValidated = (): boolean => { - const bol = true; - const { title, content, tags, answer } = formData; - if (title.value && Array.from(title.value).length <= 150) { - formData.title = { - value: title.value, - isInvalid: false, - errorMsg: '', - }; - } - - if (content.value) { - formData.content = { - value: content.value, - isInvalid: false, - errorMsg: '', - }; - } - - if (Array.isArray(tags.value) && tags.value.length > 0) { - formData.tags = { - value: tags.value, - isInvalid: false, - errorMsg: '', - }; - } - - if (checked) { - if (answer.value) { - formData.answer = { - value: answer.value, - isInvalid: false, - errorMsg: '', - }; - } - } - - setFormData({ - ...formData, - }); - return bol; - }; - const handleSubmit = async (event: React.FormEvent) => { event.preventDefault(); event.stopPropagation(); - if (!checkValidated()) { - return; - } const params: Type.QuestionParams = { title: formData.title.value, @@ -232,7 +186,9 @@ const Ask = () => { }) .catch((err) => { if (err.isError) { - const data = handleFormError(err, formData); + const data = handleFormError(err, formData, [ + { from: 'content', to: 'answer' }, + ]); setFormData({ ...data }); } }); diff --git a/ui/src/utils/common.ts b/ui/src/utils/common.ts index c48c01bd..6cd8f8ec 100644 --- a/ui/src/utils/common.ts +++ b/ui/src/utils/common.ts @@ -168,9 +168,16 @@ function labelStyle(color, hover) { function handleFormError( error: { list: Array<{ error_field: string; error_msg: string }> }, data: any, + keymap?: Array<{ from: string; to: string }>, ) { if (error.list?.length > 0) { error.list.forEach((item) => { + if (keymap?.length) { + const key = keymap.find((k) => k.from === item.error_field); + if (key) { + item.error_field = key.to; + } + } const errorFieldObject = data[item.error_field]; if (errorFieldObject) { errorFieldObject.isInvalid = true; From 8a0f4f1600901bb658464eccf5b7fb1d99e7e9c8 Mon Sep 17 00:00:00 2001 From: shuai Date: Mon, 13 Feb 2023 16:42:08 +0800 Subject: [PATCH 4/6] fix: form optional translation field unification --- i18n/en_US.yaml | 37 ++++++++----------- ui/src/components/Editor/ToolBars/code.tsx | 7 +++- ui/src/components/Editor/ToolBars/image.tsx | 11 +++++- ui/src/components/Editor/ToolBars/link.tsx | 7 +++- ui/src/hooks/useTagModal/index.tsx | 4 +- ui/src/pages/Admin/Branding/index.tsx | 14 +++++-- ui/src/pages/Admin/General/index.tsx | 8 +++- ui/src/pages/Users/Settings/Profile/index.tsx | 14 +++++-- 8 files changed, 66 insertions(+), 36 deletions(-) diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml index e02c3382..f00aa68e 100644 --- a/i18n/en_US.yaml +++ b/i18n/en_US.yaml @@ -324,7 +324,7 @@ ui: msg: empty: Code cannot be empty. language: - label: Language (optional) + label: Language placeholder: Automatic detection btn_cancel: Cancel btn_confirm: Add @@ -360,7 +360,7 @@ ui: only_image: Only image files are allowed. max_size: File size cannot exceed 4MB. desc: - label: Description (optional) + label: Description tab_url: Image URL form_url: fields: @@ -369,7 +369,7 @@ ui: msg: empty: Image URL cannot be empty. name: - label: Description (optional) + label: Description btn_cancel: Cancel btn_confirm: Add uploading: Uploading @@ -389,7 +389,7 @@ ui: msg: empty: URL cannot be empty. name: - label: Description (optional) + label: Description btn_cancel: Cancel btn_confirm: Add ordered_list: @@ -437,7 +437,7 @@ ui: range: URL slug up to 35 characters. character: URL slug contains unallowed character set. desc: - label: Description (optional) + label: Description btn_cancel: Cancel btn_submit: Submit tag_info: @@ -705,13 +705,13 @@ ui: default: System msg: Please upload an avatar bio: - label: About Me (optional) + label: About Me website: - label: Website (optional) + label: Website placeholder: "https://example.com" msg: Website incorrect format location: - label: Location (optional) + label: Location placeholder: "City, Country" notification: heading: Notifications @@ -1208,11 +1208,11 @@ ui: validate: Please enter a valid URL. text: The address of your site. short_desc: - label: Short Site Description (optional) + label: Short Site Description msg: Short site description cannot be empty. text: "Short description, as used in the title tag on homepage." desc: - label: Site Description (optional) + label: Site Description msg: Site description cannot be empty. text: "Describe this site in one sentence, as used in the meta description tag." contact_email: @@ -1222,14 +1222,6 @@ ui: text: Email address of key contact responsible for this site. interface: page_title: Interface - logo: - label: Logo (optional) - msg: Site logo cannot be empty. - text: You can upload your image or <1>reset it to the site title text. - theme: - label: Theme - msg: Theme cannot be empty. - text: Select an existing theme. language: label: Interface Language msg: Interface language cannot be empty. @@ -1281,18 +1273,18 @@ ui: branding: page_title: Branding logo: - label: Logo (optional) + label: Logo msg: Logo cannot be empty. text: The logo image at the top left of your site. Use a wide rectangular image with a height of 56 and an aspect ratio greater than 3:1. If left blank, the site title text will be shown. mobile_logo: - label: Mobile Logo (optional) + label: Mobile Logo text: The logo used on mobile version of your site. Use a wide rectangular image with a height of 56. If left blank, the image from the "logo" setting will be used. square_icon: - label: Square Icon (optional) + label: Square Icon msg: Square icon cannot be empty. text: Image used as the base for metadata icons. Should ideally be larger than 512x512. favicon: - label: Favicon (optional) + label: Favicon text: A favicon for your site. To work correctly over a CDN it must be a png. Will be resized to 32x32. If left blank, "square icon" will be used. legal: page_title: Legal @@ -1359,6 +1351,7 @@ ui: text: Only logged in users can access this community. form: + optional: (optional) empty: cannot be empty invalid: is invalid btn_submit: Save diff --git a/ui/src/components/Editor/ToolBars/code.tsx b/ui/src/components/Editor/ToolBars/code.tsx index 404077a6..5e12195a 100644 --- a/ui/src/components/Editor/ToolBars/code.tsx +++ b/ui/src/components/Editor/ToolBars/code.tsx @@ -239,7 +239,12 @@ const Code: FC = ({ editor, wrapText }) => { )} - {t('code.form.fields.language.label')} + {`${t('code.form.fields.language.label')} ${t( + 'optional', + { + keyPrefix: 'form', + }, + )}`}