mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
* Basics for rendering scenes as an embedded page * Render submenu in embedded scene * EmbeddedScene alternative for embedding within Grafana page
32 lines
793 B
TypeScript
32 lines
793 B
TypeScript
// Libraries
|
|
import React, { FC } from 'react';
|
|
|
|
import { NavModelItem } from '@grafana/data';
|
|
import { Page } from 'app/core/components/Page/Page';
|
|
import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
|
|
|
|
import { getSceneByTitle } from './scenes';
|
|
|
|
export interface Props extends GrafanaRouteComponentProps<{ name: string }> {}
|
|
|
|
export const SceneEmbeddedPage: FC<Props> = (props) => {
|
|
const scene = getSceneByTitle(props.match.params.name, false);
|
|
|
|
if (!scene) {
|
|
return <h2>Scene not found</h2>;
|
|
}
|
|
|
|
const pageNav: NavModelItem = {
|
|
text: scene.state.title,
|
|
};
|
|
return (
|
|
<Page navId="scenes" pageNav={pageNav}>
|
|
<Page.Contents>
|
|
<scene.Component model={scene} />
|
|
</Page.Contents>
|
|
</Page>
|
|
);
|
|
};
|
|
|
|
export default SceneEmbeddedPage;
|