diff --git a/ui/src/components/SchemaForm/index.tsx b/ui/src/components/SchemaForm/index.tsx index f811e81b..6c245d24 100644 --- a/ui/src/components/SchemaForm/index.tsx +++ b/ui/src/components/SchemaForm/index.tsx @@ -20,7 +20,6 @@ export interface JSONSchema { [key: string]: { type: 'string' | 'boolean' | 'number'; title: string; - label?: string; description?: string; enum?: Array; enumNames?: string[]; @@ -61,7 +60,9 @@ export interface UploadOptions extends BaseUIOptions { imageType?: Type.UploadType; } -export interface SwitchOptions extends BaseUIOptions {} +export interface SwitchOptions extends BaseUIOptions { + label?: string; +} export interface TimezoneOptions extends BaseUIOptions { placeholder?: string; @@ -172,7 +173,6 @@ const SchemaForm: ForwardRefRenderFunction = ( isInvalid: false, value: metaProp.enum?.[0], }; - console.log('formData[k]: ', k, formData[k]); } }); }; @@ -348,13 +348,13 @@ const SchemaForm: ForwardRefRenderFunction = ( useImperativeHandle(ref, () => ({ validator, })); - + console.log('uiSchema: ', uiSchema); return (
{keys.map((key) => { - const { title, description, label } = properties[key]; - const { 'ui:widget': widget = 'input' } = uiSchema[key] || {}; - + const { title, description } = properties[key]; + const { 'ui:widget': widget = 'input', 'ui:options': uiOpt } = + uiSchema[key] || {}; if (widget === 'select') { return ( = ( id={`switch-${title}`} name={key} type="switch" - label={label} + label={(uiOpt as SwitchOptions)?.label} checked={formData[key]?.value || ''} feedback={formData[key]?.errorMsg} feedbackType="invalid" diff --git a/ui/src/pages/Admin/Login/index.tsx b/ui/src/pages/Admin/Login/index.tsx index 4e3b93e2..33cf73de 100644 --- a/ui/src/pages/Admin/Login/index.tsx +++ b/ui/src/pages/Admin/Login/index.tsx @@ -19,14 +19,12 @@ const Index: FC = () => { allow_new_registrations: { type: 'boolean', title: t('membership.title'), - label: t('membership.label'), description: t('membership.text'), default: false, }, login_required: { type: 'boolean', title: t('private.title'), - label: t('private.label'), description: t('private.text'), default: false, }, @@ -35,9 +33,15 @@ const Index: FC = () => { const uiSchema: UISchema = { allow_new_registrations: { 'ui:widget': 'switch', + 'ui:options': { + label: t('membership.label'), + }, }, login_required: { 'ui:widget': 'switch', + 'ui:options': { + label: t('private.label'), + }, }, }; const [formData, setFormData] = useState(initFormData(schema)); diff --git a/ui/src/pages/Admin/Smtp/index.tsx b/ui/src/pages/Admin/Smtp/index.tsx index c39591c5..3a625157 100644 --- a/ui/src/pages/Admin/Smtp/index.tsx +++ b/ui/src/pages/Admin/Smtp/index.tsx @@ -47,7 +47,6 @@ const Smtp: FC = () => { smtp_authentication: { type: 'boolean', title: t('smtp_authentication.title'), - label: t('smtp_authentication.label'), enum: [true, false], enumNames: [t('smtp_authentication.yes'), t('smtp_authentication.no')], }, @@ -102,6 +101,9 @@ const Smtp: FC = () => { }, smtp_authentication: { 'ui:widget': 'switch', + 'ui:options': { + label: t('smtp_authentication.label'), + }, }, smtp_port: { 'ui:options': { diff --git a/ui/src/pages/Admin/Write/index.tsx b/ui/src/pages/Admin/Write/index.tsx index 1df9788f..6020a4d8 100644 --- a/ui/src/pages/Admin/Write/index.tsx +++ b/ui/src/pages/Admin/Write/index.tsx @@ -27,7 +27,6 @@ const Index: FC = () => { required_tag: { type: 'boolean', title: t('required_tag.title'), - label: t('required_tag.label'), description: t('required_tag.text'), }, reserved_tags: { @@ -46,6 +45,9 @@ const Index: FC = () => { }, required_tag: { 'ui:widget': 'switch', + 'ui:options': { + label: t('required_tag.label'), + }, }, reserved_tags: { 'ui:widget': 'textarea', diff --git a/ui/src/pages/Users/Settings/Notification/index.tsx b/ui/src/pages/Users/Settings/Notification/index.tsx index e970fd18..28869caf 100644 --- a/ui/src/pages/Users/Settings/Notification/index.tsx +++ b/ui/src/pages/Users/Settings/Notification/index.tsx @@ -17,7 +17,6 @@ const Index = () => { notice_switch: { type: 'boolean', title: t('email.label'), - label: t('email.radio'), default: false, }, }, @@ -25,6 +24,9 @@ const Index = () => { const uiSchema: UISchema = { notice_switch: { 'ui:widget': 'switch', + 'ui:options': { + label: t('email.radio'), + }, }, }; const [formData, setFormData] = useState(initFormData(schema));