@grafana/scenes 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# v0.12.0 (Thu May 25 2023)
|
|
2
|
+
|
|
3
|
+
#### 🚀 Enhancement
|
|
4
|
+
|
|
5
|
+
- SceneAppPage: Support react elements in subtitle [#196](https://github.com/grafana/scenes/pull/196) ([@torkelo](https://github.com/torkelo))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Torkel Ödegaard ([@torkelo](https://github.com/torkelo))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
1
13
|
# v0.11.0 (Tue May 23 2023)
|
|
2
14
|
|
|
3
15
|
#### 🚀 Enhancement
|
|
@@ -20,7 +20,6 @@ function SceneAppPageView({ page, routeProps }) {
|
|
|
20
20
|
}
|
|
21
21
|
const pageNav = {
|
|
22
22
|
text: containerState.title,
|
|
23
|
-
subTitle: containerState.subTitle,
|
|
24
23
|
img: containerState.titleImg,
|
|
25
24
|
icon: containerState.titleIcon,
|
|
26
25
|
url: getUrlWithAppState(containerState.url, containerState.preserveUrlKeys),
|
|
@@ -48,7 +47,8 @@ function SceneAppPageView({ page, routeProps }) {
|
|
|
48
47
|
return /* @__PURE__ */ React.createElement(PluginPage, {
|
|
49
48
|
pageNav,
|
|
50
49
|
actions: pageActions,
|
|
51
|
-
renderTitle: containerState.renderTitle
|
|
50
|
+
renderTitle: containerState.renderTitle,
|
|
51
|
+
subTitle: containerState.subTitle
|
|
52
52
|
}, /* @__PURE__ */ React.createElement(scene.Component, {
|
|
53
53
|
model: scene
|
|
54
54
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneAppPageView.js","sources":["../../../../src/components/SceneApp/SceneAppPageView.tsx"],"sourcesContent":["import { NavModelItem, UrlQueryMap } from '@grafana/data';\nimport { PluginPage } from '@grafana/runtime';\nimport React, { useLayoutEffect, useState } from 'react';\n\nimport { RouteComponentProps } from 'react-router-dom';\nimport { SceneObject } from '../../core/types';\nimport { SceneAppPage } from './SceneAppPage';\nimport { SceneAppDrilldownView, SceneAppPageLike } from './types';\nimport { getUrlWithAppState, renderSceneComponentWithRouteProps, useAppQueryParams } from './utils';\n\nexport interface Props {\n page: SceneAppPageLike;\n // activeTab?: SceneAppPageLike;\n routeProps: RouteComponentProps;\n}\n\nexport function SceneAppPageView({ page, routeProps }: Props) {\n const containerPage = getParentPageIfTab(page);\n const containerState = containerPage.useState();\n const params = useAppQueryParams();\n const scene = page.getScene(routeProps.match);\n const [initialized, setInitialized] = useState(false);\n\n useLayoutEffect(() => {\n // Before rendering scene components, we are making sure the URL sync is enabled for.\n if (!initialized) {\n containerPage.initializeScene(scene);\n setInitialized(true);\n }\n }, [initialized, scene, containerPage]);\n\n if (!initialized) {\n return null;\n }\n\n const pageNav: NavModelItem = {\n text: containerState.title,\n
|
|
1
|
+
{"version":3,"file":"SceneAppPageView.js","sources":["../../../../src/components/SceneApp/SceneAppPageView.tsx"],"sourcesContent":["import { NavModelItem, UrlQueryMap } from '@grafana/data';\nimport { PluginPage } from '@grafana/runtime';\nimport React, { useLayoutEffect, useState } from 'react';\n\nimport { RouteComponentProps } from 'react-router-dom';\nimport { SceneObject } from '../../core/types';\nimport { SceneAppPage } from './SceneAppPage';\nimport { SceneAppDrilldownView, SceneAppPageLike } from './types';\nimport { getUrlWithAppState, renderSceneComponentWithRouteProps, useAppQueryParams } from './utils';\n\nexport interface Props {\n page: SceneAppPageLike;\n // activeTab?: SceneAppPageLike;\n routeProps: RouteComponentProps;\n}\n\nexport function SceneAppPageView({ page, routeProps }: Props) {\n const containerPage = getParentPageIfTab(page);\n const containerState = containerPage.useState();\n const params = useAppQueryParams();\n const scene = page.getScene(routeProps.match);\n const [initialized, setInitialized] = useState(false);\n\n useLayoutEffect(() => {\n // Before rendering scene components, we are making sure the URL sync is enabled for.\n if (!initialized) {\n containerPage.initializeScene(scene);\n setInitialized(true);\n }\n }, [initialized, scene, containerPage]);\n\n if (!initialized) {\n return null;\n }\n\n const pageNav: NavModelItem = {\n text: containerState.title,\n img: containerState.titleImg,\n icon: containerState.titleIcon,\n url: getUrlWithAppState(containerState.url, containerState.preserveUrlKeys),\n hideFromBreadcrumbs: containerState.hideFromBreadcrumbs,\n parentItem: getParentBreadcrumbs(\n containerState.getParentPage ? containerState.getParentPage() : containerPage.parent,\n params\n ),\n };\n\n if (containerState.tabs) {\n pageNav.children = containerState.tabs.map((tab) => {\n return {\n text: tab.state.title,\n active: page === tab,\n url: getUrlWithAppState(tab.state.url, tab.state.preserveUrlKeys),\n parentItem: pageNav,\n };\n });\n }\n\n let pageActions: React.ReactNode = undefined;\n if (containerState.controls) {\n pageActions = containerState.controls.map((control) => (\n <control.Component model={control} key={control.state.key} />\n ));\n }\n\n return (\n <PluginPage\n pageNav={pageNav}\n actions={pageActions}\n renderTitle={containerState.renderTitle}\n subTitle={containerState.subTitle}\n >\n <scene.Component model={scene} />\n </PluginPage>\n );\n}\n\n/**\n * For pages that are \"tabs\" this will return the parent page\n */\nfunction getParentPageIfTab(page: SceneAppPageLike) {\n if (page.parent instanceof SceneAppPage) {\n return page.parent;\n }\n\n return page;\n}\n\nfunction getParentBreadcrumbs(parent: SceneObject | undefined, params: UrlQueryMap): NavModelItem | undefined {\n if (parent instanceof SceneAppPage) {\n return {\n text: parent.state.title,\n url: getUrlWithAppState(parent.state.url, parent.state.preserveUrlKeys),\n hideFromBreadcrumbs: parent.state.hideFromBreadcrumbs,\n parentItem: getParentBreadcrumbs(\n parent.state.getParentPage ? parent.state.getParentPage() : parent.parent,\n params\n ),\n };\n }\n\n return undefined;\n}\n\nexport interface SceneAppDrilldownViewRenderProps {\n drilldown: SceneAppDrilldownView;\n parent: SceneAppPageLike;\n routeProps: RouteComponentProps;\n}\n\nexport function SceneAppDrilldownViewRender({ drilldown, parent, routeProps }: SceneAppDrilldownViewRenderProps) {\n return renderSceneComponentWithRouteProps(parent.getDrilldownPage(drilldown, routeProps.match), routeProps);\n}\n"],"names":[],"mappings":";;;;;AAgBO,SAAS,gBAAiB,CAAA,EAAE,IAAM,EAAA,UAAA,EAAqB,EAAA;AAC5D,EAAM,MAAA,aAAA,GAAgB,mBAAmB,IAAI,CAAA,CAAA;AAC7C,EAAM,MAAA,cAAA,GAAiB,cAAc,QAAS,EAAA,CAAA;AAC9C,EAAe,iBAAkB,GAAA;AACjC,EAAA,MAAM,KAAQ,GAAA,IAAA,CAAK,QAAS,CAAA,UAAA,CAAW,KAAK,CAAA,CAAA;AAC5C,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AAEpD,EAAA,eAAA,CAAgB,MAAM;AAEpB,IAAA,IAAI,CAAC,WAAa,EAAA;AAChB,MAAA,aAAA,CAAc,gBAAgB,KAAK,CAAA,CAAA;AACnC,MAAA,cAAA,CAAe,IAAI,CAAA,CAAA;AAAA,KACrB;AAAA,GACC,EAAA,CAAC,WAAa,EAAA,KAAA,EAAO,aAAa,CAAC,CAAA,CAAA;AAEtC,EAAA,IAAI,CAAC,WAAa,EAAA;AAChB,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,MAAM,OAAwB,GAAA;AAAA,IAC5B,MAAM,cAAe,CAAA,KAAA;AAAA,IACrB,KAAK,cAAe,CAAA,QAAA;AAAA,IACpB,MAAM,cAAe,CAAA,SAAA;AAAA,IACrB,GAAK,EAAA,kBAAA,CAAmB,cAAe,CAAA,GAAA,EAAK,eAAe,eAAe,CAAA;AAAA,IAC1E,qBAAqB,cAAe,CAAA,mBAAA;AAAA,IACpC,UAAY,EAAA,oBAAA;AAAA,MACV,cAAe,CAAA,aAAA,GAAgB,cAAe,CAAA,aAAA,KAAkB,aAAc,CAAA,MAEhF,CAAA;AAAA,GACF,CAAA;AAEA,EAAA,IAAI,eAAe,I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,EAAA;AAC5G,EAAA,IAAI,kBAAkB,YAAc,EAAA;AAClC,IAAO,OAAA;AAAA,MACL,IAAA,EAAM,OAAO,KAAM,CAAA,KAAA;AAAA,MACnB,KAAK,kBAAmB,CAAA,MAAA,CAAO,MAAM,GAAK,EAAA,MAAA,CAAO,MAAM,eAAe,CAAA;AAAA,MACtE,mBAAA,EAAqB,OAAO,KAAM,CAAA,mBAAA;AAAA,MAClC,UAAY,EAAA,oBAAA;AAAA,QACV,OAAO,KAAM,CAAA,aAAA,GAAgB,OAAO,KAAM,CAAA,aAAA,KAAkB,MAAO,CAAA,MAErE,CAAA;AAAA,KACF,CAAA;AAAA,GACF;AAEA,EAAO,OAAA,KAAA,CAAA,CAAA;AACT,CAAA;AAQO,SAAS,2BAA4B,CAAA,EAAE,SAAW,EAAA,MAAA,EAAQ,YAAgD,EAAA;AAC/G,EAAA,OAAO,mCAAmC,MAAO,CAAA,gBAAA,CAAiB,WAAW,UAAW,CAAA,KAAK,GAAG,UAAU,CAAA,CAAA;AAC5G;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1080,7 +1080,7 @@ interface SceneAppPageState extends SceneObjectState {
|
|
|
1080
1080
|
/** Page title */
|
|
1081
1081
|
title: string;
|
|
1082
1082
|
/** Page subTitle */
|
|
1083
|
-
subTitle?: string;
|
|
1083
|
+
subTitle?: string | React.ReactNode;
|
|
1084
1084
|
/**
|
|
1085
1085
|
* Customize title rendering.
|
|
1086
1086
|
* Please return an unstyled h1 tag here + any additional elements you need.
|
package/dist/index.js
CHANGED
|
@@ -5015,7 +5015,6 @@ function SceneAppPageView({ page, routeProps }) {
|
|
|
5015
5015
|
}
|
|
5016
5016
|
const pageNav = {
|
|
5017
5017
|
text: containerState.title,
|
|
5018
|
-
subTitle: containerState.subTitle,
|
|
5019
5018
|
img: containerState.titleImg,
|
|
5020
5019
|
icon: containerState.titleIcon,
|
|
5021
5020
|
url: getUrlWithAppState(containerState.url, containerState.preserveUrlKeys),
|
|
@@ -5043,7 +5042,8 @@ function SceneAppPageView({ page, routeProps }) {
|
|
|
5043
5042
|
return /* @__PURE__ */ React__default["default"].createElement(runtime.PluginPage, {
|
|
5044
5043
|
pageNav,
|
|
5045
5044
|
actions: pageActions,
|
|
5046
|
-
renderTitle: containerState.renderTitle
|
|
5045
|
+
renderTitle: containerState.renderTitle,
|
|
5046
|
+
subTitle: containerState.subTitle
|
|
5047
5047
|
}, /* @__PURE__ */ React__default["default"].createElement(scene.Component, {
|
|
5048
5048
|
model: scene
|
|
5049
5049
|
}));
|