Skip to content

Commit c1c205c

Browse files
committed
PullRequest: 791 fix: 【专有云】hover显示优化
Merge branch 'fix/connectionPopoverbugfix of [email protected]:oceanbase/oceanbase-developer-center.git into dev-4.3.4 https://code.alipay.com/oceanbase/oceanbase-developer-center/pull_requests/791 Signed-off-by: 晓康 <[email protected]> * fix: 【专有云】hover显示优化
1 parent 3bb0678 commit c1c205c

File tree

2 files changed

+55
-35
lines changed

2 files changed

+55
-35
lines changed

src/component/ConnectionPopover/index.less

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,12 @@
55
}
66
.label {
77
color: var(--text-color-hint);
8+
white-space: nowrap;
9+
}
10+
.describe {
11+
display: flex;
12+
}
13+
.content {
14+
flex: 1;
15+
word-break: break-word;
816
}

src/component/ConnectionPopover/index.tsx

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,42 +49,46 @@ const ConnectionPopover: React.FC<{
4949

5050
const databaseRemarkDescription = useMemo(() => {
5151
return (
52-
<div style={{ display: 'flex' }}>
53-
<span style={{ whiteSpace: 'nowrap' }} className={styles.label}>
52+
<div className={styles.describe}>
53+
<span className={styles.label}>
5454
{formatMessage({
5555
id: 'src.component.ConnectionPopover.7A11191E',
5656
defaultMessage: '备注:',
5757
})}
5858
</span>
59-
<div style={{ width: '260px', wordBreak: 'break-word' }}>{database?.remark ?? '-'}</div>
59+
<div className={styles.content}>{database?.remark ?? '-'}</div>
6060
</div>
6161
);
6262
}, [database]);
6363

6464
const dataSourceDescription = useMemo(() => {
6565
return (
66-
<div style={{ display: 'flex' }}>
66+
<div className={styles.describe}>
6767
<span className={styles.label}>
6868
{formatMessage({
6969
id: 'src.component.ConnectionPopover.2A18AD55',
7070
defaultMessage: '数据源:',
7171
})}
7272
</span>
73-
<div>{connection?.name || database?.dataSource?.name || '-'}</div>
73+
<div className={styles.content}>
74+
{connection?.name || database?.dataSource?.name || '-'}
75+
</div>
7476
</div>
7577
);
7678
}, [connection, database]);
7779

7880
const projectDescription = useMemo(() => {
7981
return (
80-
<div style={{ display: 'flex' }}>
82+
<div className={styles.describe}>
8183
<span className={styles.label}>
8284
{formatMessage({
8385
id: 'src.component.ConnectionPopover.16ED170C',
8486
defaultMessage: '项目:',
8587
})}
8688
</span>
87-
<div>{database?.project?.name || connection?.projectName || '-'}</div>
89+
<div className={styles.content}>
90+
{database?.project?.name || connection?.projectName || '-'}
91+
</div>
8892
</div>
8993
);
9094
}, [database, connection]);
@@ -95,7 +99,7 @@ const ConnectionPopover: React.FC<{
9599
onClick={(e) => {
96100
e.stopPropagation();
97101
}}
98-
style={{ lineHeight: '20px' }}
102+
style={{ lineHeight: '20px', maxWidth: '280px' }}
99103
>
100104
<Space direction="vertical">
101105
<Tooltip title={connection?.name}>
@@ -105,7 +109,7 @@ const ConnectionPopover: React.FC<{
105109
fontFamily: 'PingFangSC-Semibold',
106110
color: 'var(--text-color-primary)',
107111
fontWeight: 'bold',
108-
width: '240px',
112+
width: '280px',
109113
overflow: 'hidden',
110114
whiteSpace: 'nowrap',
111115
textOverflow: 'ellipsis',
@@ -154,7 +158,7 @@ const ConnectionPopover: React.FC<{
154158
onClick={(e) => {
155159
e.stopPropagation();
156160
}}
157-
style={{ lineHeight: '20px' }}
161+
style={{ lineHeight: '20px', maxWidth: '280px' }}
158162
>
159163
<Space direction="vertical">
160164
<Tooltip>
@@ -164,7 +168,7 @@ const ConnectionPopover: React.FC<{
164168
fontFamily: 'PingFangSC-Semibold',
165169
color: 'var(--text-color-primary)',
166170
fontWeight: 'bold',
167-
width: '240px',
171+
width: '280px',
168172
overflow: 'hidden',
169173
whiteSpace: 'nowrap',
170174
textOverflow: 'ellipsis',
@@ -221,7 +225,7 @@ const ConnectionPopover: React.FC<{
221225
}
222226

223227
let clusterAndTenant = (
224-
<div>
228+
<div className={styles.describe}>
225229
<span className={styles.label}>
226230
{
227231
formatMessage({
@@ -232,39 +236,46 @@ const ConnectionPopover: React.FC<{
232236
/*集群/租户:*/
233237
}
234238
</span>
235-
{connection?.clusterName || '- '}/{connection?.tenantName || ' -'}
239+
<span className={styles.content}>
240+
{connection?.clusterName || '- '}/{connection?.tenantName || ' -'}
241+
</span>
236242
</div>
237243
);
238244

239245
if (haveOCP()) {
240246
const isTenantInstance = !!clusterStore.tenantListMap?.[connection?.tenantName];
241247
if (isTenantInstance) {
242248
clusterAndTenant = (
243-
<div>
244-
{
245-
formatMessage({
246-
id: 'odc.component.ConnectionPopover.InstanceId',
247-
defaultMessage: '实例 ID:',
248-
})
249+
<div className={styles.describe}>
250+
<span className={styles.label}>
251+
{
252+
formatMessage({
253+
id: 'odc.component.ConnectionPopover.InstanceId',
254+
defaultMessage: '实例 ID:',
255+
})
249256

250-
/*实例 ID:*/
251-
}
252-
253-
{connection?.tenantName}
257+
/*实例 ID:*/
258+
}
259+
</span>
260+
<span className={styles.content}>{connection?.tenantName}</span>
254261
</div>
255262
);
256263
} else {
257264
clusterAndTenant = (
258-
<div>
259-
{
260-
formatMessage({
261-
id: 'odc.component.ConnectionPopover.InstanceIdTenantId',
262-
defaultMessage: '实例ID/租户ID:',
263-
})
265+
<div className={styles.describe}>
266+
<span className={styles.label}>
267+
{
268+
formatMessage({
269+
id: 'odc.component.ConnectionPopover.InstanceIdTenantId',
270+
defaultMessage: '实例ID/租户ID:',
271+
})
264272

265-
/*实例ID/租户ID:*/
266-
}
267-
{connection?.clusterName}/{connection?.tenantName}
273+
/*实例ID/租户ID:*/
274+
}
275+
</span>
276+
<span className={styles.content}>
277+
{connection?.clusterName}/{connection?.tenantName}
278+
</span>
268279
</div>
269280
);
270281
}
@@ -299,7 +310,6 @@ const ConnectionPopover: React.FC<{
299310
}}
300311
style={{
301312
lineHeight: '20px',
302-
// padding: 12,
303313
maxWidth: '280px',
304314
}}
305315
>
@@ -337,7 +347,7 @@ const ConnectionPopover: React.FC<{
337347
{projectDescription}
338348
{renderConnectionMode()}
339349
{haveOCP() ? null : (
340-
<div>
350+
<div className={styles.describe}>
341351
<span className={styles.label}>
342352
{
343353
formatMessage({
@@ -348,7 +358,9 @@ const ConnectionPopover: React.FC<{
348358
/*主机名/端口:*/
349359
}
350360
</span>
351-
{connection?.host}:{connection?.port}
361+
<span className={styles.content}>
362+
{connection?.host}:{connection?.port}
363+
</span>
352364
</div>
353365
)}
354366

0 commit comments

Comments
 (0)