| 19 | } |
| 20 | |
| 21 | export default function SourceList({ sources, isLoading }: SourceListProps) { |
| 22 | const { sourceId } = useParams<{ sourceId: string }>(); |
| 23 | |
| 24 | if (isLoading) { |
| 25 | return ( |
| 26 | <div className="px-6 py-3 text-sm text-muted-foreground"> |
| 27 | Loading sources... |
| 28 | </div> |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | if (sources.length === 0) { |
| 33 | return ( |
| 34 | <div className="px-6 py-3 text-sm text-muted-foreground"> |
| 35 | No sources configured |
| 36 | </div> |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | return ( |
| 41 | <div className="flex-1 overflow-auto"> |
| 42 | <div className="px-6 py-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider"> |
| 43 | Data Sources |
| 44 | </div> |
| 45 | {sources.map((source) => { |
| 46 | const isActive = sourceId === source.id; |
| 47 | return ( |
| 48 | <Link |
| 49 | key={source.id} |
| 50 | to={`/source/${source.id}`} |
| 51 | className={cn( |
| 52 | 'flex items-center gap-3 px-6 py-3 text-sm font-medium transition-colors', |
| 53 | 'hover:bg-accent hover:text-accent-foreground', |
| 54 | isActive && 'bg-accent text-accent-foreground' |
| 55 | )} |
| 56 | > |
| 57 | <DatabaseIcon type={source.type} /> |
| 58 | <span className="flex-1 flex items-center gap-1.5 min-w-0"> |
| 59 | <span className="truncate">{source.id}</span> |
| 60 | </span> |
| 61 | {source.is_default && ( |
| 62 | <span className="text-xs text-muted-foreground">default</span> |
| 63 | )} |
| 64 | </Link> |
| 65 | ); |
| 66 | })} |
| 67 | </div> |
| 68 | ); |
| 69 | } |