-
Notifications
You must be signed in to change notification settings - Fork 1
/
WithTabs.tsx
45 lines (40 loc) · 1.29 KB
/
WithTabs.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
import React, { useMemo } from 'react';
import { SceneApp, SceneAppPage } from '@grafana/scenes';
import { ROUTES } from '../../constants';
import { prefixRoute } from '../../utils/utils.routing';
import { getBasicScene } from '../Home/scenes';
const getTab1Scene = () => {
return getBasicScene(false, '__server_names');
};
const getTab2Scene = () => {
return getBasicScene(false, '__house_locations');
};
const getScene = () =>
new SceneApp({
pages: [
new SceneAppPage({
title: 'Page with tabs',
subTitle: 'This scene showcases a basic tabs functionality.',
// Important: Mind the page route is ambiguous for the tabs to work properly
url: prefixRoute(`${ROUTES.WithTabs}`),
hideFromBreadcrumbs: true,
getScene: getTab1Scene,
tabs: [
new SceneAppPage({
title: 'Server names',
url: prefixRoute(`${ROUTES.WithTabs}`),
getScene: getTab1Scene,
}),
new SceneAppPage({
title: 'House locations',
url: prefixRoute(`${ROUTES.WithTabs}/tab-two`),
getScene: getTab2Scene,
}),
],
}),
],
});
export const PageWithTabs = () => {
const scene = useMemo(() => getScene(), []);
return <scene.Component model={scene} />;
};