Skip to content

Commit a645653

Browse files
committed
feat: titleCase for sidebar、table column title、card title and segment switcher
Signed-off-by: warjiang <[email protected]>
1 parent 926ab84 commit a645653

File tree

12 files changed

+342
-165
lines changed

12 files changed

+342
-165
lines changed

ui/apps/dashboard/src/pages/cluster-manage/index.tsx

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import i18nInstance from '@/utils/i18n';
1+
import i18nInstance, { titleCase } from '@/utils/i18n';
22
import Panel from '@/components/panel';
33
import { useQuery } from '@tanstack/react-query';
44
import { GetClusters } from '@/services';
@@ -54,7 +54,9 @@ const ClusterManagePage = () => {
5454
});
5555
const columns: TableColumnProps<Cluster>[] = [
5656
{
57-
title: i18nInstance.t('c3f28b34bbdec501802fa403584267e6', '集群名称'),
57+
title: titleCase(
58+
i18nInstance.t('c3f28b34bbdec501802fa403584267e6', '集群名称'),
59+
),
5860
key: 'clusterName',
5961
width: 150,
6062
render: (_, r) => {
@@ -63,17 +65,18 @@ const ClusterManagePage = () => {
6365
},
6466
},
6567
{
66-
title: i18nInstance.t(
67-
'bd17297989ec345cbc03ae0b8a13dc0a',
68-
'kubernetes版本',
68+
title: titleCase(
69+
i18nInstance.t('bd17297989ec345cbc03ae0b8a13dc0a', 'kubernetes版本'),
6970
),
7071
dataIndex: 'kubernetesVersion',
7172
key: 'kubernetesVersion',
7273
width: 150,
7374
align: 'center',
7475
},
7576
{
76-
title: i18nInstance.t('ee00813361387a116d274c608ba8bb13', '集群状态'),
77+
title: titleCase(
78+
i18nInstance.t('ee00813361387a116d274c608ba8bb13', '集群状态'),
79+
),
7780
dataIndex: 'ready',
7881
key: 'ready',
7982
align: 'center',
@@ -113,7 +116,9 @@ const ClusterManagePage = () => {
113116
},
114117
},
115118
{
116-
title: i18nInstance.t('f0789e79d48f135e5d870753f7a85d05', '模式'),
119+
title: titleCase(
120+
i18nInstance.t('f0789e79d48f135e5d870753f7a85d05', '模式'),
121+
),
117122
dataIndex: 'syncMode',
118123
width: 150,
119124
align: 'center',
@@ -126,7 +131,9 @@ const ClusterManagePage = () => {
126131
},
127132
},
128133
{
129-
title: i18nInstance.t('b86224e030e5948f96b70a4c3600b33f', '节点状态'),
134+
title: titleCase(
135+
i18nInstance.t('b86224e030e5948f96b70a4c3600b33f', '节点状态'),
136+
),
130137
dataIndex: 'nodeStatus',
131138
align: 'center',
132139
width: 150,
@@ -143,7 +150,9 @@ const ClusterManagePage = () => {
143150
},
144151
},
145152
{
146-
title: i18nInstance.t('763a78a5fc84dbca6f0137a591587f5f', 'cpu用量'),
153+
title: titleCase(
154+
i18nInstance.t('763a78a5fc84dbca6f0137a591587f5f', 'cpu用量'),
155+
),
147156
dataIndex: 'cpuFraction',
148157
width: '15%',
149158
render: (_, r) => {
@@ -159,7 +168,9 @@ const ClusterManagePage = () => {
159168
},
160169
},
161170
{
162-
title: i18nInstance.t('8b2e672e8b847415a47cc2dd25a87a07', 'memory用量'),
171+
title: titleCase(
172+
i18nInstance.t('8b2e672e8b847415a47cc2dd25a87a07', 'memory用量'),
173+
),
163174
dataIndex: 'memoryFraction',
164175
width: '15%',
165176
render: (_, r) => {
@@ -175,7 +186,9 @@ const ClusterManagePage = () => {
175186
},
176187
},
177188
{
178-
title: i18nInstance.t('2b6bc0f293f5ca01b006206c2535ccbc', '操作'),
189+
title: titleCase(
190+
i18nInstance.t('2b6bc0f293f5ca01b006206c2535ccbc', '操作'),
191+
),
179192
key: 'op',
180193
width: 200,
181194
render: (_, r) => {

ui/apps/dashboard/src/pages/multicloud-policy-manage/override-policy/index.tsx

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import i18nInstance from '@/utils/i18n';
1+
import i18nInstance, { titleCase } from '@/utils/i18n';
22
import { useMemo, useState } from 'react';
33
import Panel from '@/components/panel';
44
import {
@@ -90,25 +90,28 @@ const OverridePolicyManage = () => {
9090
});
9191
const columns = [
9292
filter.policyScope === 'namespace-scope' && {
93-
title: i18nInstance.t('a4b28a416f0b6f3c215c51e79e517298', '命名空间'),
93+
title: titleCase(
94+
i18nInstance.t('a4b28a416f0b6f3c215c51e79e517298', '命名空间'),
95+
),
9496
key: 'namespaceName',
9597
width: 200,
9698
render: (_v: string, r: OverridePolicy | ClusterOverridePolicy) => {
9799
return r.objectMeta.namespace;
98100
},
99101
},
100102
{
101-
title: i18nInstance.t('53cf41060c577315071a7c14bb612852', '策略名称'),
103+
title: titleCase(
104+
i18nInstance.t('53cf41060c577315071a7c14bb612852', '策略名称'),
105+
),
102106
key: 'policyName',
103107
width: 200,
104108
render: (_v: string, r: OverridePolicy | ClusterOverridePolicy) => {
105109
return r.objectMeta.name;
106110
},
107111
},
108112
{
109-
title: i18nInstance.t(
110-
'8a59b316f11d99f01ebe9b1b466ba8de',
111-
'差异化策略类型',
113+
title: titleCase(
114+
i18nInstance.t('8a59b316f11d99f01ebe9b1b466ba8de', '差异化策略类型'),
112115
),
113116
key: 'ruleTypes',
114117
dataIndex: 'ruleTypes',
@@ -125,7 +128,9 @@ const OverridePolicyManage = () => {
125128
},
126129
},
127130
{
128-
title: i18nInstance.t('ab7e397dd8c88360e441f1c1525a5758', '关联集群'),
131+
title: titleCase(
132+
i18nInstance.t('ab7e397dd8c88360e441f1c1525a5758', '关联集群'),
133+
),
129134
key: 'cluster',
130135
render: (_v: string, r: OverridePolicy | ClusterOverridePolicy) => {
131136
const clusters = extractClusterNames(r);
@@ -140,7 +145,9 @@ const OverridePolicyManage = () => {
140145
},
141146
},
142147
{
143-
title: i18nInstance.t('2b6bc0f293f5ca01b006206c2535ccbc', '操作'),
148+
title: titleCase(
149+
i18nInstance.t('2b6bc0f293f5ca01b006206c2535ccbc', '操作'),
150+
),
144151
key: 'op',
145152
width: 200,
146153
render: (_v: string, r: OverridePolicy | ClusterOverridePolicy) => {
@@ -263,16 +270,17 @@ const OverridePolicyManage = () => {
263270
}}
264271
options={[
265272
{
266-
label: i18nInstance.t(
267-
'bf15e71b2553d369585ace795d15ac3b',
268-
'命名空间级别',
273+
label: titleCase(
274+
i18nInstance.t(
275+
'bf15e71b2553d369585ace795d15ac3b',
276+
'命名空间级别',
277+
),
269278
),
270279
value: 'namespace-scope',
271280
},
272281
{
273-
label: i18nInstance.t(
274-
'860f29d8fc7a68113902db52885111d4',
275-
'集群级别',
282+
label: titleCase(
283+
i18nInstance.t('860f29d8fc7a68113902db52885111d4', '集群级别'),
276284
),
277285
value: 'cluster-scope',
278286
},

ui/apps/dashboard/src/pages/multicloud-policy-manage/propagation-policy/index.tsx

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import i18nInstance from '@/utils/i18n';
1+
import i18nInstance, { titleCase } from '@/utils/i18n';
22
import { useState } from 'react';
33
import Panel from '@/components/panel';
44
import {
@@ -79,29 +79,37 @@ const PropagationPolicyManage = () => {
7979
});
8080
const columns = [
8181
filter.policyScope === PolicyScope.Namespace && {
82-
title: i18nInstance.t('a4b28a416f0b6f3c215c51e79e517298', '命名空间'),
82+
title: titleCase(
83+
i18nInstance.t('a4b28a416f0b6f3c215c51e79e517298', '命名空间'),
84+
),
8385
key: 'namespaceName',
8486
width: 200,
8587
render: (_v: string, r: PropagationPolicy) => {
8688
return r.objectMeta.namespace;
8789
},
8890
},
8991
{
90-
title: i18nInstance.t('53cf41060c577315071a7c14bb612852', '策略名称'),
92+
title: titleCase(
93+
i18nInstance.t('53cf41060c577315071a7c14bb612852', '策略名称'),
94+
),
9195
key: 'policyName',
9296
width: 200,
9397
render: (_v: string, r: PropagationPolicy) => {
9498
return r.objectMeta.name;
9599
},
96100
},
97101
{
98-
title: i18nInstance.t('915f48c8fcbe25e3dc5875c471b0ce3e', '调度器名称'),
102+
title: titleCase(
103+
i18nInstance.t('915f48c8fcbe25e3dc5875c471b0ce3e', '调度器名称'),
104+
),
99105
key: 'schedulerName',
100106
dataIndex: 'schedulerName',
101107
width: 200,
102108
},
103109
{
104-
title: i18nInstance.t('ab7e397dd8c88360e441f1c1525a5758', '关联集群'),
110+
title: titleCase(
111+
i18nInstance.t('ab7e397dd8c88360e441f1c1525a5758', '关联集群'),
112+
),
105113
key: 'cluster',
106114
render: (_v: string, r: PropagationPolicy) => {
107115
if (!r?.clusterAffinity?.clusterNames) {
@@ -117,7 +125,9 @@ const PropagationPolicyManage = () => {
117125
},
118126
},
119127
{
120-
title: i18nInstance.t('8c0921045b741bc4e19d61426b99c938', '关联资源'),
128+
title: titleCase(
129+
i18nInstance.t('8c0921045b741bc4e19d61426b99c938', '关联资源'),
130+
),
121131
key: 'deployments',
122132
render: (_v: string, r: PropagationPolicy) => {
123133
return r?.deployments?.map((d) => (
@@ -126,7 +136,9 @@ const PropagationPolicyManage = () => {
126136
},
127137
},
128138
{
129-
title: i18nInstance.t('2b6bc0f293f5ca01b006206c2535ccbc', '操作'),
139+
title: titleCase(
140+
i18nInstance.t('2b6bc0f293f5ca01b006206c2535ccbc', '操作'),
141+
),
130142
key: 'op',
131143
width: 200,
132144
render: (_v: string, r: PropagationPolicy) => {
@@ -257,16 +269,17 @@ const PropagationPolicyManage = () => {
257269
}}
258270
options={[
259271
{
260-
label: i18nInstance.t(
261-
'bf15e71b2553d369585ace795d15ac3b',
262-
'命名空间级别',
272+
label: titleCase(
273+
i18nInstance.t(
274+
'bf15e71b2553d369585ace795d15ac3b',
275+
'命名空间级别',
276+
),
263277
),
264278
value: PolicyScope.Namespace,
265279
},
266280
{
267-
label: i18nInstance.t(
268-
'860f29d8fc7a68113902db52885111d4',
269-
'集群级别',
281+
label: titleCase(
282+
i18nInstance.t('860f29d8fc7a68113902db52885111d4', '集群级别'),
270283
),
271284
value: PolicyScope.Cluster,
272285
},

ui/apps/dashboard/src/pages/multicloud-resource-manage/config/components/configmap-table.tsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import i18nInstance from '@/utils/i18n';
1+
import i18nInstance, { titleCase } from '@/utils/i18n';
22
import { Button, Popconfirm, Space, Table, TableColumnProps, Tag } from 'antd';
33
import TagList from '@/components/tag-list';
44
import { FC } from 'react';
@@ -25,23 +25,29 @@ const ConfigMapTable: FC<ConfigMapTableProps> = (props) => {
2525
} = props;
2626
const columns: TableColumnProps<Config>[] = [
2727
{
28-
title: i18nInstance.t('a4b28a416f0b6f3c215c51e79e517298', '命名空间'),
28+
title: titleCase(
29+
i18nInstance.t('a4b28a416f0b6f3c215c51e79e517298', '命名空间'),
30+
),
2931
key: 'namespaceName',
3032
width: 200,
3133
render: (_, r) => {
3234
return r.objectMeta.namespace;
3335
},
3436
},
3537
{
36-
title: i18nInstance.t('4fcad1c9ba0732214679e13bd69d998b', '配置名称'),
38+
title: titleCase(
39+
i18nInstance.t('4fcad1c9ba0732214679e13bd69d998b', '配置名称'),
40+
),
3741
key: 'configmapName',
3842
width: 300,
3943
render: (_, r) => {
4044
return r.objectMeta.name;
4145
},
4246
},
4347
{
44-
title: i18nInstance.t('1f7be0a924280cd098db93c9d81ecccd', '标签信息'),
48+
title: titleCase(
49+
i18nInstance.t('1f7be0a924280cd098db93c9d81ecccd', '标签信息'),
50+
),
4551
key: 'labelName',
4652
align: 'left',
4753
width: '30%',
@@ -59,23 +65,29 @@ const ConfigMapTable: FC<ConfigMapTableProps> = (props) => {
5965
},
6066
},
6167
{
62-
title: i18nInstance.t('8a99082b2c32c843d2241e0ba60a3619', '分发策略'),
68+
title: titleCase(
69+
i18nInstance.t('8a99082b2c32c843d2241e0ba60a3619', '分发策略'),
70+
),
6371
key: 'propagationPolicies',
6472
render: (_, r) => {
6573
const pp = extractPropagationPolicy(r);
6674
return pp ? <Tag>{pp}</Tag> : '-';
6775
},
6876
},
6977
{
70-
title: i18nInstance.t('eaf8a02d1b16fcf94302927094af921f', '覆盖策略'),
78+
title: titleCase(
79+
i18nInstance.t('eaf8a02d1b16fcf94302927094af921f', '覆盖策略'),
80+
),
7181
key: 'overridePolicies',
72-
width: 150,
82+
width: i18nInstance.language === 'en-US' ? '200px' : '150px',
7383
render: () => {
7484
return '-';
7585
},
7686
},
7787
{
78-
title: i18nInstance.t('2b6bc0f293f5ca01b006206c2535ccbc', '操作'),
88+
title: titleCase(
89+
i18nInstance.t('2b6bc0f293f5ca01b006206c2535ccbc', '操作'),
90+
),
7991
key: 'op',
8092
width: 200,
8193
render: (_, r) => {

0 commit comments

Comments
 (0)