@grafana/scenes 5.24.0--canary.956.11779891409.0 → 5.24.1--canary.940.11818048844.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ # v5.24.0 (Tue Nov 12 2024)
2
+
3
+ #### 🚀 Enhancement
4
+
5
+ - Variables: Add new `allowCustomValue` flag to MultiVariables [#956](https://github.com/grafana/scenes/pull/956) ([@mdvictor](https://github.com/mdvictor))
6
+
7
+ #### 🐛 Bug Fix
8
+
9
+ - Add VizPanelExploreButton scene object [#804](https://github.com/grafana/scenes/pull/804) ([@domasx2](https://github.com/domasx2))
10
+
11
+ #### Authors: 2
12
+
13
+ - Domas ([@domasx2](https://github.com/domasx2))
14
+ - Victor Marin ([@mdvictor](https://github.com/mdvictor))
15
+
16
+ ---
17
+
1
18
  # v5.23.4 (Fri Nov 08 2024)
2
19
 
3
20
  #### 🐛 Bug Fix
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import { LinkButton } from '@grafana/ui';
3
+ import { useAsync } from 'react-use';
4
+ import { SceneObjectBase } from '../../core/SceneObjectBase.js';
5
+ import { sceneGraph } from '../../core/sceneGraph/index.js';
6
+ import { getExploreURL } from '../../utils/explore.js';
7
+ import { useReturnToPrevious } from '@grafana/runtime';
8
+
9
+ class VizPanelExploreButton extends SceneObjectBase {
10
+ constructor(options = {}) {
11
+ super({ options });
12
+ }
13
+ }
14
+ VizPanelExploreButton.Component = VizPanelExploreButtonComponent;
15
+ function VizPanelExploreButtonComponent({ model }) {
16
+ const { options } = model.useState();
17
+ const { data } = sceneGraph.getData(model).useState();
18
+ const { from, to } = sceneGraph.getTimeRange(model).useState();
19
+ const { value: exploreLink } = useAsync(
20
+ async () => data ? getExploreURL(data, model, { from, to }, options.transform) : "",
21
+ [data, model, from, to]
22
+ );
23
+ const returnToPrevious = useReturnToPrevious();
24
+ if (exploreLink) {
25
+ return /* @__PURE__ */ React.createElement(LinkButton, {
26
+ key: "explore",
27
+ icon: "compass",
28
+ size: "sm",
29
+ variant: "secondary",
30
+ href: exploreLink,
31
+ onClick: () => {
32
+ var _a;
33
+ if (options.returnToPrevious) {
34
+ returnToPrevious(options.returnToPrevious.title, options.returnToPrevious.href);
35
+ }
36
+ (_a = options.onClick) == null ? void 0 : _a.call(options);
37
+ }
38
+ }, "Explore");
39
+ }
40
+ return null;
41
+ }
42
+
43
+ export { VizPanelExploreButton };
44
+ //# sourceMappingURL=VizPanelExploreButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VizPanelExploreButton.js","sources":["../../../../src/components/VizPanel/VizPanelExploreButton.tsx"],"sourcesContent":["import React from 'react';\n\nimport { LinkButton } from '@grafana/ui';\nimport { DataQuery } from '@grafana/schema';\nimport { useAsync } from 'react-use';\nimport { SceneComponentProps, SceneObjectState } from '../../core/types';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { getExploreURL } from '../../utils/explore';\nimport { useReturnToPrevious } from '@grafana/runtime';\n\nexport interface ExploreButtonOptions {\n // Callback to hook in tracking / analytics\n onClick?: () => void;\n\n // Callback to modify interpolated query before passing it to explore\n transform?: (query: DataQuery) => DataQuery;\n\n // Title and href for the return to previous button\n returnToPrevious?: {\n title: string;\n href?: string;\n };\n}\n\ninterface ExploreButtonState extends SceneObjectState {\n options: ExploreButtonOptions;\n}\n\nexport class VizPanelExploreButton extends SceneObjectBase<ExploreButtonState> {\n static Component = VizPanelExploreButtonComponent;\n\n public constructor(options: ExploreButtonOptions = {}) {\n super({ options });\n }\n}\n\nfunction VizPanelExploreButtonComponent({ model }: SceneComponentProps<VizPanelExploreButton>) {\n const { options } = model.useState();\n\n const { data } = sceneGraph.getData(model).useState();\n\n const { from, to } = sceneGraph.getTimeRange(model).useState();\n\n const { value: exploreLink } = useAsync(\n async () => (data ? getExploreURL(data, model, { from, to }, options.transform) : ''),\n [data, model, from, to]\n );\n\n const returnToPrevious = useReturnToPrevious();\n\n if (exploreLink) {\n return (\n <LinkButton\n key=\"explore\"\n icon=\"compass\"\n size=\"sm\"\n variant=\"secondary\"\n href={exploreLink}\n onClick={() => {\n if (options.returnToPrevious) {\n returnToPrevious(options.returnToPrevious.title, options.returnToPrevious.href);\n }\n options.onClick?.();\n }}\n >\n Explore\n </LinkButton>\n );\n }\n return null;\n}\n"],"names":[],"mappings":";;;;;;;;AA6BO,MAAM,8BAA8B,eAAoC,CAAA;AAAA,EAGtE,WAAA,CAAY,OAAgC,GAAA,EAAI,EAAA;AACrD,IAAM,KAAA,CAAA,EAAE,SAAS,CAAA,CAAA;AAAA,GACnB;AACF,CAAA;AANa,qBAAA,CACJ,SAAY,GAAA,8BAAA,CAAA;AAOrB,SAAS,8BAAA,CAA+B,EAAE,KAAA,EAAqD,EAAA;AAC7F,EAAA,MAAM,EAAE,OAAA,EAAY,GAAA,KAAA,CAAM,QAAS,EAAA,CAAA;AAEnC,EAAA,MAAM,EAAE,IAAK,EAAA,GAAI,WAAW,OAAQ,CAAA,KAAK,EAAE,QAAS,EAAA,CAAA;AAEpD,EAAM,MAAA,EAAE,MAAM,EAAG,EAAA,GAAI,WAAW,YAAa,CAAA,KAAK,EAAE,QAAS,EAAA,CAAA;AAE7D,EAAM,MAAA,EAAE,KAAO,EAAA,WAAA,EAAgB,GAAA,QAAA;AAAA,IAC7B,YAAa,IAAO,GAAA,aAAA,CAAc,IAAM,EAAA,KAAA,EAAO,EAAE,IAAA,EAAM,EAAG,EAAA,EAAG,OAAQ,CAAA,SAAS,CAAI,GAAA,EAAA;AAAA,IAClF,CAAC,IAAA,EAAM,KAAO,EAAA,IAAA,EAAM,EAAE,CAAA;AAAA,GACxB,CAAA;AAEA,EAAA,MAAM,mBAAmB,mBAAoB,EAAA,CAAA;AAE7C,EAAA,IAAI,WAAa,EAAA;AACf,IAAA,uBACG,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA;AAAA,MACC,GAAI,EAAA,SAAA;AAAA,MACJ,IAAK,EAAA,SAAA;AAAA,MACL,IAAK,EAAA,IAAA;AAAA,MACL,OAAQ,EAAA,WAAA;AAAA,MACR,IAAM,EAAA,WAAA;AAAA,MACN,SAAS,MAAM;AA3DvB,QAAA,IAAA,EAAA,CAAA;AA4DU,QAAA,IAAI,QAAQ,gBAAkB,EAAA;AAC5B,UAAA,gBAAA,CAAiB,OAAQ,CAAA,gBAAA,CAAiB,KAAO,EAAA,OAAA,CAAQ,iBAAiB,IAAI,CAAA,CAAA;AAAA,SAChF;AACA,QAAA,CAAA,EAAA,GAAA,OAAA,CAAQ,OAAR,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,OAAA,CAAA,CAAA;AAAA,OACF;AAAA,KAAA,EACD,SAED,CAAA,CAAA;AAAA,GAEJ;AACA,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}
package/dist/esm/index.js CHANGED
@@ -49,6 +49,7 @@ export { SceneObjectUrlSyncConfig } from './services/SceneObjectUrlSyncConfig.js
49
49
  export { EmbeddedScene } from './components/EmbeddedScene.js';
50
50
  export { VizPanel } from './components/VizPanel/VizPanel.js';
51
51
  export { VizPanelMenu } from './components/VizPanel/VizPanelMenu.js';
52
+ export { VizPanelExploreButton } from './components/VizPanel/VizPanelExploreButton.js';
52
53
  export { NestedScene } from './components/NestedScene.js';
53
54
  export { SceneCanvasText } from './components/SceneCanvasText.js';
54
55
  export { SceneToolbarButton, SceneToolbarInput } from './components/SceneToolbarButton.js';
@@ -78,6 +79,7 @@ export { renderSelectForVariable } from './variables/components/VariableValueSel
78
79
  export { VizConfigBuilder } from './core/PanelBuilders/VizConfigBuilder.js';
79
80
  export { VizConfigBuilders } from './core/PanelBuilders/VizConfigBuilders.js';
80
81
  export { SafeSerializableSceneObject } from './utils/SafeSerializableSceneObject.js';
82
+ export { getExploreURL } from './utils/explore.js';
81
83
  export { PanelOptionsBuilders } from './core/PanelBuilders/PanelOptionsBuilders.js';
82
84
  export { FieldConfigBuilders } from './core/PanelBuilders/FieldConfigBuilders.js';
83
85
  export { FieldConfigOverridesBuilder } from './core/PanelBuilders/FieldConfigOverridesBuilder.js';
@@ -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/utils';\nimport { registerRuntimeDataSource } from './querying/RuntimeDataSource';\nimport { getUrlState, syncStateFromSearchParams } from './services/utils';\n\nimport { registerVariableMacro } from './variables/macros';\nimport { renderPrometheusLabelFilters } 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} from './behaviors/SceneQueryController';\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 {\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 { 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 { 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 { 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 {\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 { renderSelectForVariable } 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\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';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiIO,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,EAGA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AACF;;;;"}
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/utils';\nimport { registerRuntimeDataSource } from './querying/RuntimeDataSource';\nimport { getUrlState, syncStateFromSearchParams } from './services/utils';\n\nimport { registerVariableMacro } from './variables/macros';\nimport { renderPrometheusLabelFilters } 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} from './behaviors/SceneQueryController';\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 {\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 { 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 { 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 {\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 { renderSelectForVariable } 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\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';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkIO,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,EAGA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AACF;;;;"}
@@ -0,0 +1,47 @@
1
+ import { wrapInSafeSerializableSceneObject } from './wrapInSafeSerializableSceneObject.js';
2
+ import { getDataSourceSrv } from '@grafana/runtime';
3
+
4
+ async function getExploreURL(data, model, timeRange, transform) {
5
+ var _a, _b, _c, _d;
6
+ const targets = (_a = data.request) == null ? void 0 : _a.targets;
7
+ if (!targets) {
8
+ return "";
9
+ }
10
+ const { from, to } = timeRange;
11
+ const filters = (_b = data.request) == null ? void 0 : _b.filters;
12
+ const scopedVars = {
13
+ __sceneObject: wrapInSafeSerializableSceneObject(model)
14
+ };
15
+ const interpolatedQueries = (await Promise.allSettled(
16
+ targets.map(async (q) => {
17
+ var _a2;
18
+ const queryDs = await getDataSourceSrv().get(q.datasource);
19
+ return ((_a2 = queryDs.interpolateVariablesInQueries) == null ? void 0 : _a2.call(queryDs, [q], scopedVars != null ? scopedVars : {}, filters)[0]) || q;
20
+ })
21
+ )).filter((promise) => promise.status === "fulfilled").map((q) => q.value).map((q) => {
22
+ var _a2;
23
+ return (_a2 = transform == null ? void 0 : transform(q)) != null ? _a2 : q;
24
+ });
25
+ const queries = interpolatedQueries != null ? interpolatedQueries : [];
26
+ const datasource = (_d = (_c = queries.find((query) => {
27
+ var _a2;
28
+ return !!((_a2 = query.datasource) == null ? void 0 : _a2.uid);
29
+ })) == null ? void 0 : _c.datasource) == null ? void 0 : _d.uid;
30
+ if ((queries == null ? void 0 : queries.length) && datasource && from && to) {
31
+ const left = encodeURIComponent(
32
+ JSON.stringify({
33
+ datasource,
34
+ queries,
35
+ range: {
36
+ from,
37
+ to
38
+ }
39
+ })
40
+ );
41
+ return `/explore?left=${left}`;
42
+ }
43
+ return "";
44
+ }
45
+
46
+ export { getExploreURL };
47
+ //# sourceMappingURL=explore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explore.js","sources":["../../../src/utils/explore.ts"],"sourcesContent":["import { PanelData, RawTimeRange, ScopedVars } from '@grafana/data';\nimport { SceneObject } from '../core/types';\nimport { wrapInSafeSerializableSceneObject } from './wrapInSafeSerializableSceneObject';\nimport { getDataSourceSrv } from '@grafana/runtime';\nimport { DataQuery } from '@grafana/schema';\n\n/**\n * Returns URL to Grafana explore for the queries in the given panel data and time range.\n */\nexport async function getExploreURL(\n data: PanelData,\n model: SceneObject,\n timeRange: RawTimeRange,\n transform?: (query: DataQuery) => DataQuery\n): Promise<string> {\n const targets = data.request?.targets;\n if (!targets) {\n return '';\n }\n\n const { from, to } = timeRange;\n\n const filters = data.request?.filters;\n\n const scopedVars: ScopedVars = {\n __sceneObject: wrapInSafeSerializableSceneObject(model),\n };\n\n const interpolatedQueries = (\n await Promise.allSettled(\n targets.map(async (q) => {\n const queryDs = await getDataSourceSrv().get(q.datasource);\n return queryDs.interpolateVariablesInQueries?.([q], scopedVars ?? {}, filters)[0] || q;\n })\n )\n )\n .filter((promise): promise is PromiseFulfilledResult<DataQuery> => promise.status === 'fulfilled')\n .map((q) => q.value)\n .map((q) => transform?.(q) ?? q);\n\n const queries: DataQuery[] = interpolatedQueries ?? [];\n\n const datasource = queries.find((query) => !!query.datasource?.uid)?.datasource?.uid;\n\n if (queries?.length && datasource && from && to) {\n const left = encodeURIComponent(\n JSON.stringify({\n datasource,\n queries,\n range: {\n from,\n to,\n },\n })\n );\n\n return `/explore?left=${left}`;\n }\n return '';\n}\n"],"names":["_a"],"mappings":"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"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _grafana_data from '@grafana/data';
2
- import { BusEventWithPayload, PanelData, BusEvent, BusEventType, BusEventHandler, TimeRange, DataQueryRequest, DataSourceGetTagKeysOptions, DataSourceGetTagValuesOptions, DataTransformContext, DataFrame, UrlQueryMap, PanelPlugin, EventBus, DataQuery as DataQuery$1, DataSourceApi, Registry, RegistryItem, ScopedVars, AdHocVariableFilter, SelectableValue, MetricFindValue, GetTagResponse, VariableRefresh as VariableRefresh$1, VariableSort, EventFilterOptions, AnnotationEvent, AnnotationQuery, DataTransformerConfig, PanelMenuItem, FieldConfigSource, PanelModel, AbsoluteTimeRange, InterpolateFunction, IconName as IconName$1, PageLayoutType, FieldConfig, FieldType, FieldValueMatcherConfig, ScopedVar } from '@grafana/data';
2
+ import { BusEventWithPayload, PanelData, BusEvent, BusEventType, BusEventHandler, TimeRange, DataQueryRequest, DataSourceGetTagKeysOptions, DataSourceGetTagValuesOptions, DataTransformContext, DataFrame, UrlQueryMap, PanelPlugin, EventBus, DataQuery as DataQuery$1, DataSourceApi, Registry, RegistryItem, ScopedVars, AdHocVariableFilter, SelectableValue, MetricFindValue, GetTagResponse, VariableRefresh as VariableRefresh$1, VariableSort, EventFilterOptions, AnnotationEvent, AnnotationQuery, DataTransformerConfig, PanelMenuItem, FieldConfigSource, PanelModel, AbsoluteTimeRange, InterpolateFunction, IconName as IconName$1, PageLayoutType, FieldConfig, FieldType, FieldValueMatcherConfig, ScopedVar, RawTimeRange } from '@grafana/data';
3
3
  import * as React$1 from 'react';
4
4
  import React__default, { CSSProperties, ComponentType } from 'react';
5
5
  import * as rxjs from 'rxjs';
@@ -1825,6 +1825,23 @@ declare class VizPanel<TOptions = {}, TFieldConfig extends {} = {}> extends Scen
1825
1825
  private buildPanelContext;
1826
1826
  }
1827
1827
 
1828
+ interface ExploreButtonOptions {
1829
+ onClick?: () => void;
1830
+ transform?: (query: DataQuery) => DataQuery;
1831
+ returnToPrevious?: {
1832
+ title: string;
1833
+ href?: string;
1834
+ };
1835
+ }
1836
+ interface ExploreButtonState extends SceneObjectState {
1837
+ options: ExploreButtonOptions;
1838
+ }
1839
+ declare class VizPanelExploreButton extends SceneObjectBase<ExploreButtonState> {
1840
+ static Component: typeof VizPanelExploreButtonComponent;
1841
+ constructor(options?: ExploreButtonOptions);
1842
+ }
1843
+ declare function VizPanelExploreButtonComponent({ model }: SceneComponentProps<VizPanelExploreButton>): React__default.JSX.Element | null;
1844
+
1828
1845
  interface NestedSceneState extends SceneObjectState {
1829
1846
  title: string;
1830
1847
  isCollapsed?: boolean;
@@ -2781,6 +2798,11 @@ declare class SafeSerializableSceneObject implements ScopedVar {
2781
2798
  get value(): this;
2782
2799
  }
2783
2800
 
2801
+ /**
2802
+ * Returns URL to Grafana explore for the queries in the given panel data and time range.
2803
+ */
2804
+ declare function getExploreURL(data: PanelData, model: SceneObject, timeRange: RawTimeRange, transform?: (query: DataQuery) => DataQuery): Promise<string>;
2805
+
2784
2806
  declare const sceneUtils: {
2785
2807
  getUrlWithAppState: typeof getUrlWithAppState;
2786
2808
  registerRuntimePanelPlugin: typeof registerRuntimePanelPlugin;
@@ -2800,4 +2822,4 @@ declare const sceneUtils: {
2800
2822
  isGroupByVariable: typeof isGroupByVariable;
2801
2823
  };
2802
2824
 
2803
- export { AdHocFiltersVariable, CancelActivationHandler, ConstantVariable, ControlsLabel, ControlsLayout, CustomFormatterVariable, CustomTransformOperator, CustomTransformerDefinition, CustomVariable, CustomVariableValue, DataLayerFilter, DataProviderProxy, DataRequestEnricher, DataSourceVariable, DeepPartial, EmbeddedScene, EmbeddedSceneState, ExtraQueryDataProcessor, ExtraQueryDescriptor, ExtraQueryProvider, FieldConfigBuilder, FieldConfigBuilders, FieldConfigOverridesBuilder, FiltersRequestEnricher, FormatVariable, GroupByVariable, InterpolationFormatParameter, IntervalVariable, LocalValueVariable, MacroVariableConstructor, MultiValueVariable, MultiValueVariableState, NestedScene, NewSceneObjectAddedEvent, PanelBuilders, PanelOptionsBuilders, QueryRunnerState, QueryVariable, RuntimeDataSource, SafeSerializableSceneObject, SceneActivationHandler, SceneApp, SceneAppDrilldownView, SceneAppPage, SceneAppPageLike, SceneAppPageState, SceneAppRoute, SceneByFrameRepeater, SceneByVariableRepeater, SceneCSSGridItem, SceneCSSGridLayout, SceneCanvasText, SceneComponent, SceneComponentProps, SceneControlsSpacer, SceneDataLayerBase, SceneDataLayerControls, SceneDataLayerProvider, SceneDataLayerProviderState, SceneDataLayerSet, SceneDataLayerSetBase, SceneDataNode, SceneDataProvider, SceneDataProviderResult, SceneDataQuery, SceneDataState, SceneDataTransformer, SceneDataTransformerState, SceneDeactivationHandler, SceneDebugger, SceneFlexItem, SceneFlexItemLike, SceneFlexItemState, SceneFlexLayout, SceneGridItem, SceneGridItemLike, SceneGridItemStateLike, SceneGridLayout, SceneGridRow, SceneLayout, SceneLayoutChildOptions, SceneLayoutState, SceneObject, SceneObjectBase, SceneObjectRef, SceneObjectState, SceneObjectStateChangedEvent, SceneObjectStateChangedPayload, SceneObjectUrlSyncConfig, SceneObjectUrlSyncHandler, SceneObjectUrlValue, SceneObjectUrlValues, SceneObjectWithUrlSync, SceneQueryControllerEntry, SceneQueryControllerEntryType, SceneQueryControllerLike, SceneQueryRunner, SceneReactObject, SceneRefreshPicker, SceneRefreshPickerState, SceneRouteMatch, SceneStateChangedHandler, SceneStatelessBehavior, SceneTimePicker, SceneTimeRange, SceneTimeRangeCompare, SceneTimeRangeLike, SceneTimeRangeState, SceneTimeRangeTransformerBase, SceneTimeZoneOverride, SceneToolbarButton, SceneToolbarInput, SceneUrlSyncOptions, SceneVariable, SceneVariableDependencyConfigLike, SceneVariableSet, SceneVariableSetState, SceneVariableState, SceneVariableValueChangedEvent, SceneVariables, SplitLayout, TestVariable, TextBoxVariable, UrlSyncContextProvider, UrlSyncManager, UrlSyncManagerLike, UseStateHookOptions, UserActionEvent, ValidateAndUpdateResult, VariableCustomFormatterFn, VariableDependencyConfig, VariableGetOptionsArgs, VariableValue, VariableValueControl, VariableValueOption, VariableValueSelectWrapper, VariableValueSelectors, VariableValueSingle, VizConfig, VizConfigBuilder, VizConfigBuilders, VizPanel, VizPanelBuilder, VizPanelMenu, VizPanelState, index$1 as behaviors, index as dataLayers, formatRegistry, isCustomVariableValue, isDataLayer, isDataRequestEnricher, isFiltersRequestEnricher, isSceneObject, registerQueryWithController, registerRuntimeDataSource, renderSelectForVariable, sceneGraph, sceneUtils, useSceneApp, useSceneObjectState, useUrlSync };
2825
+ export { AdHocFiltersVariable, CancelActivationHandler, ConstantVariable, ControlsLabel, ControlsLayout, CustomFormatterVariable, CustomTransformOperator, CustomTransformerDefinition, CustomVariable, CustomVariableValue, DataLayerFilter, DataProviderProxy, DataRequestEnricher, DataSourceVariable, DeepPartial, EmbeddedScene, EmbeddedSceneState, ExtraQueryDataProcessor, ExtraQueryDescriptor, ExtraQueryProvider, FieldConfigBuilder, FieldConfigBuilders, FieldConfigOverridesBuilder, FiltersRequestEnricher, FormatVariable, GroupByVariable, InterpolationFormatParameter, IntervalVariable, LocalValueVariable, MacroVariableConstructor, MultiValueVariable, MultiValueVariableState, NestedScene, NewSceneObjectAddedEvent, PanelBuilders, PanelOptionsBuilders, QueryRunnerState, QueryVariable, RuntimeDataSource, SafeSerializableSceneObject, SceneActivationHandler, SceneApp, SceneAppDrilldownView, SceneAppPage, SceneAppPageLike, SceneAppPageState, SceneAppRoute, SceneByFrameRepeater, SceneByVariableRepeater, SceneCSSGridItem, SceneCSSGridLayout, SceneCanvasText, SceneComponent, SceneComponentProps, SceneControlsSpacer, SceneDataLayerBase, SceneDataLayerControls, SceneDataLayerProvider, SceneDataLayerProviderState, SceneDataLayerSet, SceneDataLayerSetBase, SceneDataNode, SceneDataProvider, SceneDataProviderResult, SceneDataQuery, SceneDataState, SceneDataTransformer, SceneDataTransformerState, SceneDeactivationHandler, SceneDebugger, SceneFlexItem, SceneFlexItemLike, SceneFlexItemState, SceneFlexLayout, SceneGridItem, SceneGridItemLike, SceneGridItemStateLike, SceneGridLayout, SceneGridRow, SceneLayout, SceneLayoutChildOptions, SceneLayoutState, SceneObject, SceneObjectBase, SceneObjectRef, SceneObjectState, SceneObjectStateChangedEvent, SceneObjectStateChangedPayload, SceneObjectUrlSyncConfig, SceneObjectUrlSyncHandler, SceneObjectUrlValue, SceneObjectUrlValues, SceneObjectWithUrlSync, SceneQueryControllerEntry, SceneQueryControllerEntryType, SceneQueryControllerLike, SceneQueryRunner, SceneReactObject, SceneRefreshPicker, SceneRefreshPickerState, SceneRouteMatch, SceneStateChangedHandler, SceneStatelessBehavior, SceneTimePicker, SceneTimeRange, SceneTimeRangeCompare, SceneTimeRangeLike, SceneTimeRangeState, SceneTimeRangeTransformerBase, SceneTimeZoneOverride, SceneToolbarButton, SceneToolbarInput, SceneUrlSyncOptions, SceneVariable, SceneVariableDependencyConfigLike, SceneVariableSet, SceneVariableSetState, SceneVariableState, SceneVariableValueChangedEvent, SceneVariables, SplitLayout, TestVariable, TextBoxVariable, UrlSyncContextProvider, UrlSyncManager, UrlSyncManagerLike, UseStateHookOptions, UserActionEvent, ValidateAndUpdateResult, VariableCustomFormatterFn, VariableDependencyConfig, VariableGetOptionsArgs, VariableValue, VariableValueControl, VariableValueOption, VariableValueSelectWrapper, VariableValueSelectors, VariableValueSingle, VizConfig, VizConfigBuilder, VizConfigBuilders, VizPanel, VizPanelBuilder, VizPanelExploreButton, VizPanelMenu, VizPanelState, index$1 as behaviors, index as dataLayers, formatRegistry, getExploreURL, isCustomVariableValue, isDataLayer, isDataRequestEnricher, isFiltersRequestEnricher, isSceneObject, registerQueryWithController, registerRuntimeDataSource, renderSelectForVariable, sceneGraph, sceneUtils, useSceneApp, useSceneObjectState, useUrlSync };
package/dist/index.js CHANGED
@@ -9978,6 +9978,82 @@ function VizPanelMenuRenderer({ model }) {
9978
9978
  }, renderItems(items));
9979
9979
  }
9980
9980
 
9981
+ async function getExploreURL(data, model, timeRange, transform) {
9982
+ var _a, _b, _c, _d;
9983
+ const targets = (_a = data.request) == null ? void 0 : _a.targets;
9984
+ if (!targets) {
9985
+ return "";
9986
+ }
9987
+ const { from, to } = timeRange;
9988
+ const filters = (_b = data.request) == null ? void 0 : _b.filters;
9989
+ const scopedVars = {
9990
+ __sceneObject: wrapInSafeSerializableSceneObject(model)
9991
+ };
9992
+ const interpolatedQueries = (await Promise.allSettled(
9993
+ targets.map(async (q) => {
9994
+ var _a2;
9995
+ const queryDs = await runtime.getDataSourceSrv().get(q.datasource);
9996
+ return ((_a2 = queryDs.interpolateVariablesInQueries) == null ? void 0 : _a2.call(queryDs, [q], scopedVars != null ? scopedVars : {}, filters)[0]) || q;
9997
+ })
9998
+ )).filter((promise) => promise.status === "fulfilled").map((q) => q.value).map((q) => {
9999
+ var _a2;
10000
+ return (_a2 = transform == null ? void 0 : transform(q)) != null ? _a2 : q;
10001
+ });
10002
+ const queries = interpolatedQueries != null ? interpolatedQueries : [];
10003
+ const datasource = (_d = (_c = queries.find((query) => {
10004
+ var _a2;
10005
+ return !!((_a2 = query.datasource) == null ? void 0 : _a2.uid);
10006
+ })) == null ? void 0 : _c.datasource) == null ? void 0 : _d.uid;
10007
+ if ((queries == null ? void 0 : queries.length) && datasource && from && to) {
10008
+ const left = encodeURIComponent(
10009
+ JSON.stringify({
10010
+ datasource,
10011
+ queries,
10012
+ range: {
10013
+ from,
10014
+ to
10015
+ }
10016
+ })
10017
+ );
10018
+ return `/explore?left=${left}`;
10019
+ }
10020
+ return "";
10021
+ }
10022
+
10023
+ class VizPanelExploreButton extends SceneObjectBase {
10024
+ constructor(options = {}) {
10025
+ super({ options });
10026
+ }
10027
+ }
10028
+ VizPanelExploreButton.Component = VizPanelExploreButtonComponent;
10029
+ function VizPanelExploreButtonComponent({ model }) {
10030
+ const { options } = model.useState();
10031
+ const { data } = sceneGraph.getData(model).useState();
10032
+ const { from, to } = sceneGraph.getTimeRange(model).useState();
10033
+ const { value: exploreLink } = reactUse.useAsync(
10034
+ async () => data ? getExploreURL(data, model, { from, to }, options.transform) : "",
10035
+ [data, model, from, to]
10036
+ );
10037
+ const returnToPrevious = runtime.useReturnToPrevious();
10038
+ if (exploreLink) {
10039
+ return /* @__PURE__ */ React__default["default"].createElement(ui.LinkButton, {
10040
+ key: "explore",
10041
+ icon: "compass",
10042
+ size: "sm",
10043
+ variant: "secondary",
10044
+ href: exploreLink,
10045
+ onClick: () => {
10046
+ var _a;
10047
+ if (options.returnToPrevious) {
10048
+ returnToPrevious(options.returnToPrevious.title, options.returnToPrevious.href);
10049
+ }
10050
+ (_a = options.onClick) == null ? void 0 : _a.call(options);
10051
+ }
10052
+ }, "Explore");
10053
+ }
10054
+ return null;
10055
+ }
10056
+
9981
10057
  const DEFAULT_PANEL_SPAN = 4;
9982
10058
  const GRID_CELL_HEIGHT = 30;
9983
10059
  const GRID_CELL_VMARGIN = 8;
@@ -13575,10 +13651,12 @@ exports.VizConfigBuilder = VizConfigBuilder;
13575
13651
  exports.VizConfigBuilders = VizConfigBuilders;
13576
13652
  exports.VizPanel = VizPanel;
13577
13653
  exports.VizPanelBuilder = VizPanelBuilder;
13654
+ exports.VizPanelExploreButton = VizPanelExploreButton;
13578
13655
  exports.VizPanelMenu = VizPanelMenu;
13579
13656
  exports.behaviors = index$1;
13580
13657
  exports.dataLayers = index;
13581
13658
  exports.formatRegistry = formatRegistry;
13659
+ exports.getExploreURL = getExploreURL;
13582
13660
  exports.isCustomVariableValue = isCustomVariableValue;
13583
13661
  exports.isDataLayer = isDataLayer;
13584
13662
  exports.isDataRequestEnricher = isDataRequestEnricher;