mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
34 lines
821 B
TypeScript
34 lines
821 B
TypeScript
// Libraries
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
import { getUrlSyncManager } from '@grafana/scenes';
|
|
import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
|
|
|
|
import { getSceneByTitle } from './scenes';
|
|
|
|
export interface Props extends GrafanaRouteComponentProps<{ name: string }> {}
|
|
|
|
export const ScenePage = (props: Props) => {
|
|
const scene = getSceneByTitle(props.match.params.name);
|
|
const [isInitialized, setInitialized] = useState(false);
|
|
|
|
useEffect(() => {
|
|
if (scene && !isInitialized) {
|
|
getUrlSyncManager().initSync(scene);
|
|
setInitialized(true);
|
|
}
|
|
}, [isInitialized, scene]);
|
|
|
|
if (!scene) {
|
|
return <h2>Scene not found</h2>;
|
|
}
|
|
|
|
if (!isInitialized) {
|
|
return null;
|
|
}
|
|
|
|
return <scene.Component model={scene} />;
|
|
};
|
|
|
|
export default ScenePage;
|