mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Separate SoloPanel rendering logic (#41408)
This commit is contained in:
parent
27f66a6df9
commit
112e44181e
@ -4,7 +4,7 @@ import AutoSizer from 'react-virtualized-auto-sizer';
|
||||
import { DashboardPanel } from '../dashgrid/DashboardPanel';
|
||||
import { initDashboard } from '../state/initDashboard';
|
||||
import { StoreState } from 'app/types';
|
||||
import { PanelModel } from 'app/features/dashboard/state';
|
||||
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
||||
import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
|
||||
|
||||
export interface DashboardPageRouteParams {
|
||||
@ -74,41 +74,54 @@ export class SoloPanelPage extends Component<Props, State> {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { dashboard } = this.props;
|
||||
const { notFound, panel } = this.state;
|
||||
|
||||
if (notFound) {
|
||||
return <div className="alert alert-error">Panel with id {this.getPanelId()} not found</div>;
|
||||
}
|
||||
|
||||
if (!panel || !dashboard) {
|
||||
return <div>Loading & initializing dashboard</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="panel-solo">
|
||||
<AutoSizer>
|
||||
{({ width, height }) => {
|
||||
if (width === 0) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<DashboardPanel
|
||||
stateKey={panel.key}
|
||||
width={width}
|
||||
height={height}
|
||||
dashboard={dashboard}
|
||||
panel={panel}
|
||||
isEditing={false}
|
||||
isViewing={false}
|
||||
isInView={true}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
</AutoSizer>
|
||||
</div>
|
||||
<SoloPanel
|
||||
dashboard={this.props.dashboard}
|
||||
notFound={this.state.notFound}
|
||||
panel={this.state.panel}
|
||||
panelId={this.getPanelId()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export interface SoloPanelProps extends State {
|
||||
dashboard: DashboardModel | null;
|
||||
panelId: number;
|
||||
}
|
||||
|
||||
export const SoloPanel = ({ dashboard, notFound, panel, panelId }: SoloPanelProps) => {
|
||||
if (notFound) {
|
||||
return <div className="alert alert-error">Panel with id {panelId} not found</div>;
|
||||
}
|
||||
|
||||
if (!panel || !dashboard) {
|
||||
return <div>Loading & initializing dashboard</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="panel-solo">
|
||||
<AutoSizer>
|
||||
{({ width, height }) => {
|
||||
if (width === 0) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<DashboardPanel
|
||||
stateKey={panel.key}
|
||||
width={width}
|
||||
height={height}
|
||||
dashboard={dashboard}
|
||||
panel={panel}
|
||||
isEditing={false}
|
||||
isViewing={false}
|
||||
isInView={true}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
</AutoSizer>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default connector(SoloPanelPage);
|
||||
|
Loading…
Reference in New Issue
Block a user