From 41f7b1b9cd3a9fdc7ed7a1fa773f1d52160ae7f3 Mon Sep 17 00:00:00 2001 From: shuai Date: Thu, 17 Aug 2023 11:27:58 +0800 Subject: [PATCH 1/2] fix: add form text for install private --- i18n/en_US.yaml | 1 + ui/src/pages/Install/components/FourthStep/index.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml index c28b0352d..fabaaf3e2 100644 --- a/i18n/en_US.yaml +++ b/i18n/en_US.yaml @@ -1262,6 +1262,7 @@ ui: login_required: label: Private switch: Login required + text: Only logged in users can access this community. admin_name: label: Name msg: Name cannot be empty. diff --git a/ui/src/pages/Install/components/FourthStep/index.tsx b/ui/src/pages/Install/components/FourthStep/index.tsx index 8e6e2b0e5..c8d0eb2c2 100644 --- a/ui/src/pages/Install/components/FourthStep/index.tsx +++ b/ui/src/pages/Install/components/FourthStep/index.tsx @@ -210,6 +210,7 @@ const Index: FC = ({ visible, data, changeCallback, nextCallback }) => { }); }} /> + {t('login_required.text')}
{t('admin_account')}
From 80df5193c530b5590e6fb65f3dc91ac9601a01c3 Mon Sep 17 00:00:00 2001 From: shuai Date: Mon, 21 Aug 2023 15:32:57 +0800 Subject: [PATCH 2/2] feat: personal setting notification change --- i18n/en_US.yaml | 13 ++- ui/src/common/interface.ts | 12 ++- .../SchemaForm/components/Check.tsx | 7 +- ui/src/components/SchemaForm/index.tsx | 9 +- ui/src/components/SchemaForm/types.ts | 2 +- ui/src/pages/Tags/Detail/index.tsx | 15 ++- .../Users/Settings/Notification/index.tsx | 95 +++++++++++++------ ui/src/services/client/settings.ts | 13 +++ 8 files changed, 125 insertions(+), 41 deletions(-) diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml index fabaaf3e2..d80846237 100644 --- a/i18n/en_US.yaml +++ b/i18n/en_US.yaml @@ -962,9 +962,16 @@ ui: placeholder: "City, Country" notification: heading: Notifications - email: - label: Email Notifications - radio: "Answers to your questions, comments, and more" + email: Email + inbox: + label: Inbox notifications + description: Answers to your questions, comments, invites, and more. + all_new_question: + label: All new questions + description: Get notified of all new questions. Up to 50 questions per week. + all_new_question_for_following_tags: + label: All new questions for following tags + description: Get notified of new questions for following tags. account: heading: Account change_email_btn: Change email diff --git a/ui/src/common/interface.ts b/ui/src/common/interface.ts index f86d60a3d..97e9bac00 100644 --- a/ui/src/common/interface.ts +++ b/ui/src/common/interface.ts @@ -57,7 +57,7 @@ export interface TagInfo extends TagBase { main_tag_slug_name?: string; excerpt?; } -export interface QuestionParams extends ImgCodeReq{ +export interface QuestionParams extends ImgCodeReq { title: string; url_title?: string; content: string; @@ -589,3 +589,13 @@ export interface UserOauthConnectorItem { binding: boolean; external_id: string; } + +export interface NotificationConfigItem { + enable: boolean; + key: string; +} +export interface NotificationConfig { + all_new_question: NotificationConfigItem[]; + all_new_question_for_following_tags: NotificationConfigItem[]; + inbox: NotificationConfigItem[]; +} diff --git a/ui/src/components/SchemaForm/components/Check.tsx b/ui/src/components/SchemaForm/components/Check.tsx index fd18fb897..23e5d5201 100644 --- a/ui/src/components/SchemaForm/components/Check.tsx +++ b/ui/src/components/SchemaForm/components/Check.tsx @@ -27,12 +27,13 @@ const Index: FC = ({ index: number, ) => { const { name, checked } = evt.currentTarget; - const freshVal = checked ? enumValues?.[index] : ''; + enumValues[index] = checked; + const state = { ...formData, [name]: { ...formData[name], - value: freshVal, + value: enumValues, isInvalid: false, }, }; @@ -51,7 +52,7 @@ const Index: FC = ({ name={fieldName} id={`form-${String(item)}`} label={enumNames?.[index]} - checked={(fieldObject?.value || '') === item} + checked={fieldObject?.value?.[index] || false} feedback={fieldObject?.errorMsg} feedbackType="invalid" isInvalid={fieldObject?.isInvalid} diff --git a/ui/src/components/SchemaForm/index.tsx b/ui/src/components/SchemaForm/index.tsx index 16ea9daba..a82ae8a04 100644 --- a/ui/src/components/SchemaForm/index.tsx +++ b/ui/src/components/SchemaForm/index.tsx @@ -386,8 +386,13 @@ export const initFormData = (schema: JSONSchema): Type.FormDataType => { const props: JSONSchema['properties'] = schema?.properties || {}; Object.keys(props).forEach((key) => { const prop = props[key]; - const defaultVal = prop?.default; - + let defaultVal: any = ''; + if (Array.isArray(prop.default) && prop.enum && prop.enum.length > 0) { + // for checkbox default values + defaultVal = prop.enum; + } else { + defaultVal = prop?.default; + } formData[key] = { value: defaultVal, isInvalid: false, diff --git a/ui/src/components/SchemaForm/types.ts b/ui/src/components/SchemaForm/types.ts index f22e6b897..cbb48fb2c 100644 --- a/ui/src/components/SchemaForm/types.ts +++ b/ui/src/components/SchemaForm/types.ts @@ -30,7 +30,7 @@ export interface JSONSchema { description?: string; enum?: Array; enumNames?: string[]; - default?: string | boolean | number; + default?: string | boolean | number | any[]; }; }; } diff --git a/ui/src/pages/Tags/Detail/index.tsx b/ui/src/pages/Tags/Detail/index.tsx index ce8924958..5818b447a 100644 --- a/ui/src/pages/Tags/Detail/index.tsx +++ b/ui/src/pages/Tags/Detail/index.tsx @@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next'; import { usePageTags } from '@/hooks'; import * as Type from '@/common/interface'; -import { FollowingTags, CustomSidebar } from '@/components'; +import { FollowingTags, CustomSidebar, Icon } from '@/components'; import { useTagInfo, useFollow, @@ -141,9 +141,16 @@ const Index: FC = () => {
{tagInfo.is_follower ? ( - +
+ + + + +
) : (