@grafana/scenes 0.7.0 → 0.7.1
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 +18 -0
- package/dist/esm/components/SceneApp/SceneAppPageView.js +1 -1
- package/dist/esm/components/SceneApp/SceneAppPageView.js.map +1 -1
- package/dist/esm/components/SceneReactObject.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
# v0.7.1 (Wed May 17 2023)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- SceneReactObject: Fix type issue [#191](https://github.com/grafana/scenes/pull/191) ([@torkelo](https://github.com/torkelo))
|
|
6
|
+
- SceneAppPage: Fixes issue with duplicate breadcrumbs [#175](https://github.com/grafana/scenes/pull/175) ([@torkelo](https://github.com/torkelo))
|
|
7
|
+
|
|
8
|
+
#### 📝 Documentation
|
|
9
|
+
|
|
10
|
+
- Docs: SceneApp [#172](https://github.com/grafana/scenes/pull/172) ([@dprokop](https://github.com/dprokop))
|
|
11
|
+
|
|
12
|
+
#### Authors: 2
|
|
13
|
+
|
|
14
|
+
- Dominik Prokop ([@dprokop](https://github.com/dprokop))
|
|
15
|
+
- Torkel Ödegaard ([@torkelo](https://github.com/torkelo))
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
1
19
|
# v0.7.0 (Mon May 08 2023)
|
|
2
20
|
|
|
3
21
|
### Release Notes
|
|
@@ -26,7 +26,7 @@ function SceneAppPageView({ page, routeProps }) {
|
|
|
26
26
|
url: getLinkUrlWithAppUrlState(containerState.url, params, containerState.preserveUrlKeys),
|
|
27
27
|
hideFromBreadcrumbs: containerState.hideFromBreadcrumbs,
|
|
28
28
|
parentItem: getParentBreadcrumbs(
|
|
29
|
-
containerState.getParentPage ? containerState.getParentPage() :
|
|
29
|
+
containerState.getParentPage ? containerState.getParentPage() : containerPage.parent,
|
|
30
30
|
params
|
|
31
31
|
)
|
|
32
32
|
};
|
|
@@ -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 { getLinkUrlWithAppUrlState, 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 subTitle: containerState.subTitle,\n img: containerState.titleImg,\n icon: containerState.titleIcon,\n url: getLinkUrlWithAppUrlState(containerState.url, params, containerState.preserveUrlKeys),\n hideFromBreadcrumbs: containerState.hideFromBreadcrumbs,\n parentItem: getParentBreadcrumbs(\n containerState.getParentPage ? containerState.getParentPage() :
|
|
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 { getLinkUrlWithAppUrlState, 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 subTitle: containerState.subTitle,\n img: containerState.titleImg,\n icon: containerState.titleIcon,\n url: getLinkUrlWithAppUrlState(containerState.url, params, 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: getLinkUrlWithAppUrlState(tab.state.url, params, 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 pageNav={pageNav} actions={pageActions} renderTitle={containerState.renderTitle}>\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: getLinkUrlWithAppUrlState(parent.state.url, params, 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,EAAA,MAAM,SAAS,iBAAkB,EAAA,CAAA;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,IA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@
|
|
|
1
|
-
{"version":3,"file":"SceneReactObject.js","sources":["../../../src/components/SceneReactObject.tsx"],"sourcesContent":["import React from 'react';\n\nimport { SceneObjectBase } from '../core/SceneObjectBase';\nimport { SceneComponentProps, SceneObjectState } from '../core/types';\n\nexport interface SceneReactObjectState<TProps = {}> extends SceneObjectState {\n /**\n * React component to render\n */\n component?: React.ComponentType<TProps>;\n /**\n * Props to pass to the component\n */\n props?: TProps;\n /**\n * Alternative to component and props is just to pass a React node\n */\n reactNode?: React.ReactNode;\n}\n\n/**\n * A utility object that can be used to render any React component or ReactNode\n */\nexport class SceneReactObject extends SceneObjectBase<SceneReactObjectState
|
|
1
|
+
{"version":3,"file":"SceneReactObject.js","sources":["../../../src/components/SceneReactObject.tsx"],"sourcesContent":["import React from 'react';\n\nimport { SceneObjectBase } from '../core/SceneObjectBase';\nimport { SceneComponentProps, SceneObjectState } from '../core/types';\n\nexport interface SceneReactObjectState<TProps = {}> extends SceneObjectState {\n /**\n * React component to render\n */\n component?: React.ComponentType<TProps>;\n /**\n * Props to pass to the component\n */\n props?: TProps;\n /**\n * Alternative to component and props is just to pass a React node\n */\n reactNode?: React.ReactNode;\n}\n\n/**\n * A utility object that can be used to render any React component or ReactNode\n */\nexport class SceneReactObject<TProps = {}> extends SceneObjectBase<SceneReactObjectState<TProps>> {\n public static Component = ({ model }: SceneComponentProps<SceneReactObject>) => {\n const { component: Component, props, reactNode } = model.useState();\n\n if (Component) {\n return <Component {...props} />;\n }\n\n if (reactNode) {\n return reactNode;\n }\n\n return null;\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAuBO,MAAM,yBAAsC,eAA+C,CAAA;AAclG,CAAA;AAda,gBAAA,CACG,SAAY,GAAA,CAAC,EAAE,KAAA,EAAmD,KAAA;AAC9E,EAAA,MAAM,EAAE,SAAW,EAAA,SAAA,EAAW,OAAO,SAAU,EAAA,GAAI,MAAM,QAAS,EAAA,CAAA;AAElE,EAAA,IAAI,SAAW,EAAA;AACb,IAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,8BAAc,KAAO,CAAA,CAAA,CAAA;AAAA,GAC/B;AAEA,EAAA,IAAI,SAAW,EAAA;AACb,IAAO,OAAA,SAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA,IAAA,CAAA;AACT,CAAA;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1078,7 +1078,7 @@ interface SceneAppPageState extends SceneObjectState {
|
|
|
1078
1078
|
titleIcon?: IconName$1;
|
|
1079
1079
|
url: string;
|
|
1080
1080
|
routePath?: string;
|
|
1081
|
-
/**
|
|
1081
|
+
/** Array of scene object to be rendered at the top right of the page, inline with the page title */
|
|
1082
1082
|
controls?: SceneObject[];
|
|
1083
1083
|
hideFromBreadcrumbs?: boolean;
|
|
1084
1084
|
tabs?: SceneAppPageLike[];
|
|
@@ -1151,7 +1151,7 @@ interface SceneReactObjectState<TProps = {}> extends SceneObjectState {
|
|
|
1151
1151
|
/**
|
|
1152
1152
|
* A utility object that can be used to render any React component or ReactNode
|
|
1153
1153
|
*/
|
|
1154
|
-
declare class SceneReactObject extends SceneObjectBase<SceneReactObjectState
|
|
1154
|
+
declare class SceneReactObject<TProps = {}> extends SceneObjectBase<SceneReactObjectState<TProps>> {
|
|
1155
1155
|
static Component: ({ model }: SceneComponentProps<SceneReactObject>) => {} | null;
|
|
1156
1156
|
}
|
|
1157
1157
|
|
package/dist/index.js
CHANGED
|
@@ -4924,7 +4924,7 @@ function SceneAppPageView({ page, routeProps }) {
|
|
|
4924
4924
|
url: getLinkUrlWithAppUrlState(containerState.url, params, containerState.preserveUrlKeys),
|
|
4925
4925
|
hideFromBreadcrumbs: containerState.hideFromBreadcrumbs,
|
|
4926
4926
|
parentItem: getParentBreadcrumbs(
|
|
4927
|
-
containerState.getParentPage ? containerState.getParentPage() :
|
|
4927
|
+
containerState.getParentPage ? containerState.getParentPage() : containerPage.parent,
|
|
4928
4928
|
params
|
|
4929
4929
|
)
|
|
4930
4930
|
};
|