Skip to content

Commit

Permalink
i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
yang1666204 committed Mar 14, 2024
1 parent 9da3d50 commit 004b90b
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 38 deletions.
17 changes: 12 additions & 5 deletions ui/src/components/TopoComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { ReactElement, useEffect, useMemo, useRef, useState } from 'react';

import showDeleteConfirm from '@/components/customModal/DeleteModal';
import OperateModal from '@/components/customModal/OperateModal';
import { RESULT_STATUS } from '@/constants';
import BasicInfo from '@/pages/Cluster/Detail/Overview/BasicInfo';
import { deleteObcluster, deleteObzone, getClusterDetailReq } from '@/services';
import { getNSName } from '../../pages/Cluster/Detail/Overview/helper';
import { ReactNode, config } from './G6register';
import type { OperateTypeLabel } from './constants';
import { RESULT_STATUS } from '@/constants';
import {
clusterOperate,
clusterOperateOfTenant,
Expand Down Expand Up @@ -49,13 +49,13 @@ export default function TopoComponent({
const [inNode, setInNode] = useState<boolean>(false);
const [inModal, setInModal] = useState<boolean>(false);
const [operateDisable, setOperateDisable] = useState<boolean>(false);

const [[ns, name]] = useState(
namespace && clusterNameOfKubectl
? [namespace, clusterNameOfKubectl]
: getNSName(),
);

//Control the visibility of operation and maintenance modal
const [operateModalVisible, setOperateModalVisible] =
useState<boolean>(false);
Expand Down Expand Up @@ -116,7 +116,13 @@ export default function TopoComponent({
zoneName: chooseZoneName.current,
});
if (res.successful) {
message.success(res.message || '删除成功');
message.success(
res.message ||
intl.formatMessage({
id: 'Dashboard.components.TopoComponent.DeletedSuccessfully',
defaultMessage: '删除成功',
}),
);
getTopoData({ ns, name, useFor: 'topo', tenantReplicas });
}
};
Expand Down Expand Up @@ -289,10 +295,11 @@ export default function TopoComponent({
: originTopoData && (
<BasicInfo
extra={false}
style={{ backgroundColor: '#f5f8fe', border:'none' }}
style={{ backgroundColor: '#f5f8fe', border: 'none' }}
{...(originTopoData.basicInfo as API.ClusterInfo)}
/>
)}

<div style={{ height: '100%' }} id="topoContainer"></div>
{useMemo(
() => (
Expand Down
8 changes: 7 additions & 1 deletion ui/src/i18n/strings/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -629,5 +629,11 @@
"Dashboard.Detail.Overview.Replicas.ClogDiskSize": "Clog disk size",
"Dashboard.Detail.Overview.Replicas.ResourcePool": "Resource Pool",
"Dashboard.Detail.Overview.Replicas.ResourcePoolReplicazone": "Resource pool-{replicaZone}",
"Dashboard.Detail.Overview.TenantOverview": "Tenant overview"
"Dashboard.Detail.Overview.TenantOverview": "Tenant overview",
"Dashboard.Cluster.New.Topo.TheFirstCharacterMustBe": "The first character must be a letter or an underscore and cannot contain-",
"Dashboard.Detail.Overview.Replicas.DeletedSuccessfully": "Deleted successfully",
"Dashboard.Detail.Overview.Replicas.Edit": "Edit",
"Dashboard.Detail.Overview.Replicas.AreYouSureYouWant": "Are you sure you want to delete the tenant's resource pool on {replicaZone}?",
"Dashboard.Detail.Overview.Replicas.Delete": "Delete",
"Dashboard.components.TopoComponent.DeletedSuccessfully": "Deleted successfully"
}
8 changes: 7 additions & 1 deletion ui/src/i18n/strings/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -629,5 +629,11 @@
"Dashboard.Detail.Overview.Replicas.ClogDiskSize": "Clog 盘大小",
"Dashboard.Detail.Overview.Replicas.ResourcePool": "资源池",
"Dashboard.Detail.Overview.Replicas.ResourcePoolReplicazone": "资源池 - {replicaZone}",
"Dashboard.Detail.Overview.TenantOverview": "租户概览"
"Dashboard.Detail.Overview.TenantOverview": "租户概览",
"Dashboard.Cluster.New.Topo.TheFirstCharacterMustBe": "首字符必须是字母或者下划线,不能包含 -",
"Dashboard.Detail.Overview.Replicas.DeletedSuccessfully": "删除成功",
"Dashboard.Detail.Overview.Replicas.Edit": "编辑",
"Dashboard.Detail.Overview.Replicas.AreYouSureYouWant": "确定要删除该租户在{replicaZone}上的资源池吗?",
"Dashboard.Detail.Overview.Replicas.Delete": "删除",
"Dashboard.components.TopoComponent.DeletedSuccessfully": "删除成功"
}
24 changes: 14 additions & 10 deletions ui/src/pages/Cluster/New/Topo.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { intl } from '@/utils/intl';
import { DeleteOutlined,PlusOutlined } from '@ant-design/icons';
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons';
import type { FormInstance } from 'antd';
import {
Button,
Card,
Col,
Form,
Input,
InputNumber,
Popconfirm,
Row,
Button,
Card,
Col,
Form,
Input,
InputNumber,
Popconfirm,
Row,
} from 'antd';

import NodeSelector from '@/components/NodeSelector';
Expand Down Expand Up @@ -61,7 +61,11 @@ export default function Topo({ form }: { form: FormInstance<any> }) {
},
{
pattern: TZ_NAME_REG,
message: '首字符必须是字母或者下划线,不能包含 -',
message: intl.formatMessage({
id: 'Dashboard.Cluster.New.Topo.TheFirstCharacterMustBe',
defaultMessage:
'首字符必须是字母或者下划线,不能包含 -',
}),
},
resourceNameRule,
]}
Expand Down
38 changes: 29 additions & 9 deletions ui/src/pages/Tenant/Detail/Overview/Replicas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ import showDeleteConfirm from '@/components/customModal/DeleteModal';
import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { deleteObtenantPool } from '@/services/tenant';
import { intl } from '@/utils/intl';
import { Button,Col,Descriptions,message } from 'antd';
import type { ClusterNSName } from '.';
import { Button, Col, Descriptions, message } from 'antd';
import styles from './index.less';

export default function Replicas({
replicaList,
refreshTenant
refreshTenant,
}: {
replicaList: API.ReplicaDetailType[];
refreshTenant:()=>void;
refreshTenant: () => void;
}) {
const LABEL_TEXT_MAP = {
priority: intl.formatMessage({
Expand Down Expand Up @@ -54,10 +53,16 @@ export default function Replicas({
const res = await deleteObtenantPool({ ns, name, zoneName });
if (res.successful) {
refreshTenant();
message.success(res.message || '删除成功');
message.success(
res.message ||
intl.formatMessage({
id: 'Dashboard.Detail.Overview.Replicas.DeletedSuccessfully',
defaultMessage: '删除成功',
}),
);
}
};

return (
<Col span={24}>
<CollapsibleCard
Expand Down Expand Up @@ -88,19 +93,34 @@ export default function Replicas({
)}
</span>
<div>
<Button type="link">编辑</Button>
<Button type="link">
{intl.formatMessage({
id: 'Dashboard.Detail.Overview.Replicas.Edit',
defaultMessage: '编辑',
})}
</Button>
<Button
onClick={() => {
showDeleteConfirm({
onOk: () => deleteZone(replica.zone),
title: `确定要删除该租户在${replica.zone}上的资源池吗?`,
title: intl.formatMessage(
{
id: 'Dashboard.Detail.Overview.Replicas.AreYouSureYouWant',
defaultMessage:
'确定要删除该租户在{{replicaZone}}上的资源池吗?',
},
{ replicaZone: replica.zone },
),
});
}}
disabled={replicaList.length === 2}
type="link"
danger
>
删除
{intl.formatMessage({
id: 'Dashboard.Detail.Overview.Replicas.Delete',
defaultMessage: '删除',
})}
</Button>
</div>
</div>
Expand Down
32 changes: 20 additions & 12 deletions ui/src/pages/Tenant/Detail/Overview/index.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import EventsTable from '@/components/EventsTable';
import showDeleteConfirm from '@/components/customModal/DeleteModal';
import OperateModal from '@/components/customModal/OperateModal';
import { REFRESH_TENANT_TIME,RESULT_STATUS } from '@/constants';
import { REFRESH_TENANT_TIME, RESULT_STATUS } from '@/constants';
import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import {
getEssentialParameters as getEssentialParametersReq,
getSimpleClusterList,
getEssentialParameters as getEssentialParametersReq,
getSimpleClusterList,
} from '@/services';
import {
deleteTenent,
getBackupJobs,
getBackupPolicy,
getTenant,
deleteTenent,
getBackupJobs,
getBackupPolicy,
getTenant,
} from '@/services/tenant';
import { intl } from '@/utils/intl';
import { EllipsisOutlined } from '@ant-design/icons';
import { PageContainer } from '@ant-design/pro-components';
import { history } from '@umijs/max';
import { useRequest } from 'ahooks';
import { Button,Row,Tooltip,message } from 'antd';
import { useEffect,useRef,useState } from 'react';
import { Button, Row, Tooltip, message } from 'antd';
import { useEffect, useRef, useState } from 'react';
import Backups from './Backups';
import BasicInfo from './BasicInfo';
import Replicas from './Replicas';
Expand All @@ -33,7 +33,7 @@ type OperateItemConfigType = {
danger?: boolean;
};

export type ClusterNSName = { ns?: string; name?: string }
export type ClusterNSName = { ns?: string; name?: string };

export default function TenantOverview() {
const [operateModalVisible, setOperateModalVisible] =
Expand Down Expand Up @@ -216,7 +216,15 @@ export default function TenantOverview() {
.filter((item) => item.show && !item.isMore)
.map((item, index) => (
<Button
type={item.text !== '修改密码' ? 'primary' : 'default'}
type={
item.text !==
intl.formatMessage({
id: 'Dashboard.Detail.Overview.ChangePassword',
defaultMessage: '修改密码',
})
? 'primary'
: 'default'
}
onClick={item.onClick}
danger={item.danger}
key={index}
Expand Down Expand Up @@ -290,7 +298,7 @@ export default function TenantOverview() {

{tenantDetail && tenantDetail.replicas && (
<Replicas
refreshTenant={reGetTenantDetail}
refreshTenant={reGetTenantDetail}
replicaList={tenantDetail.replicas}
/>
)}
Expand Down

0 comments on commit 004b90b

Please sign in to comment.