@@ -59,7 +59,7 @@ import { CustomReactTable } from './ReactTable';
59
59
import { DictTable } from '../components/ComponentType' ;
60
60
import { Type } from '../data/types' ;
61
61
import { useDispatch , useSelector } from 'react-redux' ;
62
- import { dfActions } from '../app/dfSlice' ;
62
+ import { dfActions , getSessionId } from '../app/dfSlice' ;
63
63
import { alpha } from '@mui/material' ;
64
64
import { DataFormulatorState } from '../app/dfSlice' ;
65
65
import { fetchFieldSemanticType } from '../app/dfSlice' ;
@@ -278,6 +278,12 @@ export const DBTableSelectionDialog: React.FC<{ buttonElement: any }> = function
278
278
fetchDataLoaders ( ) ;
279
279
} , [ ] ) ;
280
280
281
+ useEffect ( ( ) => {
282
+ if ( errorMessage ?. content . includes ( "session_id not found" ) ) {
283
+ dispatch ( getSessionId ( ) ) ;
284
+ }
285
+ } , [ errorMessage ] )
286
+
281
287
useEffect ( ( ) => {
282
288
if ( dbTables . length == 0 ) {
283
289
setSelectedTabKey ( "" ) ;
@@ -295,7 +301,8 @@ export const DBTableSelectionDialog: React.FC<{ buttonElement: any }> = function
295
301
setDbTables ( data . tables ) ;
296
302
}
297
303
} catch ( error ) {
298
- console . error ( 'Failed to fetch tables:' , error ) ;
304
+ setErrorMessage ( { content : 'Failed to fetch tables, please check if the server is running' , severity : "error" } ) ;
305
+ setShowError ( true ) ;
299
306
}
300
307
} ;
301
308
@@ -343,7 +350,7 @@ export const DBTableSelectionDialog: React.FC<{ buttonElement: any }> = function
343
350
}
344
351
} catch ( error ) {
345
352
console . error ( 'Failed to upload table:' , error ) ;
346
- setErrorMessage ( { content : 'Failed to upload table. The server may need to be restarted. ' , severity : "error" } ) ;
353
+ setErrorMessage ( { content : 'Failed to upload table, please check if the server is running ' , severity : "error" } ) ;
347
354
setShowError ( true ) ;
348
355
} finally {
349
356
setIsUploading ( false ) ;
@@ -377,7 +384,7 @@ export const DBTableSelectionDialog: React.FC<{ buttonElement: any }> = function
377
384
}
378
385
} catch ( error ) {
379
386
console . error ( 'Failed to upload table:' , error ) ;
380
- setErrorMessage ( { content : 'Failed to upload table. The server may need to be restarted. ' , severity : "error" } ) ;
387
+ setErrorMessage ( { content : 'Failed to upload table, please check if the server is running ' , severity : "error" } ) ;
381
388
setShowError ( true ) ;
382
389
} finally {
383
390
setIsUploading ( false ) ;
@@ -423,9 +430,13 @@ export const DBTableSelectionDialog: React.FC<{ buttonElement: any }> = function
423
430
if ( data . status === 'success' ) {
424
431
fetchTables ( ) ;
425
432
setSelectedTabKey ( dbTables . length > 0 ? dbTables [ 0 ] . name : "" ) ;
433
+ } else {
434
+ setErrorMessage ( { content : data . error || 'Failed to delete table' , severity : "error" } ) ;
435
+ setShowError ( true ) ;
426
436
}
427
437
} catch ( error ) {
428
- console . error ( 'Failed to delete table:' , error ) ;
438
+ setErrorMessage ( { content : 'Failed to delete table, please check if the server is running' , severity : "error" } ) ;
439
+ setShowError ( true ) ;
429
440
}
430
441
} ;
431
442
@@ -455,7 +466,7 @@ export const DBTableSelectionDialog: React.FC<{ buttonElement: any }> = function
455
466
}
456
467
} catch ( error ) {
457
468
console . error ( 'Failed to analyze table data:' , error ) ;
458
- setErrorMessage ( { content : 'Failed to analyze table data' , severity : "error" } ) ;
469
+ setErrorMessage ( { content : 'Failed to analyze table data, please check if the server is running ' , severity : "error" } ) ;
459
470
setShowError ( true ) ;
460
471
}
461
472
} ;
@@ -572,11 +583,11 @@ export const DBTableSelectionDialog: React.FC<{ buttonElement: any }> = function
572
583
< Box sx = { { flexGrow : 1 , bgcolor : 'background.paper' , display : 'flex' , flexDirection : 'row' , minHeight : 400 } } >
573
584
< Box sx = { { display : "flex" , flexDirection : "column" , width : "180px" , borderRight : 1 , borderColor : 'divider' } } >
574
585
< Tabs
586
+ value = { 0 } // not used, just to keep MUI happy
575
587
orientation = "vertical"
576
588
variant = "scrollable"
577
589
scrollButtons = { dbTables . length > 8 ? "auto" : false }
578
590
allowScrollButtonsMobile
579
- value = { selectedTabKey }
580
591
aria-label = "Database tables"
581
592
sx = { {
582
593
maxHeight : '360px' ,
@@ -629,14 +640,13 @@ export const DBTableSelectionDialog: React.FC<{ buttonElement: any }> = function
629
640
orientation = "vertical"
630
641
textColor = "secondary"
631
642
indicatorColor = "secondary"
632
- value = { selectedTabKey }
643
+ value = { 0 } // not used, just to keep MUI happy
633
644
sx = { { px : 0.5 } }
634
645
>
635
646
< Typography variant = "caption" sx = { { color : "text.secondary" , fontWeight : "bold" , px : 1 } } > connect external data</ Typography >
636
647
{ [ "file upload" , "mysql" , "kusto" ] . map ( ( dataLoaderType , i ) => (
637
648
< Tab
638
649
key = { `dataLoader:${ dataLoaderType } ` }
639
- value = { `dataLoader:${ dataLoaderType } ` }
640
650
wrapped
641
651
label = { < Typography variant = "caption"
642
652
sx = { { textTransform : "none" , width : "calc(100% - 4px)" , textAlign : 'left' ,
@@ -651,7 +661,7 @@ export const DBTableSelectionDialog: React.FC<{ buttonElement: any }> = function
651
661
) ) }
652
662
</ Tabs >
653
663
</ Box >
654
- < TabPanel key = { `dataLoader:file upload ` } sx = { { width : 960 , } } show = { selectedTabKey === '' } >
664
+ < TabPanel key = { `dataLoader:note ` } sx = { { width : 960 , } } show = { selectedTabKey === '' } >
655
665
< Typography variant = "caption" sx = { { color : "text.secondary" , px : 1 } } > The database is empty, refresh the table list or import some data to get started.</ Typography >
656
666
</ TabPanel >
657
667
< TabPanel key = { `dataLoader:file upload` } sx = { { width : 960 , } } show = { selectedTabKey === 'dataLoader:file upload' } >
@@ -661,6 +671,7 @@ export const DBTableSelectionDialog: React.FC<{ buttonElement: any }> = function
661
671
< TabPanel key = { `dataLoader:${ dataLoaderType } ` } sx = { { width : 960 , position : "relative" , maxWidth : '100%' } }
662
672
show = { selectedTabKey === 'dataLoader:' + dataLoaderType } >
663
673
< DataLoaderForm
674
+ key = { `data-loader-form-${ dataLoaderType } ` }
664
675
dataLoaderType = { dataLoaderType }
665
676
paramDefs = { paramDefs }
666
677
onImport = { ( ) => {
@@ -998,14 +1009,13 @@ export const DataLoaderForm: React.FC<{
998
1009
return [ table . name , table . metadata ] ;
999
1010
} ) ) ) ;
1000
1011
} else {
1001
- console . error ( 'Failed to fetch data loader tables:' , data . message ) ;
1012
+ console . error ( 'Failed to fetch data loader tables: {} ' , data . message ) ;
1002
1013
onFinish ( "error" , `Failed to fetch data loader tables: ${ data . message } ` ) ;
1003
1014
}
1004
1015
setIsConnecting ( false ) ;
1005
1016
} )
1006
1017
. catch ( error => {
1007
- console . error ( 'Failed to fetch data loader tables:' , error ) ;
1008
- onFinish ( "error" , `Failed to fetch data loader tables: ${ error } ` ) ;
1018
+ onFinish ( "error" , `Failed to fetch data loader tables, please check the server is running` ) ;
1009
1019
setIsConnecting ( false ) ;
1010
1020
} ) ;
1011
1021
} } >
0 commit comments