1
1
import { cx } from '@emotion/css' ;
2
+ import { Portal } from '@mui/material' ;
2
3
import React , { PureComponent } from 'react' ;
3
4
import { connect , ConnectedProps , MapDispatchToProps , MapStateToProps } from 'react-redux' ;
4
5
@@ -71,7 +72,7 @@ export type MapStateToDashboardPageProps = MapStateToProps<
71
72
Pick < DashboardState , 'initPhase' | 'initError' > & {
72
73
dashboard : ReturnType < DashboardState [ 'getModel' ] > ;
73
74
navIndex : StoreState [ 'navIndex' ] ;
74
- } & Pick < FnGlobalState , 'FNDashboard' > ,
75
+ } & Pick < FnGlobalState , 'FNDashboard' | 'controlsContainer' > ,
75
76
OwnProps ,
76
77
StoreState
77
78
> ;
@@ -92,6 +93,7 @@ export const mapStateToProps: MapStateToDashboardPageProps = (state) => ({
92
93
dashboard : state . dashboard . getModel ( ) ,
93
94
navIndex : state . navIndex ,
94
95
FNDashboard : state . fnGlobalState . FNDashboard ,
96
+ controlsContainer : state . fnGlobalState . controlsContainer ,
95
97
} ) ;
96
98
97
99
const mapDispatchToProps : MapDispatchToDashboardPageProps = {
@@ -376,7 +378,7 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
376
378
}
377
379
378
380
render ( ) {
379
- const { dashboard, initError, queryParams, FNDashboard } = this . props ;
381
+ const { dashboard, initError, queryParams, FNDashboard, controlsContainer } = this . props ;
380
382
const { editPanel, viewPanel, updateScrollTop, pageNav, sectionNav } = this . state ;
381
383
const kioskMode = getKioskMode ( this . props . queryParams ) ;
382
384
@@ -402,6 +404,18 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
402
404
) ;
403
405
}
404
406
407
+ const FNTimeRange = ! controlsContainer ? (
408
+ < ToolbarButtonRow alignment = "right" style = { { marginBottom : '16px' } } >
409
+ < DashNavTimeControls dashboard = { dashboard } onChangeTimeZone = { updateTimeZoneForSession } key = "time-controls" />
410
+ </ ToolbarButtonRow >
411
+ ) : (
412
+ < Portal container = { document . getElementById ( controlsContainer ) ! } >
413
+ < ToolbarButtonRow >
414
+ < DashNavTimeControls dashboard = { dashboard } onChangeTimeZone = { updateTimeZoneForSession } key = "time-controls" />
415
+ </ ToolbarButtonRow >
416
+ </ Portal >
417
+ ) ;
418
+
405
419
return (
406
420
< React . Fragment >
407
421
< Page
@@ -416,13 +430,7 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
416
430
{ showToolbar && (
417
431
< header data-testid = { selectors . pages . Dashboard . DashNav . navV2 } >
418
432
{ FNDashboard ? (
419
- < ToolbarButtonRow alignment = "right" style = { { marginBottom : '16px' } } >
420
- < DashNavTimeControls
421
- dashboard = { dashboard }
422
- onChangeTimeZone = { updateTimeZoneForSession }
423
- key = "time-controls"
424
- />
425
- </ ToolbarButtonRow >
433
+ FNTimeRange
426
434
) : (
427
435
< DashNav
428
436
dashboard = { dashboard }
0 commit comments