Skip to content

Commit

Permalink
chore:Add the i18n for UI texts
Browse files Browse the repository at this point in the history
  • Loading branch information
TianWuwt committed Dec 20, 2024
1 parent 26e8db6 commit 5fe6ad7
Show file tree
Hide file tree
Showing 17 changed files with 1,661 additions and 1,488 deletions.
241 changes: 120 additions & 121 deletions ui/src/components/TopoComponent/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,150 +3,150 @@ import { intl } from '@/utils/intl';
import { clone } from 'lodash';

const clusterOperate: Topo.OperateTypeLabel = [
{
value: 'addZone',
label: intl.formatMessage({
id: 'dashboard.Detail.Topo.constants.AddZone',
defaultMessage: '新增zone',
}),
},
{
value: 'upgradeCluster',
label: intl.formatMessage({
id: 'OBDashboard.Detail.Topo.constants.Upgrade',
defaultMessage: '升级',
}),
},
{
value: 'deleteCluster',
label: intl.formatMessage({
id: 'OBDashboard.Detail.Topo.constants.Delete',
defaultMessage: '删除',
}),
},
];
{
value: 'addZone',
label: intl.formatMessage({
id: 'dashboard.Detail.Topo.constants.AddZone',
defaultMessage: '新增zone'
})
},
{
value: 'upgradeCluster',
label: intl.formatMessage({
id: 'OBDashboard.Detail.Topo.constants.Upgrade',
defaultMessage: '升级'
})
},
{
value: 'deleteCluster',
label: intl.formatMessage({
id: 'OBDashboard.Detail.Topo.constants.Delete',
defaultMessage: '删除'
})
}];


const zoneOperate: Topo.OperateTypeLabel = [
{
value: 'scaleServer',
label: intl.formatMessage({
id: 'OBDashboard.Detail.Topo.constants.Scale',
defaultMessage: '扩缩容',
}),
},
{
value: 'deleteZone',
label: intl.formatMessage({
id: 'dashboard.Detail.Topo.constants.DeleteZone',
defaultMessage: '删除zone',
}),
disabled: false,
},
];
{
value: 'scaleServer',
label: intl.formatMessage({
id: 'OBDashboard.Detail.Topo.constants.Scale',
defaultMessage: '扩缩容'
})
},
{
value: 'deleteZone',
label: intl.formatMessage({
id: 'dashboard.Detail.Topo.constants.DeleteZone',
defaultMessage: '删除zone'
}),
disabled: false
}];


const serverOperate: Topo.OperateTypeLabel = [
{
value: 'restartServer',
label: intl.formatMessage({ id: "src.components.TopoComponent.2494A473", defaultMessage: "重启server" }),
disabled: false
},
{
value: 'deleteServer',
label: intl.formatMessage({
id: 'dashboard.Detail.Topo.constants.DeleteServer',
defaultMessage: '删除 server'
}),
disabled: false
}
// {
// value: 'add',
// label: intl.formatMessage({
// id: 'dashboard.Detail.Topo.constants.AddServer',
// defaultMessage: '添加server',
// }),
// },
// {
// value: 'upgrade',
// label: intl.formatMessage({
// id: 'dashboard.Detail.Topo.constants.UpgradeServer',
// defaultMessage: '升级server',
// }),
// },
];

const clusterOperateOfTenant: Topo.OperateTypeLabel = [
{
value: 'changeUnitCount',
label: intl.formatMessage({
id: 'Dashboard.components.TopoComponent.constants.ModifyTheNumberOfUnits',
defaultMessage: '修改 Unit 数量'
})
}];


const getZoneOperateOfTenant = (
haveResourcePool: boolean,
tenantReplicas: API.ReplicaDetailType[],
tenantStatus?: string,
clusterStatus?: string)
: Topo.OperateTypeLabel => {
return haveResourcePool ?
[
{
value: 'restartServer',
label: '重启server',
disabled: false,
value: 'editResourcePools',
label: intl.formatMessage({
id: 'Dashboard.components.TopoComponent.constants.EditResourcePool',
defaultMessage: '编辑资源池'
}),
disabled: tenantStatus !== 'running' || clusterStatus !== 'running'
},
{
value: 'deleteServer',
value: 'deleteResourcePool',
label: intl.formatMessage({
id: 'dashboard.Detail.Topo.constants.DeleteServer',
defaultMessage: '删除 server',
id: 'Dashboard.components.TopoComponent.constants.DeleteAResourcePool',
defaultMessage: '删除资源池'
}),
disabled: false,
},
// {
// value: 'add',
// label: intl.formatMessage({
// id: 'dashboard.Detail.Topo.constants.AddServer',
// defaultMessage: '添加server',
// }),
// },
// {
// value: 'upgrade',
// label: intl.formatMessage({
// id: 'dashboard.Detail.Topo.constants.UpgradeServer',
// defaultMessage: '升级server',
// }),
// },
];
disabled:
tenantReplicas.length <= 2 ||
tenantStatus !== 'running' ||
clusterStatus !== 'running'
}] :

const clusterOperateOfTenant: Topo.OperateTypeLabel = [
[
{
value: 'changeUnitCount',
value: 'createResourcePools',
label: intl.formatMessage({
id: 'Dashboard.components.TopoComponent.constants.ModifyTheNumberOfUnits',
defaultMessage: '修改 Unit 数量',
id: 'Dashboard.components.TopoComponent.constants.AddAResourcePool',
defaultMessage: '新增资源池'
}),
},
];
disabled: tenantStatus !== 'running' || clusterStatus !== 'running'
}];

const getZoneOperateOfTenant = (
haveResourcePool: boolean,
tenantReplicas: API.ReplicaDetailType[],
tenantStatus?: string,
clusterStatus?: string,
): Topo.OperateTypeLabel => {
return haveResourcePool
? [
{
value: 'editResourcePools',
label: intl.formatMessage({
id: 'Dashboard.components.TopoComponent.constants.EditResourcePool',
defaultMessage: '编辑资源池',
}),
disabled: tenantStatus !== 'running' || clusterStatus !== 'running',
},
{
value: 'deleteResourcePool',
label: intl.formatMessage({
id: 'Dashboard.components.TopoComponent.constants.DeleteAResourcePool',
defaultMessage: '删除资源池',
}),
disabled:
tenantReplicas.length <= 2 ||
tenantStatus !== 'running' ||
clusterStatus !== 'running',
},
]
: [
{
value: 'createResourcePools',
label: intl.formatMessage({
id: 'Dashboard.components.TopoComponent.constants.AddAResourcePool',
defaultMessage: '新增资源池',
}),
disabled: tenantStatus !== 'running' || clusterStatus !== 'running',
},
];
};

const getZoneOperateOfCluster = (
topoData: Topo.GraphNodeType | undefined,
status: string,
): Topo.OperateTypeLabel => {
topoData: Topo.GraphNodeType | undefined,
status: string)
: Topo.OperateTypeLabel => {
if (!topoData) return [];
const isDisabled = topoData?.children?.length <= 2 || status !== 'running';
zoneOperate.forEach((operate) => {
if (operate.value === 'deleteZone') operate.disabled = isDisabled;
if (operate.value === 'scaleServer')
operate.disabled = status !== 'running';
operate.disabled = status !== 'running';
});
return zoneOperate;
};
const getServerOperateOfCluster = (
topoData: Topo.GraphNodeType | undefined,
disabled: boolean,
serverZone: string,
): Topo.OperateTypeLabel => {
topoData: Topo.GraphNodeType | undefined,
disabled: boolean,
serverZone: string)
: Topo.OperateTypeLabel => {
if (!topoData) return [];
// 任何 zone 里面只剩一个 server 就不能删了
const supportStaticIPisDisabled = topoData?.supportStaticIP;
const zoneCurrent = topoData?.children?.find(
(zone) => zone.label === serverZone,
(zone) => zone.label === serverZone
);

const serverCurrentisDisabled = zoneCurrent?.children?.length === 1;
Expand All @@ -156,17 +156,17 @@ const getServerOperateOfCluster = (
operate.disabled = disabled;
}
if (operate.value === 'deleteServer')
operate.disabled = serverCurrentisDisabled;
operate.disabled = serverCurrentisDisabled;
if (operate.value === 'restartServer')
operate.disabled = !supportStaticIPisDisabled;
operate.disabled = !supportStaticIPisDisabled;
});
return serverOperate;
};

const getClusterOperates = (
clusterOperateList: Topo.OperateTypeLabel,
disabled: boolean,
): Topo.OperateTypeLabel => {
clusterOperateList: Topo.OperateTypeLabel,
disabled: boolean)
: Topo.OperateTypeLabel => {
const res = clone(clusterOperateList);
res.forEach((item) => {
item.disabled = disabled;
Expand All @@ -182,5 +182,4 @@ export {
getZoneOperateOfCluster,
getZoneOperateOfTenant,
serverOperate,
zoneOperate,
};
zoneOperate };
Loading

0 comments on commit 5fe6ad7

Please sign in to comment.