@@ -126,11 +126,11 @@ export interface PanelState {
126126
127127export interface IrisGridPanelProps {
128128 children ?: ReactNode ;
129- dh : DhType ;
130129 glContainer : Container ;
131130 glEventHub : EventEmitter ;
132131 metadata : Metadata ;
133132 panelState : PanelState | null ;
133+ makeApi : ( ) => DhType | Promise < DhType > ;
134134 makeModel : ( ) => IrisGridModel | Promise < IrisGridModel > ;
135135 inputFilters : InputFilter [ ] ;
136136 links : Link [ ] ;
@@ -246,11 +246,11 @@ export class IrisGridPanel extends PureComponent<
246246 this . irisGrid = React . createRef ( ) ;
247247 this . pluginRef = React . createRef ( ) ;
248248
249- const { panelState, dh } = props ;
249+ const { panelState } = props ;
250250
251251 this . pluginState = null ;
252- this . dh = dh ;
253- this . irisGridUtils = new IrisGridUtils ( dh ) ;
252+ this . dh = null ;
253+ this . irisGridUtils = null ;
254254
255255 this . state = {
256256 error : null ,
@@ -345,9 +345,9 @@ export class IrisGridPanel extends PureComponent<
345345
346346 pluginState : unknown ;
347347
348- private dh : DhType ;
348+ private dh : DhType | null ;
349349
350- private irisGridUtils : IrisGridUtils ;
350+ private irisGridUtils : IrisGridUtils | null ;
351351
352352 getTableName ( ) : string {
353353 const { metadata } = this . props ;
@@ -468,8 +468,9 @@ export class IrisGridPanel extends PureComponent<
468468 frozenColumns : readonly ColumnName [ ] ,
469469 conditionalFormats : readonly SidebarFormattingRule [ ] ,
470470 columnHeaderGroups : readonly ColumnHeaderGroup [ ]
471- ) =>
472- this . irisGridUtils . dehydrateIrisGridState ( model , {
471+ ) => {
472+ assertNotNull ( this . irisGridUtils ) ;
473+ return this . irisGridUtils . dehydrateIrisGridState ( model , {
473474 advancedFilters,
474475 aggregationSettings,
475476 customColumnFormatMap,
@@ -492,7 +493,8 @@ export class IrisGridPanel extends PureComponent<
492493 frozenColumns,
493494 conditionalFormats,
494495 columnHeaderGroups,
495- } )
496+ } ) ;
497+ }
496498 ) ;
497499
498500 getDehydratedGridState = memoize (
@@ -527,12 +529,17 @@ export class IrisGridPanel extends PureComponent<
527529
528530 initModel ( ) : void {
529531 this . setState ( { isModelReady : false , isLoading : true , error : null } ) ;
530- const { makeModel } = this . props ;
532+ const { makeApi , makeModel } = this . props ;
531533 if ( this . modelPromise != null ) {
532534 this . modelPromise . cancel ( ) ;
533535 }
534- this . modelPromise = PromiseUtils . makeCancelable ( makeModel ( ) , resolved =>
535- resolved . close ( )
536+ this . modelPromise = PromiseUtils . makeCancelable (
537+ Promise . resolve ( makeApi ( ) ) . then ( dh => {
538+ this . dh = dh ;
539+ this . irisGridUtils = new IrisGridUtils ( dh ) ;
540+ return makeModel ( ) ;
541+ } ) ,
542+ resolved => resolved . close ( )
536543 ) ;
537544 this . modelPromise . then ( this . handleLoadSuccess ) . catch ( this . handleLoadError ) ;
538545 }
@@ -615,11 +622,12 @@ export class IrisGridPanel extends PureComponent<
615622 const { model } = this . state ;
616623 assertNotNull ( model ) ;
617624 const { columns, formatter } = model ;
618- const pluginFilters = this . irisGridUtils . getFiltersFromInputFilters (
619- columns ,
620- filters ,
621- formatter . timeZone
622- ) ;
625+ const pluginFilters =
626+ this . irisGridUtils ?. getFiltersFromInputFilters (
627+ columns ,
628+ filters ,
629+ formatter . timeZone
630+ ) ?? [ ] ;
623631 this . setState ( { pluginFilters } ) ;
624632 }
625633
@@ -946,7 +954,7 @@ export class IrisGridPanel extends PureComponent<
946954 model . columns ,
947955 advancedFilters
948956 ) . filter ( ( [ columnIndex ] ) => model . isFilterable ( columnIndex ) ) ;
949-
957+ assertNotNull ( this . irisGridUtils ) ;
950958 irisGrid . clearAllFilters ( ) ;
951959 irisGrid . setFilters ( {
952960 quickFilters : this . irisGridUtils . hydrateQuickFilters (
@@ -1024,6 +1032,7 @@ export class IrisGridPanel extends PureComponent<
10241032 partitionColumn,
10251033 advancedSettings,
10261034 } = IrisGridUtils . hydrateIrisGridPanelState ( model , irisGridPanelState ) ;
1035+ assertNotNull ( this . irisGridUtils ) ;
10271036 const {
10281037 advancedFilters,
10291038 customColumns,
@@ -1196,6 +1205,7 @@ export class IrisGridPanel extends PureComponent<
11961205 }
11971206
11981207 render ( ) : ReactElement {
1208+ const { dh } = this ;
11991209 const {
12001210 children,
12011211 glContainer,
@@ -1288,7 +1298,7 @@ export class IrisGridPanel extends PureComponent<
12881298 />
12891299 ) }
12901300 >
1291- { isModelReady && model && (
1301+ { isModelReady && model && dh && (
12921302 < IrisGrid
12931303 advancedFilters = { advancedFilters }
12941304 aggregationSettings = { aggregationSettings }
0 commit comments