1818 */
1919
2020import React , { useEffect , useMemo , forwardRef , useState } from 'react' ;
21- import { Divider , Table } from 'antd' ;
21+ import { Divider , Table , Tag , Tooltip } from 'antd' ;
2222import FormGenerator , { useForm } from '@/ui/components/FormGenerator' ;
2323import { useRequest } from '@/ui/hooks' ;
2424import { useTranslation } from 'react-i18next' ;
2525import { CommonInterface } from '../common' ;
2626import { clusters } from '@/plugins/clusters' ;
2727import HighTable from '@/ui/components/HighTable' ;
28+ import i18n from '@/i18n' ;
2829
2930type 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