Skip to content

Commit 185b361

Browse files
[INLONG-12052][Dashboard] Optimization of text display in long forms on resource details page (#12053)
1 parent 9efa3fa commit 185b361

File tree

3 files changed

+88
-9
lines changed

3 files changed

+88
-9
lines changed

inlong-dashboard/src/ui/locales/cn.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@
755755
"pages.GroupDetail.OperationLog.Table.OperationTarget": "操作目标",
756756
"pages.GroupDetail.OperationLog.Table.Log": "日志",
757757
"pages.GroupDetail.OperationLog.Table.OperationTime": "操作时间",
758+
"pages.GroupDetail.Resource.Collapse": "收起",
758759
"pages.ApprovalDetail.GroupConfig.DataStorages": "数据存储",
759760
"pages.ApprovalDetail.GroupConfig.ApprovalInformation": "审批信息",
760761
"pages.ApprovalDetail.GroupConfig.DataFlowInformation": "数据流信息",

inlong-dashboard/src/ui/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@
749749
"pages.GroupDetail.OperationLog.Table.OperationTarget": "Operation target",
750750
"pages.GroupDetail.OperationLog.Table.Log": "Log",
751751
"pages.GroupDetail.OperationLog.Table.OperationTime": "Operation time",
752+
"pages.GroupDetail.Resource.Collapse": "Collapse",
752753
"pages.ApprovalDetail.GroupConfig.DataStorages": "Data storages",
753754
"pages.ApprovalDetail.GroupConfig.ApprovalInformation": "Approval information",
754755
"pages.ApprovalDetail.GroupConfig.DataFlowInformation": "Data stream information",

inlong-dashboard/src/ui/pages/GroupDetail/ResourceInfo/index.tsx

Lines changed: 86 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
*/
1919

2020
import React, { useEffect, useMemo, forwardRef, useState } from 'react';
21-
import { Divider, Table } from 'antd';
21+
import { Divider, Table, Tag, Tooltip } from 'antd';
2222
import FormGenerator, { useForm } from '@/ui/components/FormGenerator';
2323
import { useRequest } from '@/ui/hooks';
2424
import { useTranslation } from 'react-i18next';
2525
import { CommonInterface } from '../common';
2626
import { clusters } from '@/plugins/clusters';
2727
import HighTable from '@/ui/components/HighTable';
28+
import i18n from '@/i18n';
2829

2930
type Props = CommonInterface;
3031

@@ -37,6 +38,7 @@ const Comp = ({ inlongGroupId, isCreate }: Props, ref) => {
3738
return !!inlongGroupId;
3839
}, [inlongGroupId]);
3940

41+
const [expandedFields, setExpandedFields] = useState<Record<string, boolean>>({});
4042
const [sortOption, setSortOption] = useState({
4143
inlongGroupId: inlongGroupId,
4244
inlongStreamId: '',
@@ -74,12 +76,89 @@ const Comp = ({ inlongGroupId, isCreate }: Props, ref) => {
7476
let content = [];
7577
if (data[item].constructor === Object) {
7678
for (const key in data[item]) {
77-
content.push({
78-
label: key,
79-
name: item + '_' + key,
80-
type: 'text',
81-
initialValue: data[item][key],
82-
});
79+
console.log('key:', data, item, key, data[item]);
80+
if (data[item][key]?.constructor === Array) {
81+
content.push({
82+
label: key,
83+
name: item + '_' + key,
84+
type: () => {
85+
const urlList = Array.isArray(data[item][key]) ? data[item][key] : [];
86+
if (urlList.length === 0) return null;
87+
88+
const fieldKey = `${item}_${key}`;
89+
const isExpanded = expandedFields[fieldKey] || false;
90+
const displayCount = 10;
91+
const displayList = isExpanded ? urlList : urlList.slice(0, displayCount);
92+
const remainingCount = urlList.length - displayCount;
93+
94+
return (
95+
<div style={{ width: '80vw' }}>
96+
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px' }}>
97+
{displayList.map((url, index) => (
98+
<Tooltip key={`url-${index}`} title={url}>
99+
<Tag
100+
style={{
101+
maxWidth: '300px',
102+
overflow: 'hidden',
103+
textOverflow: 'ellipsis',
104+
whiteSpace: 'nowrap',
105+
cursor: 'default',
106+
}}
107+
>
108+
{url}
109+
</Tag>
110+
</Tooltip>
111+
))}
112+
{!isExpanded && remainingCount > 0 && (
113+
<Tag
114+
style={{
115+
cursor: 'pointer',
116+
backgroundColor: '#f0f0f0',
117+
borderStyle: 'dashed',
118+
}}
119+
onClick={() => {
120+
setExpandedFields(prev => ({
121+
...prev,
122+
[fieldKey]: true,
123+
}));
124+
}}
125+
>
126+
+{remainingCount}
127+
</Tag>
128+
)}
129+
{isExpanded && urlList.length > displayCount && (
130+
<Tag
131+
style={{
132+
cursor: 'pointer',
133+
backgroundColor: '#f0f0f0',
134+
borderStyle: 'dashed',
135+
}}
136+
onClick={() => {
137+
setExpandedFields(prev => ({
138+
...prev,
139+
[fieldKey]: false,
140+
}));
141+
}}
142+
>
143+
{i18n.t('pages.GroupDetail.Resource.Collapse')}
144+
</Tag>
145+
)}
146+
</div>
147+
</div>
148+
);
149+
},
150+
initialValue: data[item][key],
151+
visible: !!data[item][key],
152+
});
153+
} else {
154+
content.push({
155+
label: key,
156+
name: item + '_' + key,
157+
type: 'text',
158+
initialValue: data[item][key],
159+
visible: !!data[item][key],
160+
});
161+
}
83162
}
84163
return content;
85164
}
@@ -182,7 +261,6 @@ const Comp = ({ inlongGroupId, isCreate }: Props, ref) => {
182261
]}
183262
style={{ marginTop: 20 }}
184263
dataSource={data?.PULSAR}
185-
pagination={false}
186264
rowKey="name"
187265
></Table>
188266
</>
@@ -200,7 +278,6 @@ const Comp = ({ inlongGroupId, isCreate }: Props, ref) => {
200278
]}
201279
style={{ marginTop: 20, width: 1100 }}
202280
dataSource={data?.TUBEMQ}
203-
pagination={false}
204281
rowKey="name"
205282
></Table>
206283
</>

0 commit comments

Comments
 (0)