grafana/public/app/features/scenes/dashboard/DashboardScenePage.tsx
Torkel Ödegaard e7797ac439
SceneDashboard: Adds menu to panels, a start for inspect drawer state (#71194)
* 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>
2023-07-12 13:37:26 +02:00

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;