mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* SceneDashboard: Discard changes now works * To save model works and start at save drawer * Update * Added missing file * Refactorings to keep responsibility more logical * Refactorings * Removed file * Fixed state issue * Update * Update
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
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 { getDashboardScenePageStateManager } from './DashboardScenePageStateManager';
|
|
|
|
export interface Props extends GrafanaRouteComponentProps<{ uid: string }> {}
|
|
|
|
export function DashboardScenePage({ match }: Props) {
|
|
const stateManager = getDashboardScenePageStateManager();
|
|
const { dashboard, isLoading } = stateManager.useState();
|
|
|
|
useEffect(() => {
|
|
stateManager.loadAndInit(match.params.uid);
|
|
return () => {
|
|
stateManager.clearState();
|
|
};
|
|
}, [stateManager, 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;
|