From 4ec13228bbc0a17e84696de30ad297f6d266d039 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=B4=E6=99=96?= <2689991790@qq.com>
Date: Sat, 15 Jun 2024 23:52:17 +0800
Subject: [PATCH] fix
---
ui/src/components/CustomFormItem/index.tsx | 10 +-
ui/src/i18n/strings/zh-CN.json | 38 +++++-
ui/src/pages/Layouts/DetailLayout/index.tsx | 2 +-
.../OBProxy/Detail/Overview/ConfigDrawer.tsx | 108 ++++++++++++++----
.../OBProxy/Detail/Overview/DetailConfig.tsx | 19 ++-
ui/src/pages/OBProxy/New/BasicConfig.tsx | 50 ++++++--
ui/src/pages/OBProxy/New/DetailConfig.tsx | 85 ++++++++++++--
ui/src/pages/OBProxy/New/index.tsx | 23 ++--
ui/src/type/obproxy.d.ts | 13 +++
ui/src/type/typings.d.ts | 1 +
10 files changed, 278 insertions(+), 71 deletions(-)
create mode 100644 ui/src/type/obproxy.d.ts
diff --git a/ui/src/components/CustomFormItem/index.tsx b/ui/src/components/CustomFormItem/index.tsx
index e3799fd23..f70223428 100644
--- a/ui/src/components/CustomFormItem/index.tsx
+++ b/ui/src/components/CustomFormItem/index.tsx
@@ -2,7 +2,7 @@ import { intl } from '@/utils/intl';
import type { FormItemProps } from 'antd';
import { Form } from 'antd';
-export const CustomFormItem = (prop: FormItemProps & { message: string }) => {
+export const CustomFormItem = (prop: FormItemProps & { message?: string }) => {
const { label, message } = prop;
return (
{
{
required: true,
message:
- message || typeof label === 'string'
+ message ||
+ (typeof label === 'string'
? intl.formatMessage(
{
id: 'Dashboard.Cluster.New.Observer.EnterLabel',
@@ -19,7 +20,10 @@ export const CustomFormItem = (prop: FormItemProps & { message: string }) => {
},
{ label: label as string },
)
- : '请输入',
+ : intl.formatMessage({
+ id: 'src.components.CustomFormItem.2C6315A1',
+ defaultMessage: '请输入',
+ })),
},
]}
>
diff --git a/ui/src/i18n/strings/zh-CN.json b/ui/src/i18n/strings/zh-CN.json
index bb2ebaaeb..8715d4bfd 100644
--- a/ui/src/i18n/strings/zh-CN.json
+++ b/ui/src/i18n/strings/zh-CN.json
@@ -985,5 +985,41 @@
"src.components.InputLabelComp.6C88A39D": "添加",
"src.components.AlertDrawer.95C6A631": "提交",
"src.components.AlertDrawer.9B7CD984": "取消",
- "src.api.2CA64FC6": "登陆已过期"
+ "src.api.2CA64FC6": "登陆已过期",
+ "src.pages.OBProxy.New.49694AC5": "创建成功!",
+ "src.pages.OBProxy.New.7CAF48E9": "详细配置",
+ "src.pages.OBProxy.New.0C4EFBB0": "资源设置",
+ "src.pages.OBProxy.New.CCD9785D": "请选择服务类型",
+ "src.pages.OBProxy.New.88D0BC94": "服务类型",
+ "src.pages.OBProxy.New.2F497A97": "请选择",
+ "src.pages.OBProxy.New.A3E900B4": "副本数",
+ "src.pages.OBProxy.New.D4645164": "请输入",
+ "src.pages.OBProxy.New.6A1E93D2": "CPU 核数",
+ "src.pages.OBProxy.New.AEDDBA86": "请输入",
+ "src.pages.OBProxy.New.CE387455": "内存大小",
+ "src.pages.OBProxy.New.7C04AD55": "请输入",
+ "src.pages.OBProxy.New.134CD1CE": "参数设置",
+ "src.pages.OBProxy.New.D6D90ACC": "k8s中资源的名称",
+ "src.pages.OBProxy.New.803427AF": "资源名称",
+ "src.pages.OBProxy.New.F602E292": "请输入k8s资源名称",
+ "src.pages.OBProxy.New.37FA27BA": "资源名不能使用纯数字",
+ "src.pages.OBProxy.New.9B4BA02B": "请输入",
+ "src.pages.OBProxy.New.BB6BC872": "OBProxy 集群名",
+ "src.pages.OBProxy.New.CA42FD5D": "请输入集群名",
+ "src.pages.OBProxy.New.94339826": "请选择 OB 集群",
+ "src.pages.OBProxy.New.67DC144A": "请输入 OBProxy root 密码",
+ "src.pages.OBProxy.Detail.Overview.680A1826": "详细配置",
+ "src.pages.OBProxy.Detail.Overview.F9D66FC0": "资源设置",
+ "src.pages.OBProxy.Detail.Overview.DBE1B6C0": "服务类型",
+ "src.pages.OBProxy.Detail.Overview.E7B1B575": "请选择",
+ "src.pages.OBProxy.Detail.Overview.2DA6A0A7": "副本数",
+ "src.pages.OBProxy.Detail.Overview.52C1F09A": "请输入",
+ "src.pages.OBProxy.Detail.Overview.A4448DF2": "CPU 核数",
+ "src.pages.OBProxy.Detail.Overview.2FA13720": "请输入",
+ "src.pages.OBProxy.Detail.Overview.0075C2B3": "内存大小",
+ "src.pages.OBProxy.Detail.Overview.3F3066D5": "请输入",
+ "src.pages.OBProxy.Detail.Overview.D537DD35": "参数设置",
+ "src.pages.OBProxy.Detail.Overview.8A75D872": "请选择",
+ "src.pages.OBProxy.Detail.Overview.8E87D135": "添加",
+ "src.components.CustomFormItem.2C6315A1": "请输入"
}
\ No newline at end of file
diff --git a/ui/src/pages/Layouts/DetailLayout/index.tsx b/ui/src/pages/Layouts/DetailLayout/index.tsx
index 4c62484fa..8a2ea478b 100644
--- a/ui/src/pages/Layouts/DetailLayout/index.tsx
+++ b/ui/src/pages/Layouts/DetailLayout/index.tsx
@@ -95,7 +95,7 @@ const DetailLayout: React.FC = ({
useEffect(() => {
getAppInfoFromStorage().then((appInfo) => {
- setVersion(appInfo.version);
+ setVersion(appInfo?.version);
});
}, []);
diff --git a/ui/src/pages/OBProxy/Detail/Overview/ConfigDrawer.tsx b/ui/src/pages/OBProxy/Detail/Overview/ConfigDrawer.tsx
index 68a4a5966..7af01190b 100644
--- a/ui/src/pages/OBProxy/Detail/Overview/ConfigDrawer.tsx
+++ b/ui/src/pages/OBProxy/Detail/Overview/ConfigDrawer.tsx
@@ -1,10 +1,11 @@
import { obproxy } from '@/api';
-import type { CommonKVPair, CommonResourceSpec } from '@/api/generated';
+import type { CommonKVPair } from '@/api/generated';
import { ObproxyPatchOBProxyParam } from '@/api/generated';
import AlertDrawer from '@/components/AlertDrawer';
import { CustomFormItem } from '@/components/CustomFormItem';
import { SERVICE_TYPE, SUFFIX_UNIT } from '@/constants';
import { MIRROR_OBPROXY } from '@/constants/doc';
+import { OBProxy } from '@/type/obproxy';
import { intl } from '@/utils/intl';
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
import { useRequest } from 'ahooks';
@@ -22,16 +23,10 @@ import {
import { useEffect, useRef } from 'react';
import { isDifferentParams } from '../../helper';
-interface ConfigDrawerProps extends DrawerProps {
+type ConfigDrawerProps = {
onClose: () => void;
- name: string;
- namespace: string;
- image?: string;
- parameters?: CommonKVPair[];
- resource?: CommonResourceSpec;
- serviceType?: string;
- replicas?: number;
-}
+} & OBProxy.CommonProxyDetail &
+ DrawerProps;
type FormValue = {
parameters?: { key: string; value: string }[];
@@ -79,7 +74,10 @@ export default function ConfigDrawer({
}, [props.parameters]);
return (
form.submit()}
destroyOnClose={true}
onClose={() => onClose()}
@@ -92,7 +90,12 @@ export default function ConfigDrawer({
preserve={false}
layout="vertical"
>
- 资源设置
+
+ {intl.formatMessage({
+ id: 'src.pages.OBProxy.Detail.Overview.F9D66FC0',
+ defaultMessage: '资源设置',
+ })}
+
@@ -121,19 +124,73 @@ export default function ConfigDrawer({
})}
/>
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
- 参数设置
+
+ {intl.formatMessage({
+ id: 'src.pages.OBProxy.Detail.Overview.D537DD35',
+ defaultMessage: '参数设置',
+ })}
+
{(fields, { add, remove }) => (
<>
@@ -142,7 +199,10 @@ export default function ConfigDrawer({
diff --git a/ui/src/pages/OBProxy/Detail/Overview/DetailConfig.tsx b/ui/src/pages/OBProxy/Detail/Overview/DetailConfig.tsx
index a29bf7042..7c83c0d38 100644
--- a/ui/src/pages/OBProxy/Detail/Overview/DetailConfig.tsx
+++ b/ui/src/pages/OBProxy/Detail/Overview/DetailConfig.tsx
@@ -1,23 +1,16 @@
-import type { CommonKVPair, CommonResourceSpec } from '@/api/generated';
import InputLabelComp from '@/components/InputLabelComp';
+import { OBProxy } from '@/type/obproxy';
import { intl } from '@/utils/intl';
import { Button, Card, Col, Row } from 'antd';
import { useState } from 'react';
import ConfigDrawer from './ConfigDrawer';
-
-interface DetailConfigProps {
- name?: string;
- namespace?: string;
- image?: string;
- parameters?: CommonKVPair[];
- resource?: CommonResourceSpec;
- serviceType?: string;
- replicas?: number;
+interface DetailConfigProps extends OBProxy.CommonProxyDetail {
style?: React.CSSProperties;
}
export default function DetailConfig({ style, ...props }: DetailConfigProps) {
const { image, serviceType, replicas, resource, parameters } = props;
+
const [drawerOpen, setDrawerOpen] = useState(false);
return (
-
+
{props.name && props.namespace ? (
-
+
-
+
@@ -84,7 +110,10 @@ export default function BasicConfig({ form }: BasicConfigProps) {
rules={[
{
required: true,
- message: '请选择 OB 集群',
+ message: intl.formatMessage({
+ id: 'src.pages.OBProxy.New.94339826',
+ defaultMessage: '请选择 OB 集群',
+ }),
},
]}
>
@@ -109,7 +138,10 @@ export default function BasicConfig({ form }: BasicConfigProps) {
rules={[
{
required: true,
- message: '请输入 OBProxy root 密码',
+ message: intl.formatMessage({
+ id: 'src.pages.OBProxy.New.67DC144A',
+ defaultMessage: '请输入 OBProxy root 密码',
+ }),
},
]}
>
diff --git a/ui/src/pages/OBProxy/New/DetailConfig.tsx b/ui/src/pages/OBProxy/New/DetailConfig.tsx
index 5630b07c7..36a58b593 100644
--- a/ui/src/pages/OBProxy/New/DetailConfig.tsx
+++ b/ui/src/pages/OBProxy/New/DetailConfig.tsx
@@ -10,9 +10,19 @@ const commonStyle = { width: 280 };
export default function DetailConfig() {
return (
-
+
- 资源设置
+
+ {intl.formatMessage({
+ id: 'src.pages.OBProxy.New.0C4EFBB0',
+ defaultMessage: '资源设置',
+ })}
+
-
+
-
-
+
+
-
-
+
+
-
+
@@ -74,9 +130,14 @@ export default function DetailConfig() {
- 参数设置
+
+ {intl.formatMessage({
+ id: 'src.pages.OBProxy.New.134CD1CE',
+ defaultMessage: '参数设置',
+ })}
+
-
+
diff --git a/ui/src/pages/OBProxy/New/index.tsx b/ui/src/pages/OBProxy/New/index.tsx
index 0e8ee4ac7..7fc1f6c99 100644
--- a/ui/src/pages/OBProxy/New/index.tsx
+++ b/ui/src/pages/OBProxy/New/index.tsx
@@ -3,7 +3,7 @@ import { ObproxyCreateOBProxyParam } from '@/api/generated';
import { intl } from '@/utils/intl';
import { PageContainer } from '@ant-design/pro-components';
import { useNavigate } from '@umijs/max';
-import { Button, Col, Form, Row, message } from 'antd';
+import { Button, Form, Space, message } from 'antd';
import BasicConfig from './BasicConfig';
import DetailConfig from './DetailConfig';
@@ -21,7 +21,13 @@ export default function New() {
obCluster: JSON.parse(values.obCluster),
});
if (res.successful) {
- message.success('创建成功!', 3);
+ message.success(
+ intl.formatMessage({
+ id: 'src.pages.OBProxy.New.49694AC5',
+ defaultMessage: '创建成功!',
+ }),
+ 3,
+ );
form.resetFields();
history.back();
}
@@ -54,16 +60,13 @@ export default function New() {
})}
,
]}
+ style={{ paddingBottom: 50 }}
>
);
diff --git a/ui/src/type/obproxy.d.ts b/ui/src/type/obproxy.d.ts
new file mode 100644
index 000000000..ec8355e1c
--- /dev/null
+++ b/ui/src/type/obproxy.d.ts
@@ -0,0 +1,13 @@
+declare namespace OBProxy {
+ interface CommonProxyDetail {
+ name: string;
+ namespace: string;
+ image?: string;
+ parameters?: CommonKVPair[];
+ resource?: CommonResourceSpec;
+ serviceType?: string;
+ replicas?: number;
+ }
+}
+
+export { OBProxy };
diff --git a/ui/src/type/typings.d.ts b/ui/src/type/typings.d.ts
index c1079c0c8..9f39b0d3c 100644
--- a/ui/src/type/typings.d.ts
+++ b/ui/src/type/typings.d.ts
@@ -849,4 +849,5 @@ declare namespace API {
setVisible: (prop: boolean) => void;
successCallback?: (val?: any) => void;
};
+
}