1- import { type JSX , useEffect , useRef , useState } from 'react'
2- import { getAdapterNamesFromConfiguration } from '~/routes/builder/xml-to-json-parser'
1+ import React , { type JSX , useEffect , useRef , useState } from 'react'
2+ import { getAdapterListenerType , getAdapterNamesFromConfiguration } from '~/routes/builder/xml-to-json-parser'
33import useTabStore from '~/stores/tab-store'
44import Search from '~/components/search/search'
55import FolderIcon from '/icons/solar/Folder.svg?react'
66import FolderOpenIcon from '/icons/solar/Folder Open.svg?react'
77import CodeIcon from '/icons/solar/Code.svg?react'
8+ import JavaIcon from '/icons/solar/Cup Hot.svg?react'
9+ import MessageIcon from '/icons/solar/Chat Dots.svg?react'
10+ import MailIcon from '/icons/solar/Mailbox.svg?react'
811import 'react-complex-tree/lib/style-modern.css'
912import AltArrowRightIcon from '/icons/solar/Alt Arrow Right.svg?react'
1013import AltArrowDownIcon from '/icons/solar/Alt Arrow Down.svg?react'
@@ -16,15 +19,18 @@ import {
1619 type TreeRef ,
1720 UncontrolledTreeEnvironment ,
1821} from 'react-complex-tree'
19- import BuilderFilesDataProvider from '~/routes/builder/builder-files-data-provider'
22+ import BuilderFilesDataProvider , { type AdapterNodeData } from '~/routes/builder/builder-files-data-provider'
2023import { useProjectStore } from '~/stores/project-store'
2124import { Link } from 'react-router'
2225import { useTreeStore } from '~/stores/tree-store'
2326import { useShallow } from 'zustand/react/shallow'
2427
2528export interface ConfigWithAdapters {
2629 configName : string
27- adapterNames : string [ ]
30+ adapters : {
31+ adapterName : string
32+ listenerName : string | null
33+ } [ ]
2834}
2935
3036const TREE_ID = 'builder-files-tree'
@@ -68,16 +74,27 @@ export default function BuilderStructure() {
6874 const loaded : ConfigWithAdapters [ ] = await Promise . all (
6975 configurationNames . map ( async ( configName ) => {
7076 const adapterNames = await getAdapterNamesFromConfiguration ( configName )
71- return { configName, adapterNames }
77+
78+ // Fetch listener name for each adapter
79+ const adapters = await Promise . all (
80+ adapterNames . map ( async ( adapterName ) => {
81+ const listenerName = await getAdapterListenerType ( configName , adapterName )
82+ return { adapterName, listenerName }
83+ } ) ,
84+ )
85+
86+ return { configName, adapters }
7287 } ) ,
7388 )
89+
7490 setConfigs ( loaded )
7591 } catch ( error ) {
7692 console . error ( 'Failed to load adapter names:' , error )
7793 } finally {
7894 setIsLoading ( false )
7995 }
8096 }
97+
8198 loadAdapters ( )
8299 } , [ configurationNames ] )
83100
@@ -157,10 +174,13 @@ export default function BuilderStructure() {
157174 item : TreeItem < unknown >
158175 context : TreeItemRenderContext
159176 } ) => {
160- const Icon = ( item . isFolder && ( context . isExpanded ? FolderOpenIcon : FolderIcon ) ) || CodeIcon
161-
162177 const searchLower = searchTerm . toLowerCase ( )
163178 const titleLower = title . toLowerCase ( )
179+ const listenerType =
180+ ! item . isFolder && typeof item . data === 'object' && item . data && 'listenerName' in item . data
181+ ? ( item . data as { listenerName : string | null } ) . listenerName
182+ : null
183+ const Icon = item . isFolder ? ( context . isExpanded ? FolderOpenIcon : FolderIcon ) : getListenerIcon ( listenerType )
164184
165185 // Highlight only the substring(s) that match the search term
166186 let highlightedTitle : JSX . Element | string = title
@@ -190,6 +210,20 @@ export default function BuilderStructure() {
190210 )
191211 }
192212
213+ function getListenerIcon ( listenerType : string | null ) {
214+ if ( ! listenerType ) return CodeIcon
215+
216+ // TODO: Add more icons for more important listener types
217+ const listenerIconMap : Record < string , React . FC < React . SVGProps < SVGSVGElement > > > = {
218+ JavaListener : JavaIcon ,
219+ MessageStoreListener : MessageIcon ,
220+ FtpFileSystemListener : FolderIcon ,
221+ ExchangeMailListener : MailIcon ,
222+ }
223+
224+ return listenerIconMap [ listenerType ] ?? CodeIcon
225+ }
226+
193227 return (
194228 < >
195229 < Search onChange = { ( event ) => setSearchTerm ( event . target . value ) } />
0 commit comments