Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

feat: form for swwitch add label

shuai1d3819673ae1
diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml
index f7a7af2e..8ab8d9bc 100644
--- a/i18n/en_US.yaml
+++ b/i18n/en_US.yaml
@@ -1163,6 +1163,7 @@ ui:
label: Recommend Tags
text: "Please input tag slug above, one tag per line."
required_tag:
+ title: Required Tag
label: Set recommend tag as required
text: "Every new question must have at least one recommend tag."
reserved_tags:
diff --git a/ui/src/components/SchemaForm/index.tsx b/ui/src/components/SchemaForm/index.tsx
index 1d36e7e9..437bda58 100644
--- a/ui/src/components/SchemaForm/index.tsx
+++ b/ui/src/components/SchemaForm/index.tsx
@@ -14,6 +14,7 @@ export interface JSONSchema {
[key: string]: {
type: 'string' | 'boolean';
title: string;
+ label?: string;
description?: string;
enum?: Array<string | boolean>;
enumNames?: string[];
@@ -228,7 +229,7 @@ const SchemaForm: FC<IProps> = ({
return (
<Form noValidate onSubmit={handleSubmit}>
{keys.map((key) => {
- const { title, description } = properties[key];
+ const { title, description, label } = properties[key];
const { 'ui:widget': widget = 'input', 'ui:options': options = {} } =
uiSchema[key] || {};
if (widget === 'select') {
@@ -285,7 +286,6 @@ const SchemaForm: FC<IProps> = ({
}
if (widget === 'switch') {
- console.log(formData[key]?.value, 'switch=====');
return (
<Form.Group key={title} className="mb-3" controlId={key}>
<Form.Label>{title}</Form.Label>
@@ -294,7 +294,7 @@ const SchemaForm: FC<IProps> = ({
id={title}
name={key}
type="switch"
- label={title}
+ label={label}
checked={formData[key]?.value}
feedback={formData[key]?.errorMsg}
feedbackType="invalid"
diff --git a/ui/src/pages/Admin/Dashboard/components/HealthStatus/index.tsx b/ui/src/pages/Admin/Dashboard/components/HealthStatus/index.tsx
index 2d6c5700..08bcacc1 100644
--- a/ui/src/pages/Admin/Dashboard/components/HealthStatus/index.tsx
+++ b/ui/src/pages/Admin/Dashboard/components/HealthStatus/index.tsx
@@ -3,10 +3,10 @@ import { Card, Row, Col, Badge } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
-import { gt, gte } from 'semver';
-
import type * as Type from '@/common/interface';
+const { gt, gte } = require('semver');
+
interface IProps {
data: Type.AdminDashboard['info'];
}
diff --git a/ui/src/pages/Admin/Write/index.tsx b/ui/src/pages/Admin/Write/index.tsx
index c24b41b5..75a71861 100644
--- a/ui/src/pages/Admin/Write/index.tsx
+++ b/ui/src/pages/Admin/Write/index.tsx
@@ -29,7 +29,8 @@ const Legal: FC = () => {
},
required_tag: {
type: 'boolean',
- title: t('required_tag.label'),
+ title: t('required_tag.title'),
+ label: t('required_tag.label'),
description: t('required_tag.text'),
},
reserved_tags: {