@ -1,7 +1,7 @@
import React , { PureComponent } from 'react' ;
import React , { PureComponent } from 'react' ;
import { css } from 'emotion' ;
import { css } from 'emotion' ;
import { hot } from 'react-hot-loader' ;
import { hot } from 'react-hot-loader' ;
import { connect } from 'react-redux' ;
import { connect , ConnectedProps } from 'react-redux' ;
import { locationService } from '@grafana/runtime' ;
import { locationService } from '@grafana/runtime' ;
import { selectors } from '@grafana/e2e-selectors' ;
import { selectors } from '@grafana/e2e-selectors' ;
import { CustomScrollbar , ScrollbarPosition , stylesFactory , Themeable2 , withTheme2 } from '@grafana/ui' ;
import { CustomScrollbar , ScrollbarPosition , stylesFactory , Themeable2 , withTheme2 } from '@grafana/ui' ;
@ -14,8 +14,8 @@ import { DashboardSettings } from '../components/DashboardSettings';
import { PanelEditor } from '../components/PanelEditor/PanelEditor' ;
import { PanelEditor } from '../components/PanelEditor/PanelEditor' ;
import { initDashboard } from '../state/initDashboard' ;
import { initDashboard } from '../state/initDashboard' ;
import { notifyApp } from 'app/core/actions' ;
import { notifyApp } from 'app/core/actions' ;
import { DashboardInitError , DashboardInitPhase , KioskMode , StoreState } from 'app/types' ;
import { KioskMode , StoreState } from 'app/types' ;
import { DashboardModel , PanelModel } from 'app/features/dashboard/state' ;
import { PanelModel } from 'app/features/dashboard/state' ;
import { PanelInspector } from '../components/Inspector/PanelInspector' ;
import { PanelInspector } from '../components/Inspector/PanelInspector' ;
import { SubMenu } from '../components/SubMenu/SubMenu' ;
import { SubMenu } from '../components/SubMenu/SubMenu' ;
import { cleanUpDashboardAndVariables } from '../state/actions' ;
import { cleanUpDashboardAndVariables } from '../state/actions' ;
@ -50,21 +50,32 @@ type DashboardPageRouteSearchParams = {
refresh? : string ;
refresh? : string ;
} ;
} ;
export interface Props
export const mapStateToProps = ( state : StoreState ) = > ( {
extends Themeable2 ,
initPhase : state.dashboard.initPhase ,
GrafanaRouteComponentProps < DashboardPageRouteParams , DashboardPageRouteSearchParams > {
isInitSlow : state.dashboard.isInitSlow ,
initPhase : DashboardInitPhase ;
initError : state.dashboard.initError ,
isInitSlow : boolean ;
dashboard : state.dashboard.getModel ( ) ,
dashboard : DashboardModel | null ;
} ) ;
initError? : DashboardInitError ;
initDashboard : typeof initDashboard ;
const mapDispatchToProps = {
cleanUpDashboardAndVariables : typeof cleanUpDashboardAndVariables ;
initDashboard ,
notifyApp : typeof notifyApp ;
cleanUpDashboardAndVariables ,
notifyApp ,
cancelVariables ,
templateVarsChangedInUrl ,
} ;
const connector = connect ( mapStateToProps , mapDispatchToProps ) ;
interface OwnProps {
isPanelEditorOpen? : boolean ;
isPanelEditorOpen? : boolean ;
cancelVariables : typeof cancelVariables ;
templateVarsChangedInUrl : typeof templateVarsChangedInUrl ;
}
}
export type Props = Themeable2 &
GrafanaRouteComponentProps < DashboardPageRouteParams , DashboardPageRouteSearchParams > &
ConnectedProps < typeof connector > &
OwnProps ;
export interface State {
export interface State {
editPanel : PanelModel | null ;
editPanel : PanelModel | null ;
viewPanel : PanelModel | null ;
viewPanel : PanelModel | null ;
@ -366,21 +377,6 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
}
}
}
}
export const mapStateToProps = ( state : StoreState ) = > ( {
initPhase : state.dashboard.initPhase ,
isInitSlow : state.dashboard.isInitSlow ,
initError : state.dashboard.initError ,
dashboard : state.dashboard.getModel ( ) ,
} ) ;
const mapDispatchToProps = {
initDashboard ,
cleanUpDashboardAndVariables ,
notifyApp ,
cancelVariables ,
templateVarsChangedInUrl ,
} ;
/ *
/ *
* Styles
* Styles
* /
* /
@ -413,4 +409,4 @@ export const getStyles = stylesFactory((theme: GrafanaTheme2, kioskMode) => {
export const DashboardPage = withTheme2 ( UnthemedDashboardPage ) ;
export const DashboardPage = withTheme2 ( UnthemedDashboardPage ) ;
DashboardPage . displayName = 'DashboardPage' ;
DashboardPage . displayName = 'DashboardPage' ;
export default hot ( module ) ( connect ( mapStateT oP rops , mapDispatchToProps ) ( DashboardPage ) ) ;
export default hot ( module ) ( connector ( DashboardPage ) ) ;