-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathHome.tsx
55 lines (50 loc) · 1.74 KB
/
Home.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React, { useMemo } from 'react';
import { SceneApp, SceneAppPage } from '@grafana/scenes';
import { getBasicScene } from './scenes';
import { prefixRoute } from '../../utils/utils.routing';
import { DATASOURCE_REF, ROUTES } from '../../constants';
import { testIds } from '../../components/testIds';
import { config } from '@grafana/runtime';
import { Alert, useStyles2 } from '@grafana/ui';
import { GrafanaTheme2 } from '@grafana/data';
import { css } from '@emotion/css';
const getScene = () => {
return new SceneApp({
pages: [
new SceneAppPage({
title: 'Home page',
subTitle:
'This scene showcases a basic scene functionality, including query runner, variable and a custom scene object.',
url: prefixRoute(ROUTES.Home),
getScene: () => {
return getBasicScene();
},
}),
],
});
};
export const HomePage = () => {
const s = useStyles2(getStyles);
const scene = useMemo(() => getScene(), []);
return (
<div className={s.container} data-testid={testIds.pageHome.container}>
{!config.datasources[DATASOURCE_REF.uid] && (
<Alert title={`Missing ${DATASOURCE_REF.uid} datasource`}>
These demos depend on <b>testdata</b> datasource: <code>{JSON.stringify(DATASOURCE_REF)}</code>. See{' '}
<a href="https://github.com/grafana/grafana/tree/main/devenv#set-up-your-development-environment">
https://github.com/grafana/grafana/tree/main/devenv#set-up-your-development-environment
</a>{' '}
for more details.
</Alert>
)}
<scene.Component model={scene} />
</div>
);
};
const getStyles = (theme: GrafanaTheme2) => ({
container: css`
display: flex;
flex-grow: 1;
height: 100%;
`,
});