2018-07-05 15:10:39 -05:00
|
|
|
import React, { ComponentClass } from 'react';
|
2018-06-19 07:51:57 -05:00
|
|
|
import { PanelModel } from '../panel_model';
|
|
|
|
import { DashboardModel } from '../dashboard_model';
|
|
|
|
import { PanelHeader } from './PanelHeader';
|
2018-07-05 15:10:39 -05:00
|
|
|
import { DataPanel, PanelProps, DataPanelWrapper } from './DataPanel';
|
2018-06-19 07:51:57 -05:00
|
|
|
|
2018-07-01 10:34:42 -05:00
|
|
|
export interface Props {
|
2018-06-19 07:51:57 -05:00
|
|
|
panel: PanelModel;
|
|
|
|
dashboard: DashboardModel;
|
2018-07-05 15:10:39 -05:00
|
|
|
component: ComponentClass<PanelProps>;
|
2018-06-19 07:51:57 -05:00
|
|
|
}
|
|
|
|
|
2018-07-09 11:17:51 -05:00
|
|
|
interface State {}
|
2018-07-05 15:10:39 -05:00
|
|
|
|
2018-07-09 15:24:15 -05:00
|
|
|
// cache DataPanel wrapper components
|
|
|
|
const dataPanels: { [s: string]: DataPanel } = {};
|
|
|
|
|
2018-07-05 15:10:39 -05:00
|
|
|
export class PanelChrome extends React.Component<Props, State> {
|
|
|
|
panelComponent: DataPanel;
|
|
|
|
|
2018-06-19 07:51:57 -05:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2018-07-05 15:10:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-07-09 15:24:15 -05:00
|
|
|
const { type } = this.props.panel;
|
|
|
|
|
|
|
|
let PanelComponent = dataPanels[type];
|
|
|
|
|
|
|
|
if (!PanelComponent) {
|
|
|
|
PanelComponent = dataPanels[type] = DataPanelWrapper(this.props.component);
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('PanelChrome render', PanelComponent);
|
2018-06-19 07:51:57 -05:00
|
|
|
|
|
|
|
return (
|
2018-07-09 11:17:51 -05:00
|
|
|
<div className="panel-container">
|
|
|
|
<PanelHeader panel={this.props.panel} dashboard={this.props.dashboard} />
|
|
|
|
<div className="panel-content">{<PanelComponent type={'test'} queries={[]} isVisible={true} />}</div>
|
2018-06-19 07:51:57 -05:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|