2022-11-17 09:15:51 -06:00
|
|
|
// Libraries
|
2023-01-05 11:55:55 -06:00
|
|
|
import React, { useEffect } from 'react';
|
2022-11-17 09:15:51 -06:00
|
|
|
|
2023-03-16 03:19:50 -05:00
|
|
|
import { PageLayoutType } from '@grafana/data';
|
2022-11-17 09:15:51 -06:00
|
|
|
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 }> {}
|
|
|
|
|
2023-01-05 11:55:55 -06:00
|
|
|
export const DashboardScenePage = ({ match }: Props) => {
|
2022-11-17 09:15:51 -06:00
|
|
|
const loader = getDashboardLoader();
|
|
|
|
const { dashboard, isLoading } = loader.useState();
|
|
|
|
|
|
|
|
useEffect(() => {
|
2023-07-12 06:37:26 -05:00
|
|
|
loader.loadAndInit(match.params.uid);
|
2023-03-16 03:19:50 -05:00
|
|
|
return () => {
|
|
|
|
loader.clearState();
|
|
|
|
};
|
2022-11-17 09:15:51 -06:00
|
|
|
}, [loader, match.params.uid]);
|
|
|
|
|
|
|
|
if (!dashboard) {
|
|
|
|
return (
|
2023-03-16 03:19:50 -05:00
|
|
|
<Page layout={PageLayoutType.Canvas}>
|
2022-11-17 09:15:51 -06:00
|
|
|
{isLoading && <PageLoader />}
|
|
|
|
{!isLoading && <h2>Dashboard not found</h2>}
|
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return <dashboard.Component model={dashboard} />;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default DashboardScenePage;
|