@grafana/scenes 6.30.0--canary.1215.16931241718.0 → 6.30.0--canary.1215.16939805262.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/dist/esm/components/VizPanel/VizPanelRenderer.js +5 -5
- package/dist/esm/components/VizPanel/VizPanelRenderer.js.map +1 -1
- package/dist/esm/components/layout/grid/SceneGridLayout.js +8 -7
- package/dist/esm/components/layout/grid/SceneGridLayout.js.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/utils.js +11 -1
- package/dist/esm/utils/utils.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +24 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -220,15 +220,15 @@ function getDragHooks(panel) {
|
|
|
220
220
|
return (_b = (_a = parentLayout == null ? void 0 : parentLayout.getDragHooks) == null ? void 0 : _a.call(parentLayout)) != null ? _b : {};
|
|
221
221
|
}
|
|
222
222
|
function itemDraggingDisabled(item, layout) {
|
|
223
|
-
let
|
|
224
|
-
while (
|
|
225
|
-
if ("isDraggable" in
|
|
223
|
+
let obj = item;
|
|
224
|
+
while (obj && obj !== layout) {
|
|
225
|
+
if ("isDraggable" in obj.state && obj.state.isDraggable === false) {
|
|
226
226
|
return true;
|
|
227
227
|
}
|
|
228
|
-
if ("repeatSourceKey" in
|
|
228
|
+
if ("repeatSourceKey" in obj.state && obj.state.repeatSourceKey) {
|
|
229
229
|
return true;
|
|
230
230
|
}
|
|
231
|
-
|
|
231
|
+
obj = obj.parent;
|
|
232
232
|
}
|
|
233
233
|
return false;
|
|
234
234
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VizPanelRenderer.js","sources":["../../../../src/components/VizPanel/VizPanelRenderer.tsx"],"sourcesContent":["import { Trans } from '@grafana/i18n';\nimport React, { RefCallback, useCallback, useMemo } from 'react';\nimport { useMeasure } from 'react-use';\n\n// @ts-ignore\nimport { AlertState, GrafanaTheme2, PanelData, PluginContextProvider, SetPanelAttentionEvent } from '@grafana/data';\n\nimport { getAppEvents } from '@grafana/runtime';\nimport { PanelChrome, ErrorBoundaryAlert, PanelContextProvider, Tooltip, useStyles2, Icon } from '@grafana/ui';\n\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { isSceneObject, SceneComponentProps, SceneLayout, SceneObject } from '../../core/types';\n\nimport { VizPanel } from './VizPanel';\nimport { css, cx } from '@emotion/css';\nimport { debounce } from 'lodash';\nimport { VizPanelSeriesLimit } from './VizPanelSeriesLimit';\n\nexport function VizPanelRenderer({ model }: SceneComponentProps<VizPanel>) {\n const {\n title,\n options,\n fieldConfig,\n _pluginLoadError,\n displayMode,\n hoverHeader,\n showMenuAlways,\n hoverHeaderOffset,\n menu,\n headerActions,\n titleItems,\n seriesLimit,\n seriesLimitShowAll,\n description,\n collapsible,\n collapsed,\n _renderCounter = 0,\n } = model.useState();\n const [ref, { width, height }] = useMeasure();\n const appEvents = useMemo(() => getAppEvents(), []);\n\n const setPanelAttention = useCallback(() => {\n if (model.state.key) {\n appEvents.publish(new SetPanelAttentionEvent({ panelId: model.state.key }));\n }\n }, [model.state.key, appEvents]);\n const debouncedMouseMove = useMemo(\n () => debounce(setPanelAttention, 100, { leading: true, trailing: false }),\n [setPanelAttention]\n );\n\n const plugin = model.getPlugin();\n\n const { dragClass, dragClassCancel } = getDragClasses(model);\n const dragHooks = getDragHooks(model);\n const dataObject = sceneGraph.getData(model);\n\n const rawData = dataObject.useState();\n const dataWithSeriesLimit = useDataWithSeriesLimit(rawData.data, seriesLimit, seriesLimitShowAll);\n const dataWithFieldConfig = model.applyFieldConfig(dataWithSeriesLimit);\n const sceneTimeRange = sceneGraph.getTimeRange(model);\n const timeZone = sceneTimeRange.getTimeZone();\n const timeRange = model.getTimeRange(dataWithFieldConfig);\n\n // Interpolate title\n const titleInterpolated = model.interpolate(title, undefined, 'text');\n\n const alertStateStyles = useStyles2(getAlertStateStyles);\n\n if (!plugin) {\n return (\n <div>\n <Trans i18nKey=\"grafana-scenes.components.viz-panel-renderer.loading-plugin-panel\">\n Loading plugin panel...\n </Trans>\n </div>\n );\n }\n\n if (!plugin.panel) {\n return (\n <div>\n <Trans i18nKey=\"grafana-scenes.components.viz-panel-renderer.panel-plugin-has-no-panel-component\">\n Panel plugin has no panel component\n </Trans>\n </div>\n );\n }\n\n const PanelComponent = plugin.panel;\n\n // If we have a query runner on our level inform it of the container width (used to set auto max data points)\n if (dataObject && dataObject.setContainerWidth) {\n dataObject.setContainerWidth(Math.round(width));\n }\n\n let titleItemsElement: React.ReactNode[] = [];\n\n if (titleItems) {\n if (Array.isArray(titleItems)) {\n titleItemsElement = titleItemsElement.concat(\n titleItems.map((titleItem) => {\n return <titleItem.Component model={titleItem} key={`${titleItem.state.key}`} />;\n })\n );\n } else if (isSceneObject(titleItems)) {\n titleItemsElement.push(<titleItems.Component model={titleItems} />);\n } else {\n titleItemsElement.push(titleItems);\n }\n }\n\n if (seriesLimit) {\n titleItemsElement.push(\n <VizPanelSeriesLimit\n key=\"series-limit\"\n data={rawData.data}\n seriesLimit={seriesLimit}\n showAll={seriesLimitShowAll}\n onShowAllSeries={() => model.setState({ seriesLimitShowAll: !seriesLimitShowAll })}\n />\n );\n }\n\n // If we have local time range show that in panel header\n if (model.state.$timeRange) {\n titleItemsElement.push(<model.state.$timeRange.Component model={model.state.$timeRange} key={model.state.key} />);\n }\n\n if (dataWithFieldConfig.alertState) {\n titleItemsElement.push(\n <Tooltip content={dataWithFieldConfig.alertState.state ?? 'unknown'} key={`alert-states-icon-${model.state.key}`}>\n <PanelChrome.TitleItem\n className={cx({\n [alertStateStyles.ok]: dataWithFieldConfig.alertState.state === AlertState.OK,\n [alertStateStyles.pending]: dataWithFieldConfig.alertState.state === AlertState.Pending,\n [alertStateStyles.alerting]: dataWithFieldConfig.alertState.state === AlertState.Alerting,\n })}\n >\n <Icon\n name={dataWithFieldConfig.alertState.state === 'alerting' ? 'heart-break' : 'heart'}\n className=\"panel-alert-icon\"\n size=\"md\"\n />\n </PanelChrome.TitleItem>\n </Tooltip>\n );\n }\n\n let panelMenu;\n if (menu) {\n panelMenu = <menu.Component model={menu} />;\n }\n\n let actionsElement: React.ReactNode | undefined;\n\n if (headerActions) {\n if (Array.isArray(headerActions)) {\n actionsElement = (\n <>\n {headerActions.map((action) => {\n return <action.Component model={action} key={`${action.state.key}`} />;\n })}\n </>\n );\n } else if (isSceneObject(headerActions)) {\n actionsElement = <headerActions.Component model={headerActions} />;\n } else {\n actionsElement = headerActions;\n }\n }\n\n // Data is always returned. For non-data panels, empty PanelData is returned.\n const data = dataWithFieldConfig!;\n\n const isReadyToRender = dataObject.isDataReadyToDisplay ? dataObject.isDataReadyToDisplay() : true;\n\n const context = model.getPanelContext();\n const panelId = model.getLegacyPanelId();\n\n return (\n <div className={relativeWrapper}>\n <div ref={ref as RefCallback<HTMLDivElement>} className={absoluteWrapper} data-viz-panel-key={model.state.key}>\n {width > 0 && height > 0 && (\n // @ts-expect-error showMenuAlways remove when updating to @grafana/ui@12 fixed in https://github.com/grafana/grafana/pull/103553\n <PanelChrome\n title={titleInterpolated}\n description={description?.trim() ? model.getDescription : undefined}\n loadingState={data.state}\n statusMessage={getChromeStatusMessage(data, _pluginLoadError)}\n statusMessageOnClick={model.onStatusMessageClick}\n width={width}\n height={height}\n selectionId={model.state.key}\n displayMode={displayMode}\n titleItems={titleItemsElement}\n dragClass={dragClass}\n actions={actionsElement}\n dragClassCancel={dragClassCancel}\n padding={plugin.noPadding ? 'none' : 'md'}\n menu={panelMenu}\n onCancelQuery={model.onCancelQuery}\n onFocus={setPanelAttention}\n onMouseEnter={setPanelAttention}\n onMouseMove={debouncedMouseMove}\n onDragStart={(e: React.PointerEvent) => {\n dragHooks.onDragStart?.(e, model);\n }}\n showMenuAlways={showMenuAlways}\n {...(collapsible\n ? {\n collapsible: Boolean(collapsible),\n collapsed,\n onToggleCollapse: model.onToggleCollapse,\n }\n : { hoverHeader, hoverHeaderOffset })}\n >\n {(innerWidth, innerHeight) => (\n <>\n <ErrorBoundaryAlert dependencies={[plugin, data]}>\n <PluginContextProvider meta={plugin.meta}>\n <PanelContextProvider value={context}>\n {isReadyToRender && (\n <PanelComponent\n id={panelId}\n data={data}\n title={title}\n timeRange={timeRange}\n timeZone={timeZone}\n options={options}\n fieldConfig={fieldConfig}\n transparent={displayMode === 'transparent'}\n width={innerWidth}\n height={innerHeight}\n renderCounter={_renderCounter}\n replaceVariables={model.interpolate}\n onOptionsChange={model.onOptionsChange}\n onFieldConfigChange={model.onFieldConfigChange}\n onChangeTimeRange={model.onTimeRangeChange}\n eventBus={context.eventBus}\n />\n )}\n </PanelContextProvider>\n </PluginContextProvider>\n </ErrorBoundaryAlert>\n </>\n )}\n </PanelChrome>\n )}\n </div>\n </div>\n );\n}\n\nfunction useDataWithSeriesLimit(data: PanelData | undefined, seriesLimit?: number, showAllSeries?: boolean) {\n return useMemo(() => {\n if (!data?.series || !seriesLimit || showAllSeries) {\n return data;\n }\n\n return {\n ...data,\n series: data.series.slice(0, seriesLimit),\n };\n }, [data, seriesLimit, showAllSeries]);\n}\n\nfunction getDragClasses(panel: VizPanel) {\n const parentLayout = sceneGraph.getLayout(panel);\n const isDraggable = parentLayout?.isDraggable();\n\n if (!parentLayout || !isDraggable || itemDraggingDisabled(panel, parentLayout)) {\n return { dragClass: '', dragClassCancel: '' };\n }\n\n return { dragClass: parentLayout.getDragClass?.(), dragClassCancel: parentLayout?.getDragClassCancel?.() };\n}\n\nfunction getDragHooks(panel: VizPanel) {\n const parentLayout = sceneGraph.getLayout(panel);\n return parentLayout?.getDragHooks?.() ?? {};\n}\n\n/**\n * Walks up the parent chain until it hits the layout object, trying to find the closest SceneGridItemLike ancestor.\n * It is not always the direct parent, because the VizPanel can be wrapped in other objects.\n */\nfunction itemDraggingDisabled(item: SceneObject, layout: SceneLayout) {\n let ancestor = item.parent;\n\n while (ancestor && ancestor !== layout) {\n if ('isDraggable' in ancestor.state && ancestor.state.isDraggable === false) {\n return true;\n }\n\n if ('repeatSourceKey' in ancestor.state && ancestor.state.repeatSourceKey) {\n return true;\n }\n\n ancestor = ancestor.parent;\n }\n\n return false;\n}\n\nfunction getChromeStatusMessage(data: PanelData, pluginLoadingError: string | undefined) {\n if (pluginLoadingError) {\n return pluginLoadingError;\n }\n\n let message = data.error ? data.error.message : undefined;\n\n // Handling multiple errors with a single string until we integrate VizPanel with inspector\n if (data.errors) {\n message = data.errors.map((e) => e.message).join(', ');\n }\n return message;\n}\n\nconst relativeWrapper = css({\n position: 'relative',\n width: '100%',\n height: '100%',\n});\n\n/**\n * Sadly this this absolute wrapper is needed for the panel to adopt smaller sizes.\n * The combo of useMeasure and PanelChrome makes the panel take up the width it get's but that makes it impossible to\n * Then adapt to smaller space (say resizing the browser window or undocking menu).\n */\nconst absoluteWrapper = css({\n position: 'absolute',\n width: '100%',\n height: '100%',\n});\n\nconst getAlertStateStyles = (theme: GrafanaTheme2) => {\n return {\n ok: css({\n color: theme.colors.success.text,\n }),\n pending: css({\n color: theme.colors.warning.text,\n }),\n alerting: css({\n color: theme.colors.error.text,\n }),\n };\n};\n"],"names":["_a"],"mappings":";;;;;;;;;;;;AAkBgB,SAAA,gBAAA,CAAiB,EAAE,KAAA,EAAwC,EAAA;AAlB3E,EAAA,IAAA,EAAA;AAmBE,EAAM,MAAA;AAAA,IACJ,KAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,cAAA;AAAA,IACA,iBAAA;AAAA,IACA,IAAA;AAAA,IACA,aAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,IACA,kBAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAiB,GAAA;AAAA,GACnB,GAAI,MAAM,QAAS,EAAA;AACnB,EAAA,MAAM,CAAC,GAAK,EAAA,EAA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AO,EAAA,MAAA;AAAA,EACP,MAAQ,EAAA;AACV,CAAC,CAAA;AAOD,MAAM,kBAAkB,GAAI,CAAA;AAAA,EAC1B,QAAU,EAAA,UAAA;AAAA,EACV,KAAO,EAAA,MAAA;AAAA,EACP,MAAQ,EAAA;AACV,CAAC,CAAA;AAED,MAAM,mBAAA,GAAsB,CAAC,KAAyB,KAAA;AACpD,EAAO,OAAA;AAAA,IACL,IAAI,GAAI,CAAA;AAAA,MACN,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,OAAQ,CAAA;AAAA,KAC7B,CAAA;AAAA,IACD,SAAS,GAAI,CAAA;AAAA,MACX,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,OAAQ,CAAA;AAAA,KAC7B,CAAA;AAAA,IACD,UAAU,GAAI,CAAA;AAAA,MACZ,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,KAAM,CAAA;AAAA,KAC3B;AAAA,GACH;AACF,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"VizPanelRenderer.js","sources":["../../../../src/components/VizPanel/VizPanelRenderer.tsx"],"sourcesContent":["import { Trans } from '@grafana/i18n';\nimport React, { RefCallback, useCallback, useMemo } from 'react';\nimport { useMeasure } from 'react-use';\n\n// @ts-ignore\nimport { AlertState, GrafanaTheme2, PanelData, PluginContextProvider, SetPanelAttentionEvent } from '@grafana/data';\n\nimport { getAppEvents } from '@grafana/runtime';\nimport { PanelChrome, ErrorBoundaryAlert, PanelContextProvider, Tooltip, useStyles2, Icon } from '@grafana/ui';\n\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { isSceneObject, SceneComponentProps, SceneLayout, SceneObject } from '../../core/types';\n\nimport { VizPanel } from './VizPanel';\nimport { css, cx } from '@emotion/css';\nimport { debounce } from 'lodash';\nimport { VizPanelSeriesLimit } from './VizPanelSeriesLimit';\n\nexport function VizPanelRenderer({ model }: SceneComponentProps<VizPanel>) {\n const {\n title,\n options,\n fieldConfig,\n _pluginLoadError,\n displayMode,\n hoverHeader,\n showMenuAlways,\n hoverHeaderOffset,\n menu,\n headerActions,\n titleItems,\n seriesLimit,\n seriesLimitShowAll,\n description,\n collapsible,\n collapsed,\n _renderCounter = 0,\n } = model.useState();\n const [ref, { width, height }] = useMeasure();\n const appEvents = useMemo(() => getAppEvents(), []);\n\n const setPanelAttention = useCallback(() => {\n if (model.state.key) {\n appEvents.publish(new SetPanelAttentionEvent({ panelId: model.state.key }));\n }\n }, [model.state.key, appEvents]);\n const debouncedMouseMove = useMemo(\n () => debounce(setPanelAttention, 100, { leading: true, trailing: false }),\n [setPanelAttention]\n );\n\n const plugin = model.getPlugin();\n\n const { dragClass, dragClassCancel } = getDragClasses(model);\n const dragHooks = getDragHooks(model);\n const dataObject = sceneGraph.getData(model);\n\n const rawData = dataObject.useState();\n const dataWithSeriesLimit = useDataWithSeriesLimit(rawData.data, seriesLimit, seriesLimitShowAll);\n const dataWithFieldConfig = model.applyFieldConfig(dataWithSeriesLimit);\n const sceneTimeRange = sceneGraph.getTimeRange(model);\n const timeZone = sceneTimeRange.getTimeZone();\n const timeRange = model.getTimeRange(dataWithFieldConfig);\n\n // Interpolate title\n const titleInterpolated = model.interpolate(title, undefined, 'text');\n\n const alertStateStyles = useStyles2(getAlertStateStyles);\n\n if (!plugin) {\n return (\n <div>\n <Trans i18nKey=\"grafana-scenes.components.viz-panel-renderer.loading-plugin-panel\">\n Loading plugin panel...\n </Trans>\n </div>\n );\n }\n\n if (!plugin.panel) {\n return (\n <div>\n <Trans i18nKey=\"grafana-scenes.components.viz-panel-renderer.panel-plugin-has-no-panel-component\">\n Panel plugin has no panel component\n </Trans>\n </div>\n );\n }\n\n const PanelComponent = plugin.panel;\n\n // If we have a query runner on our level inform it of the container width (used to set auto max data points)\n if (dataObject && dataObject.setContainerWidth) {\n dataObject.setContainerWidth(Math.round(width));\n }\n\n let titleItemsElement: React.ReactNode[] = [];\n\n if (titleItems) {\n if (Array.isArray(titleItems)) {\n titleItemsElement = titleItemsElement.concat(\n titleItems.map((titleItem) => {\n return <titleItem.Component model={titleItem} key={`${titleItem.state.key}`} />;\n })\n );\n } else if (isSceneObject(titleItems)) {\n titleItemsElement.push(<titleItems.Component model={titleItems} />);\n } else {\n titleItemsElement.push(titleItems);\n }\n }\n\n if (seriesLimit) {\n titleItemsElement.push(\n <VizPanelSeriesLimit\n key=\"series-limit\"\n data={rawData.data}\n seriesLimit={seriesLimit}\n showAll={seriesLimitShowAll}\n onShowAllSeries={() => model.setState({ seriesLimitShowAll: !seriesLimitShowAll })}\n />\n );\n }\n\n // If we have local time range show that in panel header\n if (model.state.$timeRange) {\n titleItemsElement.push(<model.state.$timeRange.Component model={model.state.$timeRange} key={model.state.key} />);\n }\n\n if (dataWithFieldConfig.alertState) {\n titleItemsElement.push(\n <Tooltip content={dataWithFieldConfig.alertState.state ?? 'unknown'} key={`alert-states-icon-${model.state.key}`}>\n <PanelChrome.TitleItem\n className={cx({\n [alertStateStyles.ok]: dataWithFieldConfig.alertState.state === AlertState.OK,\n [alertStateStyles.pending]: dataWithFieldConfig.alertState.state === AlertState.Pending,\n [alertStateStyles.alerting]: dataWithFieldConfig.alertState.state === AlertState.Alerting,\n })}\n >\n <Icon\n name={dataWithFieldConfig.alertState.state === 'alerting' ? 'heart-break' : 'heart'}\n className=\"panel-alert-icon\"\n size=\"md\"\n />\n </PanelChrome.TitleItem>\n </Tooltip>\n );\n }\n\n let panelMenu;\n if (menu) {\n panelMenu = <menu.Component model={menu} />;\n }\n\n let actionsElement: React.ReactNode | undefined;\n\n if (headerActions) {\n if (Array.isArray(headerActions)) {\n actionsElement = (\n <>\n {headerActions.map((action) => {\n return <action.Component model={action} key={`${action.state.key}`} />;\n })}\n </>\n );\n } else if (isSceneObject(headerActions)) {\n actionsElement = <headerActions.Component model={headerActions} />;\n } else {\n actionsElement = headerActions;\n }\n }\n\n // Data is always returned. For non-data panels, empty PanelData is returned.\n const data = dataWithFieldConfig!;\n\n const isReadyToRender = dataObject.isDataReadyToDisplay ? dataObject.isDataReadyToDisplay() : true;\n\n const context = model.getPanelContext();\n const panelId = model.getLegacyPanelId();\n\n return (\n <div className={relativeWrapper}>\n <div ref={ref as RefCallback<HTMLDivElement>} className={absoluteWrapper} data-viz-panel-key={model.state.key}>\n {width > 0 && height > 0 && (\n // @ts-expect-error showMenuAlways remove when updating to @grafana/ui@12 fixed in https://github.com/grafana/grafana/pull/103553\n <PanelChrome\n title={titleInterpolated}\n description={description?.trim() ? model.getDescription : undefined}\n loadingState={data.state}\n statusMessage={getChromeStatusMessage(data, _pluginLoadError)}\n statusMessageOnClick={model.onStatusMessageClick}\n width={width}\n height={height}\n selectionId={model.state.key}\n displayMode={displayMode}\n titleItems={titleItemsElement}\n dragClass={dragClass}\n actions={actionsElement}\n dragClassCancel={dragClassCancel}\n padding={plugin.noPadding ? 'none' : 'md'}\n menu={panelMenu}\n onCancelQuery={model.onCancelQuery}\n onFocus={setPanelAttention}\n onMouseEnter={setPanelAttention}\n onMouseMove={debouncedMouseMove}\n onDragStart={(e: React.PointerEvent) => {\n dragHooks.onDragStart?.(e, model);\n }}\n showMenuAlways={showMenuAlways}\n {...(collapsible\n ? {\n collapsible: Boolean(collapsible),\n collapsed,\n onToggleCollapse: model.onToggleCollapse,\n }\n : { hoverHeader, hoverHeaderOffset })}\n >\n {(innerWidth, innerHeight) => (\n <>\n <ErrorBoundaryAlert dependencies={[plugin, data]}>\n <PluginContextProvider meta={plugin.meta}>\n <PanelContextProvider value={context}>\n {isReadyToRender && (\n <PanelComponent\n id={panelId}\n data={data}\n title={title}\n timeRange={timeRange}\n timeZone={timeZone}\n options={options}\n fieldConfig={fieldConfig}\n transparent={displayMode === 'transparent'}\n width={innerWidth}\n height={innerHeight}\n renderCounter={_renderCounter}\n replaceVariables={model.interpolate}\n onOptionsChange={model.onOptionsChange}\n onFieldConfigChange={model.onFieldConfigChange}\n onChangeTimeRange={model.onTimeRangeChange}\n eventBus={context.eventBus}\n />\n )}\n </PanelContextProvider>\n </PluginContextProvider>\n </ErrorBoundaryAlert>\n </>\n )}\n </PanelChrome>\n )}\n </div>\n </div>\n );\n}\n\nfunction useDataWithSeriesLimit(data: PanelData | undefined, seriesLimit?: number, showAllSeries?: boolean) {\n return useMemo(() => {\n if (!data?.series || !seriesLimit || showAllSeries) {\n return data;\n }\n\n return {\n ...data,\n series: data.series.slice(0, seriesLimit),\n };\n }, [data, seriesLimit, showAllSeries]);\n}\n\nfunction getDragClasses(panel: VizPanel) {\n const parentLayout = sceneGraph.getLayout(panel);\n const isDraggable = parentLayout?.isDraggable();\n\n if (!parentLayout || !isDraggable || itemDraggingDisabled(panel, parentLayout)) {\n return { dragClass: '', dragClassCancel: '' };\n }\n\n return { dragClass: parentLayout.getDragClass?.(), dragClassCancel: parentLayout?.getDragClassCancel?.() };\n}\n\nfunction getDragHooks(panel: VizPanel) {\n const parentLayout = sceneGraph.getLayout(panel);\n return parentLayout?.getDragHooks?.() ?? {};\n}\n\n/**\n * Walks up the parent chain until it hits the layout object, trying to find the closest SceneGridItemLike ancestor.\n * It is not always the direct parent, because the VizPanel can be wrapped in other objects.\n */\nfunction itemDraggingDisabled(item: SceneObject, layout: SceneLayout) {\n let obj: SceneObject | undefined = item;\n\n while (obj && obj !== layout) {\n if ('isDraggable' in obj.state && obj.state.isDraggable === false) {\n return true;\n }\n\n if ('repeatSourceKey' in obj.state && obj.state.repeatSourceKey) {\n return true;\n }\n\n obj = obj.parent;\n }\n\n return false;\n}\n\nfunction getChromeStatusMessage(data: PanelData, pluginLoadingError: string | undefined) {\n if (pluginLoadingError) {\n return pluginLoadingError;\n }\n\n let message = data.error ? data.error.message : undefined;\n\n // Handling multiple errors with a single string until we integrate VizPanel with inspector\n if (data.errors) {\n message = data.errors.map((e) => e.message).join(', ');\n }\n return message;\n}\n\nconst relativeWrapper = css({\n position: 'relative',\n width: '100%',\n height: '100%',\n});\n\n/**\n * Sadly this this absolute wrapper is needed for the panel to adopt smaller sizes.\n * The combo of useMeasure and PanelChrome makes the panel take up the width it get's but that makes it impossible to\n * Then adapt to smaller space (say resizing the browser window or undocking menu).\n */\nconst absoluteWrapper = css({\n position: 'absolute',\n width: '100%',\n height: '100%',\n});\n\nconst getAlertStateStyles = (theme: GrafanaTheme2) => {\n return {\n ok: css({\n color: theme.colors.success.text,\n }),\n pending: css({\n color: theme.colors.warning.text,\n }),\n alerting: css({\n color: theme.colors.error.text,\n }),\n };\n};\n"],"names":["_a"],"mappings":";;;;;;;;;;;;AAkBgB,SAAA,gBAAA,CAAiB,EAAE,KAAA,EAAwC,EAAA;AAlB3E,EAAA,IAAA,EAAA;AAmBE,EAAM,MAAA;AAAA,IACJ,KAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,cAAA;AAAA,IACA,iBAAA;AAAA,IACA,IAAA;AAAA,IACA,aAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,IACA,kBAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAiB,GAAA;AAAA,GACnB,GAAI,MAAM,QAAS,EAAA;AACnB,EAAA,MAAM,CAAC,GAAK,EAAA,EAAE,OAAO,MAAO,EAAC,IAAI,UAAW,EAAA;AAC5C,EAAA,MAAM,YAAY,OAAQ,CAAA,MAAM,YAAa,EAAA,EAAG,EAAE,CAAA;AAElD,EAAM,MAAA,iBAAA,GAAoB,YAAY,MAAM;AAC1C,IAAI,IAAA,KAAA,CAAM,MAAM,GAAK,EAAA;AACnB,MAAU,SAAA,CAAA,OAAA,CAAQ,IAAI,sBAAuB,CAAA,EAAE,SAAS,KAAM,CAAA,KAAA,CAAM,GAAI,EAAC,CAAC,CAAA;AAAA;AAC5E,KACC,CAAC,KAAA,CAAM,KAAM,CAAA,GAAA,EAAK,SAAS,CAAC,CAAA;AAC/B,EAAA,MAAM,kBAAqB,GAAA,OAAA;AAAA,IACzB,MAAM,SAAS,iBAAmB,EAA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AAU,GAAI,CAAA;AAAA,MACZ,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,KAAM,CAAA;AAAA,KAC3B;AAAA,GACH;AACF,CAAA;;;;"}
|
|
@@ -5,6 +5,7 @@ import { SceneGridLayoutRenderer } from './SceneGridLayoutRenderer.js';
|
|
|
5
5
|
import { SceneGridRow } from './SceneGridRow.js';
|
|
6
6
|
import { SceneGridLayoutDragStartEvent } from './types.js';
|
|
7
7
|
import { fitPanelsInHeight } from './utils.js';
|
|
8
|
+
import { isRepeatCloneOrChildOf } from '../../../utils/utils.js';
|
|
8
9
|
|
|
9
10
|
const _SceneGridLayout = class _SceneGridLayout extends SceneObjectBase {
|
|
10
11
|
constructor(state) {
|
|
@@ -231,7 +232,7 @@ const _SceneGridLayout = class _SceneGridLayout extends SceneObjectBase {
|
|
|
231
232
|
}
|
|
232
233
|
return rootChildren;
|
|
233
234
|
}
|
|
234
|
-
toGridCell(child) {
|
|
235
|
+
toGridCell(child, parentKey) {
|
|
235
236
|
var _a, _b;
|
|
236
237
|
const size = child.state;
|
|
237
238
|
let x = (_a = size.x) != null ? _a : 0;
|
|
@@ -243,20 +244,20 @@ const _SceneGridLayout = class _SceneGridLayout extends SceneObjectBase {
|
|
|
243
244
|
if (child instanceof SceneGridRow) {
|
|
244
245
|
isDraggable = child.state.isCollapsed ? true : false;
|
|
245
246
|
isResizable = false;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
}
|
|
248
|
+
if (isRepeatCloneOrChildOf(child)) {
|
|
249
|
+
isDraggable = false;
|
|
250
|
+
isResizable = false;
|
|
250
251
|
}
|
|
251
252
|
return { i: child.state.key, x, y, h, w, isResizable, isDraggable };
|
|
252
253
|
}
|
|
253
254
|
buildGridLayout(width, height) {
|
|
254
255
|
let cells = [];
|
|
255
256
|
for (const child of this.state.children) {
|
|
256
|
-
cells.push(this.toGridCell(child));
|
|
257
|
+
cells.push(this.toGridCell(child, ""));
|
|
257
258
|
if (child instanceof SceneGridRow && !child.state.isCollapsed) {
|
|
258
259
|
for (const rowChild of child.state.children) {
|
|
259
|
-
cells.push(this.toGridCell(rowChild));
|
|
260
|
+
cells.push(this.toGridCell(rowChild, child.state.key));
|
|
260
261
|
}
|
|
261
262
|
}
|
|
262
263
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneGridLayout.js","sources":["../../../../../src/components/layout/grid/SceneGridLayout.tsx"],"sourcesContent":["import { PointerEvent } from 'react';\nimport ReactGridLayout from 'react-grid-layout';\n\nimport { SceneObjectBase } from '../../../core/SceneObjectBase';\nimport { SceneLayout, SceneObjectState } from '../../../core/types';\nimport { DEFAULT_PANEL_SPAN } from './constants';\nimport { isSceneGridRow } from './SceneGridItem';\nimport { SceneGridLayoutRenderer } from './SceneGridLayoutRenderer';\n\nimport { SceneGridRow } from './SceneGridRow';\nimport { SceneGridItemLike, SceneGridItemPlacement, SceneGridLayoutDragStartEvent } from './types';\nimport { fitPanelsInHeight } from './utils';\nimport { VizPanel } from '../../VizPanel/VizPanel';\n\ninterface SceneGridLayoutState extends SceneObjectState {\n /**\n * Turn on or off dragging for all items. Individual items can still disabled via isDraggable property\n **/\n isDraggable?: boolean;\n /** Enable or disable item resizing */\n isResizable?: boolean;\n isLazy?: boolean;\n /**\n * Fit panels to height of the grid. This will scale down the panels vertically to fit available height.\n * The row height is not changed, only the y position and height of the panels.\n * UNSAFE: This feature is experimental and it might change in the future.\n */\n UNSAFE_fitPanels?: boolean;\n children: SceneGridItemLike[];\n}\n\nexport class SceneGridLayout extends SceneObjectBase<SceneGridLayoutState> implements SceneLayout {\n public static Component = SceneGridLayoutRenderer;\n\n private _skipOnLayoutChange = false;\n private _oldLayout: ReactGridLayout.Layout[] = [];\n private _loadOldLayout = false;\n\n public constructor(state: SceneGridLayoutState) {\n super({\n ...state,\n children: sortChildrenByPosition(state.children),\n });\n }\n\n /**\n * SceneLayout interface. Used for example by VizPanelRenderer\n */\n public isDraggable(): boolean {\n return this.state.isDraggable ?? false;\n }\n\n public getDragClass() {\n return `grid-drag-handle-${this.state.key}`;\n }\n\n public getDragClassCancel() {\n return `grid-drag-cancel`;\n }\n\n public getDragHooks() {\n return {\n onDragStart: (evt: PointerEvent, panel: VizPanel) => {\n this.publishEvent(new SceneGridLayoutDragStartEvent({ evt, panel }), true);\n },\n };\n }\n\n public toggleRow(row: SceneGridRow) {\n const isCollapsed = row.state.isCollapsed;\n\n if (!isCollapsed) {\n row.setState({ isCollapsed: true });\n // To force re-render\n this.setState({});\n return;\n }\n\n const rowChildren = row.state.children;\n\n if (rowChildren.length === 0) {\n row.setState({ isCollapsed: false });\n this.setState({});\n return;\n }\n\n // Ok we are expanding row. We need to update row children y pos (incase they are incorrect) and push items below down\n // Code copied from DashboardModel toggleRow()\n\n const rowY = row.state.y!;\n const firstPanelYPos = rowChildren[0].state.y ?? rowY;\n const yDiff = firstPanelYPos - (rowY + 1);\n\n // y max will represent the bottom y pos after all panels have been added\n // needed to know home much panels below should be pushed down\n let yMax = rowY;\n\n for (const panel of rowChildren) {\n // set the y gridPos if it wasn't already set\n const newSize = { ...panel.state };\n newSize.y = newSize.y ?? rowY;\n // make sure y is adjusted (in case row moved while collapsed)\n newSize.y -= yDiff;\n\n if (newSize.y! !== panel.state.y!) {\n panel.setState(newSize);\n }\n\n // update insert post and y max\n yMax = Math.max(yMax, Number(newSize.y!) + Number(newSize.height!));\n }\n\n const pushDownAmount = yMax - rowY - 1;\n\n // push panels below down\n for (const child of this.state.children) {\n if (child.state.y! > rowY) {\n this.pushChildDown(child, pushDownAmount);\n }\n\n if (isSceneGridRow(child) && child !== row) {\n for (const rowChild of child.state.children) {\n if (rowChild.state.y! > rowY) {\n this.pushChildDown(rowChild, pushDownAmount);\n }\n }\n }\n }\n\n row.setState({ isCollapsed: false });\n // Trigger re-render\n this.setState({});\n }\n\n public ignoreLayoutChange(shouldIgnore: boolean) {\n this._skipOnLayoutChange = shouldIgnore;\n }\n\n public onLayoutChange = (layout: ReactGridLayout.Layout[]) => {\n if (this._skipOnLayoutChange) {\n // Layout has been updated by other RTL handler already\n this._skipOnLayoutChange = false;\n return;\n }\n\n // We replace with the old layout only if the current state is invalid\n if (this._loadOldLayout) {\n layout = [...this._oldLayout];\n this._loadOldLayout = false;\n }\n\n for (const item of layout) {\n const child = this.getSceneLayoutChild(item.i);\n\n const nextSize: SceneGridItemPlacement = {\n x: item.x,\n y: item.y,\n width: item.w,\n height: item.h,\n };\n\n if (!isItemSizeEqual(child.state, nextSize)) {\n child.setState({\n ...nextSize,\n });\n }\n }\n\n this.setState({ children: sortChildrenByPosition(this.state.children) });\n };\n\n /**\n * Will also scan row children and return child of the row\n */\n public getSceneLayoutChild(key: string): SceneGridItemLike {\n for (const child of this.state.children) {\n if (child.state.key === key) {\n return child;\n }\n\n if (child instanceof SceneGridRow) {\n for (const rowChild of child.state.children) {\n if (rowChild.state.key === key) {\n return rowChild;\n }\n }\n }\n }\n\n throw new Error('Scene layout child not found for GridItem');\n }\n\n public onResizeStop: ReactGridLayout.ItemCallback = (_, o, n) => {\n const child = this.getSceneLayoutChild(n.i);\n child.setState({\n width: n.w,\n height: n.h,\n });\n };\n\n private pushChildDown(child: SceneGridItemLike, amount: number) {\n child.setState({\n y: child.state.y! + amount,\n });\n }\n\n /**\n * We assume the layout array is sorted according to y pos, and walk upwards until we find a row.\n * If it is collapsed there is no row to add it to. The default is then to return the SceneGridLayout itself\n */\n private findGridItemSceneParent(layout: ReactGridLayout.Layout[], startAt: number): SceneGridRow | SceneGridLayout {\n for (let i = startAt; i >= 0; i--) {\n const gridItem = layout[i];\n const sceneChild = this.getSceneLayoutChild(gridItem.i);\n\n if (sceneChild instanceof SceneGridRow) {\n // the closest row is collapsed return null\n if (sceneChild.state.isCollapsed) {\n return this;\n }\n\n return sceneChild;\n }\n }\n\n return this;\n }\n\n /**\n * Helper func to check if we are dropping a row in between panels of another row\n */\n private isRowDropValid(\n gridLayout: ReactGridLayout.Layout[],\n updatedItem: ReactGridLayout.Layout,\n indexOfUpdatedItem: number\n ): boolean {\n // if the row is dropped at the end of the dashboard grid layout, we accept this valid state\n if (gridLayout[gridLayout.length - 1].i === updatedItem.i) {\n return true;\n }\n\n // if the next child after the updated item is a scene grid row, then we are either at the top\n // of the dashboard, or between rows\n // if it's not a grid row, but it's parent is the layout, it means we are not in between a\n // rows children, so also valid state\n const nextSceneChild = this.getSceneLayoutChild(gridLayout[indexOfUpdatedItem + 1].i);\n if (nextSceneChild instanceof SceneGridRow) {\n return true;\n } else if (nextSceneChild.parent instanceof SceneGridLayout) {\n return true;\n }\n\n return false;\n }\n\n /**\n * This likely needs a slightly different approach. Where we clone or deactivate or and re-activate the moved child\n */\n public moveChildTo(child: SceneGridItemLike, target: SceneGridLayout | SceneGridRow) {\n const currentParent = child.parent!;\n let rootChildren = this.state.children;\n\n const newChild = child.clone({ key: child.state.key });\n\n // Remove from current parent row\n if (currentParent instanceof SceneGridRow) {\n const newRow = currentParent.clone();\n newRow.setState({\n children: newRow.state.children.filter((c) => c.state.key !== child.state.key),\n });\n\n // new children with new row\n rootChildren = rootChildren.map((c) => (c === currentParent ? newRow : c));\n\n // if target is also a row\n if (target instanceof SceneGridRow) {\n const targetRow = target.clone();\n targetRow.setState({ children: [...targetRow.state.children, newChild] });\n rootChildren = rootChildren.map((c) => (c === target ? targetRow : c));\n } else {\n // target is the main grid\n rootChildren = [...rootChildren, newChild];\n }\n } else {\n if (!(target instanceof SceneGridLayout)) {\n // current parent is the main grid remove it from there\n rootChildren = rootChildren.filter((c) => c.state.key !== child.state.key);\n // Clone the target row and add the child\n const targetRow = target.clone();\n targetRow.setState({ children: [...targetRow.state.children, newChild] });\n // Replace row with new row\n rootChildren = rootChildren.map((c) => (c === target ? targetRow : c));\n }\n }\n\n return rootChildren;\n }\n\n public onDragStart: ReactGridLayout.ItemCallback = (gridLayout) => {\n this._oldLayout = [...gridLayout];\n };\n\n public onDragStop: ReactGridLayout.ItemCallback = (gridLayout, o, updatedItem) => {\n const sceneChild = this.getSceneLayoutChild(updatedItem.i)!;\n\n // Need to resort the grid layout based on new position (needed to find the new parent)\n gridLayout = sortGridLayout(gridLayout);\n\n // Update children positions if they have changed\n for (let i = 0; i < gridLayout.length; i++) {\n const gridItem = gridLayout[i];\n const child = this.getSceneLayoutChild(gridItem.i)!;\n const childSize = child.state;\n\n if (childSize?.x !== gridItem.x || childSize?.y !== gridItem.y) {\n child.setState({\n x: gridItem.x,\n y: gridItem.y,\n });\n }\n }\n\n // Update the parent if the child if it has moved to a row or back to the grid\n const indexOfUpdatedItem = gridLayout.findIndex((item) => item.i === updatedItem.i);\n let newParent = this.findGridItemSceneParent(gridLayout, indexOfUpdatedItem - 1);\n let newChildren = this.state.children;\n\n // if the child is a row and we are moving it under an uncollapsed row, keep the scene grid layout as parent\n // and set the old layout flag if the state is invalid. We allow setting the children in an invalid state,\n // as the layout will be updated in onLayoutChange and avoid flickering\n if (sceneChild instanceof SceneGridRow && newParent instanceof SceneGridRow) {\n if (!this.isRowDropValid(gridLayout, updatedItem, indexOfUpdatedItem)) {\n this._loadOldLayout = true;\n }\n\n newParent = this;\n }\n\n if (newParent !== sceneChild.parent) {\n newChildren = this.moveChildTo(sceneChild, newParent);\n }\n\n this.setState({ children: sortChildrenByPosition(newChildren) });\n this._skipOnLayoutChange = true;\n };\n\n private toGridCell(child: SceneGridItemLike): ReactGridLayout.Layout {\n const size = child.state;\n\n let x = size.x ?? 0;\n let y = size.y ?? 0;\n const w = Number.isInteger(Number(size.width)) ? Number(size.width) : DEFAULT_PANEL_SPAN;\n const h = Number.isInteger(Number(size.height)) ? Number(size.height) : DEFAULT_PANEL_SPAN;\n\n let isDraggable = child.state.isDraggable;\n let isResizable = child.state.isResizable;\n\n if (child instanceof SceneGridRow) {\n isDraggable = child.state.isCollapsed ? true : false;\n isResizable = false;\n\n if (child.state.repeatSourceKey) {\n // If this is a repeated row, we should not allow dragging\n isDraggable = false;\n isResizable = false;\n }\n }\n\n return { i: child.state.key!, x, y, h, w, isResizable, isDraggable };\n }\n\n public buildGridLayout(width: number, height: number): ReactGridLayout.Layout[] {\n let cells: ReactGridLayout.Layout[] = [];\n\n for (const child of this.state.children) {\n cells.push(this.toGridCell(child));\n\n if (child instanceof SceneGridRow && !child.state.isCollapsed) {\n for (const rowChild of child.state.children) {\n cells.push(this.toGridCell(rowChild));\n }\n }\n }\n\n // Sort by position\n cells = sortGridLayout(cells);\n\n if (this.state.UNSAFE_fitPanels) {\n cells = fitPanelsInHeight(cells, height);\n }\n\n if (width < 768) {\n // We should not persist the mobile layout\n this._skipOnLayoutChange = true;\n return cells.map((cell) => ({ ...cell, w: 24 }));\n }\n\n this._skipOnLayoutChange = false;\n\n return cells;\n }\n}\n\nfunction isItemSizeEqual(a: SceneGridItemPlacement, b: SceneGridItemPlacement) {\n return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\n\nfunction sortChildrenByPosition(children: SceneGridItemLike[]) {\n children.forEach((child) => {\n if (child instanceof SceneGridRow) {\n child.setState({ children: sortChildrenByPosition(child.state.children) });\n }\n });\n\n return [...children].sort((a, b) => {\n return a.state.y! - b.state.y! || a.state.x! - b.state.x!;\n });\n}\n\nfunction sortGridLayout(layout: ReactGridLayout.Layout[]) {\n return [...layout].sort((a, b) => a.y - b.y || a.x! - b.x);\n}\n"],"names":[],"mappings":";;;;;;;;AA+BO,MAAM,gBAAA,GAAN,MAAM,gBAAA,SAAwB,eAA6D,CAAA;AAAA,EAOzF,YAAY,KAA6B,EAAA;AAC9C,IAAM,KAAA,CAAA;AAAA,MACJ,GAAG,KAAA;AAAA,MACH,QAAA,EAAU,sBAAuB,CAAA,KAAA,CAAM,QAAQ;AAAA,KAChD,CAAA;AARH,IAAA,IAAA,CAAQ,mBAAsB,GAAA,KAAA;AAC9B,IAAA,IAAA,CAAQ,aAAuC,EAAC;AAChD,IAAA,IAAA,CAAQ,cAAiB,GAAA,KAAA;AAsGzB,IAAO,IAAA,CAAA,cAAA,GAAiB,CAAC,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AAS,uBAAuB,QAA+B,EAAA;AAC7D,EAAS,QAAA,CAAA,OAAA,CAAQ,CAAC,KAAU,KAAA;AAC1B,IAAA,IAAI,iBAAiB,YAAc,EAAA;AACjC,MAAM,KAAA,CAAA,QAAA,CAAS,EAAE,QAAU,EAAA,sBAAA,CAAuB,MAAM,KAAM,CAAA,QAAQ,GAAG,CAAA;AAAA;AAC3E,GACD,CAAA;AAED,EAAA,OAAO,CAAC,GAAG,QAAQ,EAAE,IAAK,CAAA,CAAC,GAAG,CAAM,KAAA;AAClC,IAAO,OAAA,CAAA,CAAE,KAAM,CAAA,CAAA,GAAK,CAAE,CAAA,KAAA,CAAM,KAAM,CAAE,CAAA,KAAA,CAAM,CAAK,GAAA,CAAA,CAAE,KAAM,CAAA,CAAA;AAAA,GACxD,CAAA;AACH;AAEA,SAAS,eAAe,MAAkC,EAAA;AACxD,EAAA,OAAO,CAAC,GAAG,MAAM,CAAA,CAAE,KAAK,CAAC,CAAA,EAAG,CAAM,KAAA,CAAA,CAAE,IAAI,CAAE,CAAA,CAAA,IAAK,CAAE,CAAA,CAAA,GAAK,EAAE,CAAC,CAAA;AAC3D;;;;"}
|
|
1
|
+
{"version":3,"file":"SceneGridLayout.js","sources":["../../../../../src/components/layout/grid/SceneGridLayout.tsx"],"sourcesContent":["import { PointerEvent } from 'react';\nimport ReactGridLayout from 'react-grid-layout';\n\nimport { SceneObjectBase } from '../../../core/SceneObjectBase';\nimport { SceneLayout, SceneObjectState } from '../../../core/types';\nimport { DEFAULT_PANEL_SPAN } from './constants';\nimport { isSceneGridRow } from './SceneGridItem';\nimport { SceneGridLayoutRenderer } from './SceneGridLayoutRenderer';\n\nimport { SceneGridRow } from './SceneGridRow';\nimport { SceneGridItemLike, SceneGridItemPlacement, SceneGridLayoutDragStartEvent } from './types';\nimport { fitPanelsInHeight } from './utils';\nimport { VizPanel } from '../../VizPanel/VizPanel';\nimport { isRepeatCloneOrChildOf } from '../../../utils/utils';\n\ninterface SceneGridLayoutState extends SceneObjectState {\n /**\n * Turn on or off dragging for all items. Individual items can still disabled via isDraggable property\n **/\n isDraggable?: boolean;\n /** Enable or disable item resizing */\n isResizable?: boolean;\n isLazy?: boolean;\n /**\n * Fit panels to height of the grid. This will scale down the panels vertically to fit available height.\n * The row height is not changed, only the y position and height of the panels.\n * UNSAFE: This feature is experimental and it might change in the future.\n */\n UNSAFE_fitPanels?: boolean;\n children: SceneGridItemLike[];\n}\n\nexport class SceneGridLayout extends SceneObjectBase<SceneGridLayoutState> implements SceneLayout {\n public static Component = SceneGridLayoutRenderer;\n\n private _skipOnLayoutChange = false;\n private _oldLayout: ReactGridLayout.Layout[] = [];\n private _loadOldLayout = false;\n\n public constructor(state: SceneGridLayoutState) {\n super({\n ...state,\n children: sortChildrenByPosition(state.children),\n });\n }\n\n /**\n * SceneLayout interface. Used for example by VizPanelRenderer\n */\n public isDraggable(): boolean {\n return this.state.isDraggable ?? false;\n }\n\n public getDragClass() {\n return `grid-drag-handle-${this.state.key}`;\n }\n\n public getDragClassCancel() {\n return `grid-drag-cancel`;\n }\n\n public getDragHooks() {\n return {\n onDragStart: (evt: PointerEvent, panel: VizPanel) => {\n this.publishEvent(new SceneGridLayoutDragStartEvent({ evt, panel }), true);\n },\n };\n }\n\n public toggleRow(row: SceneGridRow) {\n const isCollapsed = row.state.isCollapsed;\n\n if (!isCollapsed) {\n row.setState({ isCollapsed: true });\n // To force re-render\n this.setState({});\n return;\n }\n\n const rowChildren = row.state.children;\n\n if (rowChildren.length === 0) {\n row.setState({ isCollapsed: false });\n this.setState({});\n return;\n }\n\n // Ok we are expanding row. We need to update row children y pos (incase they are incorrect) and push items below down\n // Code copied from DashboardModel toggleRow()\n\n const rowY = row.state.y!;\n const firstPanelYPos = rowChildren[0].state.y ?? rowY;\n const yDiff = firstPanelYPos - (rowY + 1);\n\n // y max will represent the bottom y pos after all panels have been added\n // needed to know home much panels below should be pushed down\n let yMax = rowY;\n\n for (const panel of rowChildren) {\n // set the y gridPos if it wasn't already set\n const newSize = { ...panel.state };\n newSize.y = newSize.y ?? rowY;\n // make sure y is adjusted (in case row moved while collapsed)\n newSize.y -= yDiff;\n\n if (newSize.y! !== panel.state.y!) {\n panel.setState(newSize);\n }\n\n // update insert post and y max\n yMax = Math.max(yMax, Number(newSize.y!) + Number(newSize.height!));\n }\n\n const pushDownAmount = yMax - rowY - 1;\n\n // push panels below down\n for (const child of this.state.children) {\n if (child.state.y! > rowY) {\n this.pushChildDown(child, pushDownAmount);\n }\n\n if (isSceneGridRow(child) && child !== row) {\n for (const rowChild of child.state.children) {\n if (rowChild.state.y! > rowY) {\n this.pushChildDown(rowChild, pushDownAmount);\n }\n }\n }\n }\n\n row.setState({ isCollapsed: false });\n // Trigger re-render\n this.setState({});\n }\n\n public ignoreLayoutChange(shouldIgnore: boolean) {\n this._skipOnLayoutChange = shouldIgnore;\n }\n\n public onLayoutChange = (layout: ReactGridLayout.Layout[]) => {\n if (this._skipOnLayoutChange) {\n // Layout has been updated by other RTL handler already\n this._skipOnLayoutChange = false;\n return;\n }\n\n // We replace with the old layout only if the current state is invalid\n if (this._loadOldLayout) {\n layout = [...this._oldLayout];\n this._loadOldLayout = false;\n }\n\n for (const item of layout) {\n const child = this.getSceneLayoutChild(item.i);\n\n const nextSize: SceneGridItemPlacement = {\n x: item.x,\n y: item.y,\n width: item.w,\n height: item.h,\n };\n\n if (!isItemSizeEqual(child.state, nextSize)) {\n child.setState({\n ...nextSize,\n });\n }\n }\n\n this.setState({ children: sortChildrenByPosition(this.state.children) });\n };\n\n /**\n * Will also scan row children and return child of the row\n */\n public getSceneLayoutChild(key: string): SceneGridItemLike {\n for (const child of this.state.children) {\n if (child.state.key === key) {\n return child;\n }\n\n if (child instanceof SceneGridRow) {\n for (const rowChild of child.state.children) {\n if (rowChild.state.key === key) {\n return rowChild;\n }\n }\n }\n }\n\n throw new Error('Scene layout child not found for GridItem');\n }\n\n public onResizeStop: ReactGridLayout.ItemCallback = (_, o, n) => {\n const child = this.getSceneLayoutChild(n.i);\n child.setState({\n width: n.w,\n height: n.h,\n });\n };\n\n private pushChildDown(child: SceneGridItemLike, amount: number) {\n child.setState({\n y: child.state.y! + amount,\n });\n }\n\n /**\n * We assume the layout array is sorted according to y pos, and walk upwards until we find a row.\n * If it is collapsed there is no row to add it to. The default is then to return the SceneGridLayout itself\n */\n private findGridItemSceneParent(layout: ReactGridLayout.Layout[], startAt: number): SceneGridRow | SceneGridLayout {\n for (let i = startAt; i >= 0; i--) {\n const gridItem = layout[i];\n const sceneChild = this.getSceneLayoutChild(gridItem.i);\n\n if (sceneChild instanceof SceneGridRow) {\n // the closest row is collapsed return null\n if (sceneChild.state.isCollapsed) {\n return this;\n }\n\n return sceneChild;\n }\n }\n\n return this;\n }\n\n /**\n * Helper func to check if we are dropping a row in between panels of another row\n */\n private isRowDropValid(\n gridLayout: ReactGridLayout.Layout[],\n updatedItem: ReactGridLayout.Layout,\n indexOfUpdatedItem: number\n ): boolean {\n // if the row is dropped at the end of the dashboard grid layout, we accept this valid state\n if (gridLayout[gridLayout.length - 1].i === updatedItem.i) {\n return true;\n }\n\n // if the next child after the updated item is a scene grid row, then we are either at the top\n // of the dashboard, or between rows\n // if it's not a grid row, but it's parent is the layout, it means we are not in between a\n // rows children, so also valid state\n const nextSceneChild = this.getSceneLayoutChild(gridLayout[indexOfUpdatedItem + 1].i);\n if (nextSceneChild instanceof SceneGridRow) {\n return true;\n } else if (nextSceneChild.parent instanceof SceneGridLayout) {\n return true;\n }\n\n return false;\n }\n\n /**\n * This likely needs a slightly different approach. Where we clone or deactivate or and re-activate the moved child\n */\n public moveChildTo(child: SceneGridItemLike, target: SceneGridLayout | SceneGridRow) {\n const currentParent = child.parent!;\n let rootChildren = this.state.children;\n\n const newChild = child.clone({ key: child.state.key });\n\n // Remove from current parent row\n if (currentParent instanceof SceneGridRow) {\n const newRow = currentParent.clone();\n newRow.setState({\n children: newRow.state.children.filter((c) => c.state.key !== child.state.key),\n });\n\n // new children with new row\n rootChildren = rootChildren.map((c) => (c === currentParent ? newRow : c));\n\n // if target is also a row\n if (target instanceof SceneGridRow) {\n const targetRow = target.clone();\n targetRow.setState({ children: [...targetRow.state.children, newChild] });\n rootChildren = rootChildren.map((c) => (c === target ? targetRow : c));\n } else {\n // target is the main grid\n rootChildren = [...rootChildren, newChild];\n }\n } else {\n if (!(target instanceof SceneGridLayout)) {\n // current parent is the main grid remove it from there\n rootChildren = rootChildren.filter((c) => c.state.key !== child.state.key);\n // Clone the target row and add the child\n const targetRow = target.clone();\n targetRow.setState({ children: [...targetRow.state.children, newChild] });\n // Replace row with new row\n rootChildren = rootChildren.map((c) => (c === target ? targetRow : c));\n }\n }\n\n return rootChildren;\n }\n\n public onDragStart: ReactGridLayout.ItemCallback = (gridLayout) => {\n this._oldLayout = [...gridLayout];\n };\n\n public onDragStop: ReactGridLayout.ItemCallback = (gridLayout, o, updatedItem) => {\n const sceneChild = this.getSceneLayoutChild(updatedItem.i)!;\n\n // Need to resort the grid layout based on new position (needed to find the new parent)\n gridLayout = sortGridLayout(gridLayout);\n\n // Update children positions if they have changed\n for (let i = 0; i < gridLayout.length; i++) {\n const gridItem = gridLayout[i];\n const child = this.getSceneLayoutChild(gridItem.i)!;\n const childSize = child.state;\n\n if (childSize?.x !== gridItem.x || childSize?.y !== gridItem.y) {\n child.setState({\n x: gridItem.x,\n y: gridItem.y,\n });\n }\n }\n\n // Update the parent if the child if it has moved to a row or back to the grid\n const indexOfUpdatedItem = gridLayout.findIndex((item) => item.i === updatedItem.i);\n let newParent = this.findGridItemSceneParent(gridLayout, indexOfUpdatedItem - 1);\n let newChildren = this.state.children;\n\n // if the child is a row and we are moving it under an uncollapsed row, keep the scene grid layout as parent\n // and set the old layout flag if the state is invalid. We allow setting the children in an invalid state,\n // as the layout will be updated in onLayoutChange and avoid flickering\n if (sceneChild instanceof SceneGridRow && newParent instanceof SceneGridRow) {\n if (!this.isRowDropValid(gridLayout, updatedItem, indexOfUpdatedItem)) {\n this._loadOldLayout = true;\n }\n\n newParent = this;\n }\n\n if (newParent !== sceneChild.parent) {\n newChildren = this.moveChildTo(sceneChild, newParent);\n }\n\n this.setState({ children: sortChildrenByPosition(newChildren) });\n this._skipOnLayoutChange = true;\n };\n\n private toGridCell(child: SceneGridItemLike, parentKey: string): ReactGridLayout.Layout {\n const size = child.state;\n\n let x = size.x ?? 0;\n let y = size.y ?? 0;\n const w = Number.isInteger(Number(size.width)) ? Number(size.width) : DEFAULT_PANEL_SPAN;\n const h = Number.isInteger(Number(size.height)) ? Number(size.height) : DEFAULT_PANEL_SPAN;\n\n let isDraggable = child.state.isDraggable;\n let isResizable = child.state.isResizable;\n\n if (child instanceof SceneGridRow) {\n isDraggable = child.state.isCollapsed ? true : false;\n isResizable = false;\n }\n\n // If this is a repeated row, we should not allow dragging\n if (isRepeatCloneOrChildOf(child)) {\n isDraggable = false;\n isResizable = false;\n }\n\n return { i: child.state.key!, x, y, h, w, isResizable, isDraggable };\n }\n\n public buildGridLayout(width: number, height: number): ReactGridLayout.Layout[] {\n let cells: ReactGridLayout.Layout[] = [];\n\n for (const child of this.state.children) {\n cells.push(this.toGridCell(child, ''));\n\n if (child instanceof SceneGridRow && !child.state.isCollapsed) {\n for (const rowChild of child.state.children) {\n cells.push(this.toGridCell(rowChild, child.state.key!));\n }\n }\n }\n\n // Sort by position\n cells = sortGridLayout(cells);\n\n if (this.state.UNSAFE_fitPanels) {\n cells = fitPanelsInHeight(cells, height);\n }\n\n if (width < 768) {\n // We should not persist the mobile layout\n this._skipOnLayoutChange = true;\n return cells.map((cell) => ({ ...cell, w: 24 }));\n }\n\n this._skipOnLayoutChange = false;\n\n return cells;\n }\n}\n\nfunction isItemSizeEqual(a: SceneGridItemPlacement, b: SceneGridItemPlacement) {\n return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\n\nfunction sortChildrenByPosition(children: SceneGridItemLike[]) {\n children.forEach((child) => {\n if (child instanceof SceneGridRow) {\n child.setState({ children: sortChildrenByPosition(child.state.children) });\n }\n });\n\n return [...children].sort((a, b) => {\n return a.state.y! - b.state.y! || a.state.x! - b.state.x!;\n });\n}\n\nfunction sortGridLayout(layout: ReactGridLayout.Layout[]) {\n return [...layout].sort((a, b) => a.y - b.y || a.x! - b.x);\n}\n"],"names":[],"mappings":";;;;;;;;;AAgCO,MAAM,gBAAA,GAAN,MAAM,gBAAA,SAAwB,eAA6D,CAAA;AAAA,EAOzF,YAAY,KAA6B,EAAA;AAC9C,IAAM,KAAA,CAAA;AAAA,MACJ,GAAG,KAAA;AAAA,MACH,QAAA,EAAU,sBAAuB,CAAA,KAAA,CAAM,QAAQ;AAAA,KAChD,CAAA;AARH,IAAA,IAAA,CAAQ,mBAAsB,GAAA,KAAA;AAC9B,IAAA,IAAA,CAAQ,aAAuC,EAAC;AAChD,IAAA,IAAA,CAAQ,cAAiB,GAAA,KAAA;AAsGzB,IAAO,IAAA,CAAA,cAAA,GAAiB,CAAC,MAAqC,KAAA;AAC5D,MAAA,IAAI,KAAK,mBAAqB,EAAA;AAE5B,QAAA,IAAA,CAAK,mBAAsB,GAAA,KAAA;AAC3B,QAAA;AAAA;AAIF,MAAA,IAAI,KAAK,cAAgB,EAAA;AACvB,QAAS,MAAA,GAAA,CAAC,GAAG,IAAA,CAAK,UAAU,CAAA;AAC5B,QAAA,IAAA,CAAK,cAAiB,GAAA,KAAA;AAAA;AAGxB,MAAA,KAAA,MAAW,QAAQ,MAAQ,EAAA;AACzB,QAAA,MAAM,KAAQ,GAAA,IAAA,CAAK,mBAAoB,CAAA,IAAA,CAAK,CAAC,CAAA;AAE7C,QAAA,MAAM,QAAmC,GAAA;AAAA,UACvC,GAAG,IAAK,CAAA,CAAA;AAAA,UACR,GAAG,IAAK,CAAA,CAAA;AAAA,UACR,OAAO,IAAK,CAAA,CAAA;AAAA,UACZ,QAAQ,IAAK,CAAA;AAAA,SACf;AAEA,QAAA,IAAI,CAAC,eAAA,CAAgB,KAAM,CAAA,KAAA,EAAO,QAAQ,CAAG,EAAA;AAC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AAM,KAAA,CAAA,CAAE,IAAI,CAAE,CAAA,CAAA,IAAK,CAAE,CAAA,CAAA,GAAK,EAAE,CAAC,CAAA;AAC3D;;;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { cloneSceneObjectState } from './core/sceneGraph/cloneSceneObject.js';
|
|
|
4
4
|
import { registerRuntimeDataSource } from './querying/RuntimeDataSource.js';
|
|
5
5
|
export { RuntimeDataSource } from './querying/RuntimeDataSource.js';
|
|
6
6
|
import { getUrlState, syncStateFromSearchParams } from './services/utils.js';
|
|
7
|
+
import { isRepeatCloneOrChildOf } from './utils/utils.js';
|
|
7
8
|
import { registerVariableMacro } from './variables/macros/index.js';
|
|
8
9
|
import { escapeURLDelimiters, escapeLabelValueInExactSelector, escapeLabelValueInRegexSelector, renderPrometheusLabelFilters } from './variables/utils.js';
|
|
9
10
|
import { isGroupByVariable, isTextBoxVariable, isQueryVariable, isIntervalVariable, isDataSourceVariable, isCustomVariable, isConstantVariable, isAdHocVariable } from './variables/variants/guards.js';
|
|
@@ -109,7 +110,8 @@ const sceneUtils = {
|
|
|
109
110
|
isIntervalVariable,
|
|
110
111
|
isQueryVariable,
|
|
111
112
|
isTextBoxVariable,
|
|
112
|
-
isGroupByVariable
|
|
113
|
+
isGroupByVariable,
|
|
114
|
+
isRepeatCloneOrChildOf
|
|
113
115
|
};
|
|
114
116
|
|
|
115
117
|
export { registerRuntimeDataSource, sceneUtils };
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { getUrlWithAppState } from './components/SceneApp/utils';\nimport { registerRuntimePanelPlugin } from './components/VizPanel/registerRuntimePanelPlugin';\nimport { cloneSceneObjectState } from './core/sceneGraph/cloneSceneObject';\nimport { registerRuntimeDataSource } from './querying/RuntimeDataSource';\nimport { getUrlState, syncStateFromSearchParams } from './services/utils';\n\nimport { registerVariableMacro } from './variables/macros';\nimport {\n escapeLabelValueInExactSelector,\n escapeLabelValueInRegexSelector,\n escapeURLDelimiters,\n renderPrometheusLabelFilters,\n} from './variables/utils';\nimport {\n isAdHocVariable,\n isQueryVariable,\n isTextBoxVariable,\n isCustomVariable,\n isDataSourceVariable,\n isConstantVariable,\n isIntervalVariable,\n isGroupByVariable,\n} from './variables/variants/guards';\n\nexport * from './core/types';\nexport * from './core/events';\nexport { sceneGraph } from './core/sceneGraph';\nexport * as behaviors from './behaviors';\nexport * as dataLayers from './querying/layers';\n\nexport { SceneObjectBase, useSceneObjectState } from './core/SceneObjectBase';\nexport { SceneDataNode } from './core/SceneDataNode';\nexport { SceneTimeRange } from './core/SceneTimeRange';\nexport { SceneTimeZoneOverride } from './core/SceneTimeZoneOverride';\n\nexport { SceneQueryRunner, type QueryRunnerState } from './querying/SceneQueryRunner';\nexport { DataProviderProxy } from './querying/DataProviderProxy';\nexport {\n type ExtraQueryDescriptor,\n type ExtraQueryProvider,\n type ExtraQueryDataProcessor,\n} from './querying/ExtraQueryProvider';\nexport { SceneDataLayerSet, SceneDataLayerSetBase } from './querying/SceneDataLayerSet';\nexport { SceneDataLayerBase } from './querying/layers/SceneDataLayerBase';\nexport { SceneDataLayerControls } from './querying/layers/SceneDataLayerControls';\nexport { SceneDataTransformer, type SceneDataTransformerState } from './querying/SceneDataTransformer';\nexport { registerQueryWithController } from './querying/registerQueryWithController';\nexport { registerRuntimeDataSource, RuntimeDataSource } from './querying/RuntimeDataSource';\nexport type {\n SceneQueryControllerLike,\n SceneQueryControllerEntryType,\n SceneQueryControllerEntry,\n SceneInteractionProfileEvent,\n} from './behaviors/types';\nexport { SceneRenderProfiler } from './behaviors/SceneRenderProfiler';\n\nexport * from './variables/types';\nexport { VariableDependencyConfig } from './variables/VariableDependencyConfig';\nexport { formatRegistry, type FormatVariable } from './variables/interpolation/formatRegistry';\nexport { VariableValueSelectors } from './variables/components/VariableValueSelectors';\nexport { VariableValueControl } from './variables/components/VariableValueControl';\nexport { SceneVariableSet } from './variables/sets/SceneVariableSet';\nexport { ConstantVariable } from './variables/variants/ConstantVariable';\nexport { CustomVariable } from './variables/variants/CustomVariable';\nexport { DataSourceVariable } from './variables/variants/DataSourceVariable';\nexport { QueryVariable } from './variables/variants/query/QueryVariable';\nexport { TestVariable } from './variables/variants/TestVariable';\nexport { TextBoxVariable } from './variables/variants/TextBoxVariable';\nexport { ScopesVariable } from './variables/variants/ScopesVariable';\nexport {\n MultiValueVariable,\n type MultiValueVariableState,\n type VariableGetOptionsArgs,\n} from './variables/variants/MultiValueVariable';\nexport { LocalValueVariable } from './variables/variants/LocalValueVariable';\nexport { IntervalVariable } from './variables/variants/IntervalVariable';\nexport { AdHocFiltersVariable } from './variables/adhoc/AdHocFiltersVariable';\nexport type { AdHocFilterWithLabels } from './variables/adhoc/AdHocFiltersVariable';\nexport { GroupByVariable } from './variables/groupby/GroupByVariable';\nexport { type MacroVariableConstructor } from './variables/macros/types';\n\nexport { type UrlSyncManagerLike, UrlSyncManager, NewSceneObjectAddedEvent } from './services/UrlSyncManager';\nexport { useUrlSync } from './services/useUrlSync';\nexport { UrlSyncContextProvider } from './services/UrlSyncContextProvider';\nexport { SceneObjectUrlSyncConfig } from './services/SceneObjectUrlSyncConfig';\n\nexport { EmbeddedScene, type EmbeddedSceneState } from './components/EmbeddedScene';\nexport { VizPanel, type VizPanelState } from './components/VizPanel/VizPanel';\nexport { VizPanelMenu } from './components/VizPanel/VizPanelMenu';\nexport { VizPanelExploreButton } from './components/VizPanel/VizPanelExploreButton';\nexport { NestedScene } from './components/NestedScene';\nexport { SceneCanvasText } from './components/SceneCanvasText';\nexport { SceneToolbarButton, SceneToolbarInput } from './components/SceneToolbarButton';\nexport { SceneTimePicker } from './components/SceneTimePicker';\nexport { SceneRefreshPicker, type SceneRefreshPickerState } from './components/SceneRefreshPicker';\nexport { SceneTimeRangeTransformerBase } from './core/SceneTimeRangeTransformerBase';\nexport { SceneTimeRangeCompare } from './components/SceneTimeRangeCompare';\nexport { SceneByFrameRepeater } from './components/SceneByFrameRepeater';\nexport { SceneByVariableRepeater } from './components/SceneByVariableRepeater';\nexport { SceneControlsSpacer } from './components/SceneControlsSpacer';\nexport {\n SceneFlexLayout,\n SceneFlexItem,\n type SceneFlexItemState,\n type SceneFlexItemLike,\n} from './components/layout/SceneFlexLayout';\nexport { SceneCSSGridLayout, SceneCSSGridItem } from './components/layout/CSSGrid/SceneCSSGridLayout';\nexport { SceneGridLayout } from './components/layout/grid/SceneGridLayout';\nexport { SceneGridLayoutDragStartEvent } from './components/layout/grid/types';\nexport { SceneGridItem } from './components/layout/grid/SceneGridItem';\nexport { SceneGridRow } from './components/layout/grid/SceneGridRow';\nexport { type SceneGridItemStateLike, type SceneGridItemLike } from './components/layout/grid/types';\nexport { SplitLayout } from './components/layout/split/SplitLayout';\nexport { LazyLoader } from './components/layout/LazyLoader';\nexport {\n type SceneAppPageLike,\n type SceneRouteMatch,\n type SceneAppPageState,\n type SceneAppDrilldownView,\n type SceneAppRoute,\n} from './components/SceneApp/types';\nexport { SceneApp, useSceneApp } from './components/SceneApp/SceneApp';\nexport { SceneAppPage } from './components/SceneApp/SceneAppPage';\nexport { SceneReactObject } from './components/SceneReactObject';\nexport { SceneObjectRef } from './core/SceneObjectRef';\nexport {\n PanelBuilders,\n PanelOptionsBuilders,\n FieldConfigBuilders,\n FieldConfigOverridesBuilder,\n} from './core/PanelBuilders';\nexport { FieldConfigBuilder } from './core/PanelBuilders/FieldConfigBuilder';\nexport { VizPanelBuilder } from './core/PanelBuilders/VizPanelBuilder';\nexport { SceneDebugger } from './components/SceneDebugger/SceneDebugger';\nexport { VariableValueSelectWrapper } from './variables/components/VariableValueSelectors';\nexport { ControlsLabel } from './utils/ControlsLabel';\nexport { MultiOrSingleValueSelect } from './variables/components/VariableValueSelect';\nexport { VizConfigBuilder } from './core/PanelBuilders/VizConfigBuilder';\nexport { VizConfigBuilders } from './core/PanelBuilders/VizConfigBuilders';\nexport { type VizConfig } from './core/PanelBuilders/types';\n\nexport const sceneUtils = {\n getUrlWithAppState,\n registerRuntimePanelPlugin,\n registerRuntimeDataSource,\n registerVariableMacro,\n cloneSceneObjectState,\n syncStateFromSearchParams,\n getUrlState,\n renderPrometheusLabelFilters,\n escapeLabelValueInRegexSelector,\n escapeLabelValueInExactSelector,\n escapeURLDelimiters,\n\n // Variable guards\n isAdHocVariable,\n isConstantVariable,\n isCustomVariable,\n isDataSourceVariable,\n isIntervalVariable,\n isQueryVariable,\n isTextBoxVariable,\n isGroupByVariable,\n};\n\nexport { SafeSerializableSceneObject } from './utils/SafeSerializableSceneObject';\nexport { getExploreURL } from './utils/explore';\nexport { loadResources } from './utils/loadResources';\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { getUrlWithAppState } from './components/SceneApp/utils';\nimport { registerRuntimePanelPlugin } from './components/VizPanel/registerRuntimePanelPlugin';\nimport { cloneSceneObjectState } from './core/sceneGraph/cloneSceneObject';\nimport { registerRuntimeDataSource } from './querying/RuntimeDataSource';\nimport { getUrlState, syncStateFromSearchParams } from './services/utils';\nimport { isRepeatCloneOrChildOf } from './utils/utils';\n\nimport { registerVariableMacro } from './variables/macros';\nimport {\n escapeLabelValueInExactSelector,\n escapeLabelValueInRegexSelector,\n escapeURLDelimiters,\n renderPrometheusLabelFilters,\n} from './variables/utils';\nimport {\n isAdHocVariable,\n isQueryVariable,\n isTextBoxVariable,\n isCustomVariable,\n isDataSourceVariable,\n isConstantVariable,\n isIntervalVariable,\n isGroupByVariable,\n} from './variables/variants/guards';\n\nexport * from './core/types';\nexport * from './core/events';\nexport { sceneGraph } from './core/sceneGraph';\nexport * as behaviors from './behaviors';\nexport * as dataLayers from './querying/layers';\n\nexport { SceneObjectBase, useSceneObjectState } from './core/SceneObjectBase';\nexport { SceneDataNode } from './core/SceneDataNode';\nexport { SceneTimeRange } from './core/SceneTimeRange';\nexport { SceneTimeZoneOverride } from './core/SceneTimeZoneOverride';\n\nexport { SceneQueryRunner, type QueryRunnerState } from './querying/SceneQueryRunner';\nexport { DataProviderProxy } from './querying/DataProviderProxy';\nexport {\n type ExtraQueryDescriptor,\n type ExtraQueryProvider,\n type ExtraQueryDataProcessor,\n} from './querying/ExtraQueryProvider';\nexport { SceneDataLayerSet, SceneDataLayerSetBase } from './querying/SceneDataLayerSet';\nexport { SceneDataLayerBase } from './querying/layers/SceneDataLayerBase';\nexport { SceneDataLayerControls } from './querying/layers/SceneDataLayerControls';\nexport { SceneDataTransformer, type SceneDataTransformerState } from './querying/SceneDataTransformer';\nexport { registerQueryWithController } from './querying/registerQueryWithController';\nexport { registerRuntimeDataSource, RuntimeDataSource } from './querying/RuntimeDataSource';\nexport type {\n SceneQueryControllerLike,\n SceneQueryControllerEntryType,\n SceneQueryControllerEntry,\n SceneInteractionProfileEvent,\n} from './behaviors/types';\nexport { SceneRenderProfiler } from './behaviors/SceneRenderProfiler';\n\nexport * from './variables/types';\nexport { VariableDependencyConfig } from './variables/VariableDependencyConfig';\nexport { formatRegistry, type FormatVariable } from './variables/interpolation/formatRegistry';\nexport { VariableValueSelectors } from './variables/components/VariableValueSelectors';\nexport { VariableValueControl } from './variables/components/VariableValueControl';\nexport { SceneVariableSet } from './variables/sets/SceneVariableSet';\nexport { ConstantVariable } from './variables/variants/ConstantVariable';\nexport { CustomVariable } from './variables/variants/CustomVariable';\nexport { DataSourceVariable } from './variables/variants/DataSourceVariable';\nexport { QueryVariable } from './variables/variants/query/QueryVariable';\nexport { TestVariable } from './variables/variants/TestVariable';\nexport { TextBoxVariable } from './variables/variants/TextBoxVariable';\nexport { ScopesVariable } from './variables/variants/ScopesVariable';\nexport {\n MultiValueVariable,\n type MultiValueVariableState,\n type VariableGetOptionsArgs,\n} from './variables/variants/MultiValueVariable';\nexport { LocalValueVariable } from './variables/variants/LocalValueVariable';\nexport { IntervalVariable } from './variables/variants/IntervalVariable';\nexport { AdHocFiltersVariable } from './variables/adhoc/AdHocFiltersVariable';\nexport type { AdHocFilterWithLabels } from './variables/adhoc/AdHocFiltersVariable';\nexport { GroupByVariable } from './variables/groupby/GroupByVariable';\nexport { type MacroVariableConstructor } from './variables/macros/types';\n\nexport { type UrlSyncManagerLike, UrlSyncManager, NewSceneObjectAddedEvent } from './services/UrlSyncManager';\nexport { useUrlSync } from './services/useUrlSync';\nexport { UrlSyncContextProvider } from './services/UrlSyncContextProvider';\nexport { SceneObjectUrlSyncConfig } from './services/SceneObjectUrlSyncConfig';\n\nexport { EmbeddedScene, type EmbeddedSceneState } from './components/EmbeddedScene';\nexport { VizPanel, type VizPanelState } from './components/VizPanel/VizPanel';\nexport { VizPanelMenu } from './components/VizPanel/VizPanelMenu';\nexport { VizPanelExploreButton } from './components/VizPanel/VizPanelExploreButton';\nexport { NestedScene } from './components/NestedScene';\nexport { SceneCanvasText } from './components/SceneCanvasText';\nexport { SceneToolbarButton, SceneToolbarInput } from './components/SceneToolbarButton';\nexport { SceneTimePicker } from './components/SceneTimePicker';\nexport { SceneRefreshPicker, type SceneRefreshPickerState } from './components/SceneRefreshPicker';\nexport { SceneTimeRangeTransformerBase } from './core/SceneTimeRangeTransformerBase';\nexport { SceneTimeRangeCompare } from './components/SceneTimeRangeCompare';\nexport { SceneByFrameRepeater } from './components/SceneByFrameRepeater';\nexport { SceneByVariableRepeater } from './components/SceneByVariableRepeater';\nexport { SceneControlsSpacer } from './components/SceneControlsSpacer';\nexport {\n SceneFlexLayout,\n SceneFlexItem,\n type SceneFlexItemState,\n type SceneFlexItemLike,\n} from './components/layout/SceneFlexLayout';\nexport { SceneCSSGridLayout, SceneCSSGridItem } from './components/layout/CSSGrid/SceneCSSGridLayout';\nexport { SceneGridLayout } from './components/layout/grid/SceneGridLayout';\nexport { SceneGridLayoutDragStartEvent } from './components/layout/grid/types';\nexport { SceneGridItem } from './components/layout/grid/SceneGridItem';\nexport { SceneGridRow } from './components/layout/grid/SceneGridRow';\nexport { type SceneGridItemStateLike, type SceneGridItemLike } from './components/layout/grid/types';\nexport { SplitLayout } from './components/layout/split/SplitLayout';\nexport { LazyLoader } from './components/layout/LazyLoader';\nexport {\n type SceneAppPageLike,\n type SceneRouteMatch,\n type SceneAppPageState,\n type SceneAppDrilldownView,\n type SceneAppRoute,\n} from './components/SceneApp/types';\nexport { SceneApp, useSceneApp } from './components/SceneApp/SceneApp';\nexport { SceneAppPage } from './components/SceneApp/SceneAppPage';\nexport { SceneReactObject } from './components/SceneReactObject';\nexport { SceneObjectRef } from './core/SceneObjectRef';\nexport {\n PanelBuilders,\n PanelOptionsBuilders,\n FieldConfigBuilders,\n FieldConfigOverridesBuilder,\n} from './core/PanelBuilders';\nexport { FieldConfigBuilder } from './core/PanelBuilders/FieldConfigBuilder';\nexport { VizPanelBuilder } from './core/PanelBuilders/VizPanelBuilder';\nexport { SceneDebugger } from './components/SceneDebugger/SceneDebugger';\nexport { VariableValueSelectWrapper } from './variables/components/VariableValueSelectors';\nexport { ControlsLabel } from './utils/ControlsLabel';\nexport { MultiOrSingleValueSelect } from './variables/components/VariableValueSelect';\nexport { VizConfigBuilder } from './core/PanelBuilders/VizConfigBuilder';\nexport { VizConfigBuilders } from './core/PanelBuilders/VizConfigBuilders';\nexport { type VizConfig } from './core/PanelBuilders/types';\n\nexport const sceneUtils = {\n getUrlWithAppState,\n registerRuntimePanelPlugin,\n registerRuntimeDataSource,\n registerVariableMacro,\n cloneSceneObjectState,\n syncStateFromSearchParams,\n getUrlState,\n renderPrometheusLabelFilters,\n escapeLabelValueInRegexSelector,\n escapeLabelValueInExactSelector,\n escapeURLDelimiters,\n\n // Variable guards\n isAdHocVariable,\n isConstantVariable,\n isCustomVariable,\n isDataSourceVariable,\n isIntervalVariable,\n isQueryVariable,\n isTextBoxVariable,\n isGroupByVariable,\n isRepeatCloneOrChildOf,\n};\n\nexport { SafeSerializableSceneObject } from './utils/SafeSerializableSceneObject';\nexport { getExploreURL } from './utils/explore';\nexport { loadResources } from './utils/loadResources';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8IO,MAAM,UAAa,GAAA;AAAA,EACxB,kBAAA;AAAA,EACA,0BAAA;AAAA,EACA,yBAAA;AAAA,EACA,qBAAA;AAAA,EACA,qBAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA,4BAAA;AAAA,EACA,+BAAA;AAAA,EACA,+BAAA;AAAA,EACA,mBAAA;AAAA;AAAA,EAGA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACF;;;;"}
|
package/dist/esm/utils/utils.js
CHANGED
|
@@ -6,6 +6,16 @@ function setBaseClassState(sceneObject, newState) {
|
|
|
6
6
|
function useLocationServiceSafe() {
|
|
7
7
|
return useLocationService ? useLocationService() : locationService;
|
|
8
8
|
}
|
|
9
|
+
function isRepeatCloneOrChildOf(scene) {
|
|
10
|
+
let obj = scene;
|
|
11
|
+
do {
|
|
12
|
+
if ("repeatSourceKey" in obj.state && obj.state.repeatSourceKey) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
obj = obj.parent;
|
|
16
|
+
} while (obj);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
9
19
|
|
|
10
|
-
export { setBaseClassState, useLocationServiceSafe };
|
|
20
|
+
export { isRepeatCloneOrChildOf, setBaseClassState, useLocationServiceSafe };
|
|
11
21
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/utils/utils.ts"],"sourcesContent":["import { SceneObject, SceneObjectState } from '../core/types';\nimport { locationService as locationServiceRuntime, useLocationService } from '@grafana/runtime';\n\n/**\n * This function works around the problem of Contravariance of the SceneObject.setState function\n * Contravariance is not enforce by interfaces and here we use the SceneObject interface to access the setState function\n */\nexport function setBaseClassState<T extends SceneObjectState>(sceneObject: SceneObject<T>, newState: Partial<T>) {\n sceneObject.setState(newState);\n}\n\n/**\n * Safe way to get location service that fallbacks to singleton for older runtime versions where useLocationService is\n * not available.\n */\nexport function useLocationServiceSafe() {\n // This is basically a version/feature check for grafana/runtime so this 'if' should be stable (ie for one instance\n // of grafana this will always be true or false) so it should be safe to ignore the hook rule here\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useLocationService ? useLocationService() : locationServiceRuntime;\n}\n"],"names":["locationServiceRuntime"],"mappings":";;AAOgB,SAAA,iBAAA,CAA8C,aAA6B,QAAsB,EAAA;AAC/G,EAAA,WAAA,CAAY,SAAS,QAAQ,CAAA;AAC/B;AAMO,SAAS,sBAAyB,GAAA;AAIvC,EAAO,OAAA,kBAAA,GAAqB,oBAAuB,GAAAA,eAAA;AACrD;;;;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/utils/utils.ts"],"sourcesContent":["import { SceneObject, SceneObjectState } from '../core/types';\nimport { locationService as locationServiceRuntime, useLocationService } from '@grafana/runtime';\n\n/**\n * This function works around the problem of Contravariance of the SceneObject.setState function\n * Contravariance is not enforce by interfaces and here we use the SceneObject interface to access the setState function\n */\nexport function setBaseClassState<T extends SceneObjectState>(sceneObject: SceneObject<T>, newState: Partial<T>) {\n sceneObject.setState(newState);\n}\n\n/**\n * Safe way to get location service that fallbacks to singleton for older runtime versions where useLocationService is\n * not available.\n */\nexport function useLocationServiceSafe() {\n // This is basically a version/feature check for grafana/runtime so this 'if' should be stable (ie for one instance\n // of grafana this will always be true or false) so it should be safe to ignore the hook rule here\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useLocationService ? useLocationService() : locationServiceRuntime;\n}\n\nexport function isRepeatCloneOrChildOf(scene: SceneObject): boolean {\n let obj: SceneObject | undefined = scene;\n\n do {\n if ('repeatSourceKey' in obj.state && obj.state.repeatSourceKey) {\n return true;\n }\n\n obj = obj.parent;\n } while (obj);\n\n return false;\n}\n"],"names":["locationServiceRuntime"],"mappings":";;AAOgB,SAAA,iBAAA,CAA8C,aAA6B,QAAsB,EAAA;AAC/G,EAAA,WAAA,CAAY,SAAS,QAAQ,CAAA;AAC/B;AAMO,SAAS,sBAAyB,GAAA;AAIvC,EAAO,OAAA,kBAAA,GAAqB,oBAAuB,GAAAA,eAAA;AACrD;AAEO,SAAS,uBAAuB,KAA6B,EAAA;AAClE,EAAA,IAAI,GAA+B,GAAA,KAAA;AAEnC,EAAG,GAAA;AACD,IAAA,IAAI,iBAAqB,IAAA,GAAA,CAAI,KAAS,IAAA,GAAA,CAAI,MAAM,eAAiB,EAAA;AAC/D,MAAO,OAAA,IAAA;AAAA;AAGT,IAAA,GAAA,GAAM,GAAI,CAAA,MAAA;AAAA,GACH,QAAA,GAAA;AAET,EAAO,OAAA,KAAA;AACT;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -805,6 +805,8 @@ declare function getUrlState(root: SceneObject, uniqueUrlKeyMapperOptions?: Uniq
|
|
|
805
805
|
*/
|
|
806
806
|
declare function syncStateFromSearchParams(root: SceneObject, urlParams: URLSearchParams, uniqueUrlKeyMapperOptions?: UniqueUrlKeyMapperOptions): void;
|
|
807
807
|
|
|
808
|
+
declare function isRepeatCloneOrChildOf(scene: SceneObject): boolean;
|
|
809
|
+
|
|
808
810
|
interface FormatRegistryItem extends RegistryItem {
|
|
809
811
|
formatter(value: VariableValue, args: string[], variable: FormatVariable): string;
|
|
810
812
|
}
|
|
@@ -3103,6 +3105,7 @@ declare const sceneUtils: {
|
|
|
3103
3105
|
isQueryVariable: typeof isQueryVariable;
|
|
3104
3106
|
isTextBoxVariable: typeof isTextBoxVariable;
|
|
3105
3107
|
isGroupByVariable: typeof isGroupByVariable;
|
|
3108
|
+
isRepeatCloneOrChildOf: typeof isRepeatCloneOrChildOf;
|
|
3106
3109
|
};
|
|
3107
3110
|
|
|
3108
3111
|
export { AdHocFiltersVariable, ConstantVariable, ControlsLabel, CustomVariable, DataProviderProxy, DataSourceVariable, EmbeddedScene, FieldConfigBuilder, FieldConfigBuilders, FieldConfigOverridesBuilder, GroupByVariable, IntervalVariable, LazyLoader, LocalValueVariable, MultiOrSingleValueSelect, MultiValueVariable, NestedScene, NewSceneObjectAddedEvent, PanelBuilders, PanelOptionsBuilders, QueryVariable, RuntimeDataSource, SafeSerializableSceneObject, SceneApp, SceneAppPage, SceneByFrameRepeater, SceneByVariableRepeater, SceneCSSGridItem, SceneCSSGridLayout, SceneCanvasText, SceneControlsSpacer, SceneDataLayerBase, SceneDataLayerControls, SceneDataLayerSet, SceneDataLayerSetBase, SceneDataNode, SceneDataTransformer, SceneDebugger, SceneFlexItem, SceneFlexLayout, SceneGridItem, SceneGridLayout, SceneGridLayoutDragStartEvent, SceneGridRow, SceneObjectBase, SceneObjectRef, SceneObjectStateChangedEvent, SceneObjectUrlSyncConfig, SceneQueryRunner, SceneReactObject, SceneRefreshPicker, SceneRenderProfiler, SceneTimePicker, SceneTimeRange, SceneTimeRangeCompare, SceneTimeRangeTransformerBase, SceneTimeZoneOverride, SceneToolbarButton, SceneToolbarInput, SceneVariableSet, SceneVariableValueChangedEvent, ScopesVariable, SplitLayout, TestVariable, TextBoxVariable, UrlSyncContextProvider, UrlSyncManager, UserActionEvent, VariableDependencyConfig, VariableValueControl, VariableValueSelectWrapper, VariableValueSelectors, VizConfigBuilder, VizConfigBuilders, VizPanel, VizPanelBuilder, VizPanelExploreButton, VizPanelMenu, index$1 as behaviors, index as dataLayers, formatRegistry, getExploreURL, isCustomVariableValue, isDataLayer, isDataRequestEnricher, isFiltersRequestEnricher, isSceneObject, loadResources, registerQueryWithController, registerRuntimeDataSource, sceneGraph, sceneUtils, useSceneApp, useSceneObjectState, useUrlSync };
|
package/dist/index.js
CHANGED
|
@@ -1841,6 +1841,16 @@ function setBaseClassState(sceneObject, newState) {
|
|
|
1841
1841
|
function useLocationServiceSafe() {
|
|
1842
1842
|
return runtime.useLocationService ? runtime.useLocationService() : runtime.locationService;
|
|
1843
1843
|
}
|
|
1844
|
+
function isRepeatCloneOrChildOf(scene) {
|
|
1845
|
+
let obj = scene;
|
|
1846
|
+
do {
|
|
1847
|
+
if ("repeatSourceKey" in obj.state && obj.state.repeatSourceKey) {
|
|
1848
|
+
return true;
|
|
1849
|
+
}
|
|
1850
|
+
obj = obj.parent;
|
|
1851
|
+
} while (obj);
|
|
1852
|
+
return false;
|
|
1853
|
+
}
|
|
1844
1854
|
|
|
1845
1855
|
class MultiValueVariable extends SceneObjectBase {
|
|
1846
1856
|
constructor() {
|
|
@@ -8347,15 +8357,15 @@ function getDragHooks(panel) {
|
|
|
8347
8357
|
return (_b = (_a = parentLayout == null ? void 0 : parentLayout.getDragHooks) == null ? void 0 : _a.call(parentLayout)) != null ? _b : {};
|
|
8348
8358
|
}
|
|
8349
8359
|
function itemDraggingDisabled(item, layout) {
|
|
8350
|
-
let
|
|
8351
|
-
while (
|
|
8352
|
-
if ("isDraggable" in
|
|
8360
|
+
let obj = item;
|
|
8361
|
+
while (obj && obj !== layout) {
|
|
8362
|
+
if ("isDraggable" in obj.state && obj.state.isDraggable === false) {
|
|
8353
8363
|
return true;
|
|
8354
8364
|
}
|
|
8355
|
-
if ("repeatSourceKey" in
|
|
8365
|
+
if ("repeatSourceKey" in obj.state && obj.state.repeatSourceKey) {
|
|
8356
8366
|
return true;
|
|
8357
8367
|
}
|
|
8358
|
-
|
|
8368
|
+
obj = obj.parent;
|
|
8359
8369
|
}
|
|
8360
8370
|
return false;
|
|
8361
8371
|
}
|
|
@@ -11689,7 +11699,7 @@ const _SceneGridLayout = class _SceneGridLayout extends SceneObjectBase {
|
|
|
11689
11699
|
}
|
|
11690
11700
|
return rootChildren;
|
|
11691
11701
|
}
|
|
11692
|
-
toGridCell(child) {
|
|
11702
|
+
toGridCell(child, parentKey) {
|
|
11693
11703
|
var _a, _b;
|
|
11694
11704
|
const size = child.state;
|
|
11695
11705
|
let x = (_a = size.x) != null ? _a : 0;
|
|
@@ -11701,20 +11711,20 @@ const _SceneGridLayout = class _SceneGridLayout extends SceneObjectBase {
|
|
|
11701
11711
|
if (child instanceof SceneGridRow) {
|
|
11702
11712
|
isDraggable = child.state.isCollapsed ? true : false;
|
|
11703
11713
|
isResizable = false;
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
11714
|
+
}
|
|
11715
|
+
if (isRepeatCloneOrChildOf(child)) {
|
|
11716
|
+
isDraggable = false;
|
|
11717
|
+
isResizable = false;
|
|
11708
11718
|
}
|
|
11709
11719
|
return { i: child.state.key, x, y, h, w, isResizable, isDraggable };
|
|
11710
11720
|
}
|
|
11711
11721
|
buildGridLayout(width, height) {
|
|
11712
11722
|
let cells = [];
|
|
11713
11723
|
for (const child of this.state.children) {
|
|
11714
|
-
cells.push(this.toGridCell(child));
|
|
11724
|
+
cells.push(this.toGridCell(child, ""));
|
|
11715
11725
|
if (child instanceof SceneGridRow && !child.state.isCollapsed) {
|
|
11716
11726
|
for (const rowChild of child.state.children) {
|
|
11717
|
-
cells.push(this.toGridCell(rowChild));
|
|
11727
|
+
cells.push(this.toGridCell(rowChild, child.state.key));
|
|
11718
11728
|
}
|
|
11719
11729
|
}
|
|
11720
11730
|
}
|
|
@@ -14660,7 +14670,8 @@ const sceneUtils = {
|
|
|
14660
14670
|
isIntervalVariable,
|
|
14661
14671
|
isQueryVariable,
|
|
14662
14672
|
isTextBoxVariable,
|
|
14663
|
-
isGroupByVariable
|
|
14673
|
+
isGroupByVariable,
|
|
14674
|
+
isRepeatCloneOrChildOf
|
|
14664
14675
|
};
|
|
14665
14676
|
|
|
14666
14677
|
exports.AdHocFiltersVariable = AdHocFiltersVariable;
|