@@ -11,6 +11,7 @@ import {
1111 NodeRegistration ,
1212 UpsertGraphTemplateRequest ,
1313 UpsertGraphTemplateResponse ,
14+ ListNamespacesResponse ,
1415} from '@/types/state-manager' ;
1516import {
1617 GitBranch ,
@@ -23,12 +24,14 @@ import {
2324import { Card , CardContent , CardDescription , CardHeader , CardTitle } from '@/components/ui/card' ;
2425import { Button } from '@/components/ui/button' ;
2526import { Input } from '@/components/ui/input' ;
27+ import { Select } from '@/components/ui/select' ;
2628import { Tabs , TabsContent , TabsList , TabsTrigger } from '@/components/ui/tabs' ;
2729import { Alert , AlertDescription } from '@/components/ui/alert' ;
2830
2931export default function Dashboard ( ) {
3032 const [ activeTab , setActiveTab ] = useState < 'overview' | 'graph' | 'runs' > ( 'overview' ) ;
3133 const [ namespace , setNamespace ] = useState ( 'default' ) ;
34+ const [ availableNamespaces , setAvailableNamespaces ] = useState < string [ ] > ( [ ] ) ;
3235 const [ graphName , setGraphName ] = useState ( 'test-graph' ) ;
3336 const [ graphTemplate , setGraphTemplate ] = useState < UpsertGraphTemplateRequest | null > ( null ) ;
3437
@@ -41,21 +44,32 @@ export default function Dashboard() {
4144 const [ selectedGraphTemplate , setSelectedGraphTemplate ] = useState < UpsertGraphTemplateResponse | null > ( null ) ;
4245 const [ isGraphModalOpen , setIsGraphModalOpen ] = useState ( false ) ;
4346
44- // Fetch configuration on component mount
47+ // Fetch configuration and namespaces on component mount
4548 useEffect ( ( ) => {
46- const fetchConfig = async ( ) => {
49+ const fetchConfigAndNamespaces = async ( ) => {
4750 try {
48- const response = await fetch ( '/api/config' ) ;
49- if ( response . ok ) {
50- const config = await response . json ( ) ;
51+ // Fetch configuration
52+ const configResponse = await fetch ( '/api/config' ) ;
53+ if ( configResponse . ok ) {
54+ const config = await configResponse . json ( ) ;
5155 setNamespace ( config . defaultNamespace ) ;
5256 }
57+
58+ // Fetch available namespaces
59+ const namespacesData = await clientApiService . getNamespaces ( ) ;
60+ setAvailableNamespaces ( namespacesData . namespaces || [ ] ) ;
61+
62+ // If no namespaces available and we have a default, add it
63+ if ( namespacesData . namespaces ?. length === 0 ) {
64+ setAvailableNamespaces ( [ 'default' ] ) ;
65+ }
5366 } catch ( error ) {
54- console . warn ( 'Failed to fetch config, using default namespace' ) ;
67+ console . warn ( 'Failed to fetch config or namespaces, using defaults' ) ;
68+ setAvailableNamespaces ( [ 'default' ] ) ;
5569 }
5670 } ;
5771
58- fetchConfig ( ) ;
72+ fetchConfigAndNamespaces ( ) ;
5973 } , [ ] ) ;
6074
6175 const handleSaveGraphTemplate = async ( template : UpsertGraphTemplateRequest ) => {
@@ -117,12 +131,23 @@ export default function Dashboard() {
117131 < div className = "flex items-center space-x-4" >
118132 < div className = "flex items-center space-x-2" >
119133 < span className = "text-sm text-muted-foreground" > Namespace:</ span >
120- < Input
121- type = "text"
134+ < Select
122135 value = { namespace }
123136 onChange = { ( e ) => setNamespace ( e . target . value ) }
124137 className = "w-32 h-8"
125- />
138+ >
139+ { availableNamespaces . map ( ( ns ) => (
140+ < option key = { ns } value = { ns } >
141+ { ns }
142+ </ option >
143+ ) ) }
144+ { /* Show current namespace even if not in the list */ }
145+ { ! availableNamespaces . includes ( namespace ) && (
146+ < option key = { namespace } value = { namespace } >
147+ { namespace }
148+ </ option >
149+ ) }
150+ </ Select >
126151 </ div >
127152 </ div >
128153 </ div >
0 commit comments