mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
* Began work on panel menu * SceneDashboard: Basic state handling for inspect panel * Switched to using scene url sync instead * Updated * Update comment on hack * Fixed url synnc issues and more / better DashboardsLoader tests * Progress on test * Updates * Progress * Progress * Update * Update * Update * Update * Update scenes lib * Update * Update --------- Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
37 lines
1023 B
TypeScript
37 lines
1023 B
TypeScript
// Libraries
|
|
import React, { useEffect } from 'react';
|
|
|
|
import { PageLayoutType } from '@grafana/data';
|
|
import { Page } from 'app/core/components/Page/Page';
|
|
import PageLoader from 'app/core/components/PageLoader/PageLoader';
|
|
import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
|
|
|
|
import { getDashboardLoader } from './DashboardsLoader';
|
|
|
|
export interface Props extends GrafanaRouteComponentProps<{ uid: string }> {}
|
|
|
|
export const DashboardScenePage = ({ match }: Props) => {
|
|
const loader = getDashboardLoader();
|
|
const { dashboard, isLoading } = loader.useState();
|
|
|
|
useEffect(() => {
|
|
loader.loadAndInit(match.params.uid);
|
|
return () => {
|
|
loader.clearState();
|
|
};
|
|
}, [loader, match.params.uid]);
|
|
|
|
if (!dashboard) {
|
|
return (
|
|
<Page layout={PageLayoutType.Canvas}>
|
|
{isLoading && <PageLoader />}
|
|
{!isLoading && <h2>Dashboard not found</h2>}
|
|
</Page>
|
|
);
|
|
}
|
|
|
|
return <dashboard.Component model={dashboard} />;
|
|
};
|
|
|
|
export default DashboardScenePage;
|