@grafana/scenes 5.24.0--canary.956.11776448023.0 → 5.24.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +17 -0
- package/dist/esm/components/VizPanel/VizPanelExploreButton.js +44 -0
- package/dist/esm/components/VizPanel/VizPanelExploreButton.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/explore.js +47 -0
- package/dist/esm/utils/explore.js.map +1 -0
- package/dist/esm/variables/components/VariableValueSelect.js +4 -4
- package/dist/esm/variables/components/VariableValueSelect.js.map +1 -1
- package/dist/index.d.ts +24 -2
- package/dist/index.js +82 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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,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ObjectUrlSyncConfig } 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';
|
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/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":"
|
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":";;;AASA,eAAsB,aACpB,CAAA,IAAA,EACA,KACA,EAAA,SAAA,EACA,SACiB,EAAA;AAdnB,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAeE,EAAM,MAAA,OAAA,GAAA,CAAU,EAAK,GAAA,IAAA,CAAA,OAAA,KAAL,IAAc,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAA,CAAA;AAC9B,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAO,OAAA,EAAA,CAAA;AAAA,GACT;AAEA,EAAM,MAAA,EAAE,IAAM,EAAA,EAAA,EAAO,GAAA,SAAA,CAAA;AAErB,EAAM,MAAA,OAAA,GAAA,CAAU,EAAK,GAAA,IAAA,CAAA,OAAA,KAAL,IAAc,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAA,CAAA;AAE9B,EAAA,MAAM,UAAyB,GAAA;AAAA,IAC7B,aAAA,EAAe,kCAAkC,KAAK,CAAA;AAAA,GACxD,CAAA;AAEA,EAAM,MAAA,mBAAA,GAAA,CACJ,MAAM,OAAQ,CAAA,UAAA;AAAA,IACZ,O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,GAAA,EAAA,CAAA,GAAA,CAAA;AAEjF,EAAA,IAAA,CAAI,OAAS,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAA,MAAA,KAAU,UAAc,IAAA,IAAA,IAAQ,EAAI,EAAA;AAC/C,IAAA,MAAM,IAAO,GAAA,kBAAA;AAAA,MACX,KAAK,SAAU,CAAA;AAAA,QACb,UAAA;AAAA,QACA,OAAA;AAAA,QACA,KAAO,EAAA;AAAA,UACL,IAAA;AAAA,UACA,EAAA;AAAA,SACF;AAAA,OACD,CAAA;AAAA,KACH,CAAA;AAEA,IAAA,OAAO,CAAiB,cAAA,EAAA,IAAA,CAAA,CAAA,CAAA;AAAA,GAC1B;AACA,EAAO,OAAA,EAAA,CAAA;AACT;;;;"}
|
@@ -54,7 +54,7 @@ function toSelectableValue(value, label) {
|
|
54
54
|
};
|
55
55
|
}
|
56
56
|
function VariableValueSelect({ model }) {
|
57
|
-
const { value, text, key, options, includeAll, isReadOnly, allowCustomValue } = model.useState();
|
57
|
+
const { value, text, key, options, includeAll, isReadOnly, allowCustomValue = true } = model.useState();
|
58
58
|
const [inputValue, setInputValue] = useState("");
|
59
59
|
const [hasCustomValue, setHasCustomValue] = useState(false);
|
60
60
|
const selectValue = toSelectableValue(value, String(text));
|
@@ -86,7 +86,7 @@ function VariableValueSelect({ model }) {
|
|
86
86
|
disabled: isReadOnly,
|
87
87
|
value: selectValue,
|
88
88
|
inputValue,
|
89
|
-
allowCustomValue
|
89
|
+
allowCustomValue,
|
90
90
|
virtualized: true,
|
91
91
|
filterOption: filterNoOp,
|
92
92
|
tabSelectsValue: false,
|
@@ -104,7 +104,7 @@ function VariableValueSelect({ model }) {
|
|
104
104
|
});
|
105
105
|
}
|
106
106
|
function VariableValueSelectMulti({ model }) {
|
107
|
-
const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue } = model.useState();
|
107
|
+
const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue = true } = model.useState();
|
108
108
|
const arrayValue = useMemo(() => isArray(value) ? value : [value], [value]);
|
109
109
|
const [uncommittedValue, setUncommittedValue] = useState(arrayValue);
|
110
110
|
const [inputValue, setInputValue] = useState("");
|
@@ -139,7 +139,7 @@ function VariableValueSelectMulti({ model }) {
|
|
139
139
|
maxVisibleValues: maxVisibleValues != null ? maxVisibleValues : 5,
|
140
140
|
tabSelectsValue: false,
|
141
141
|
virtualized: true,
|
142
|
-
allowCustomValue
|
142
|
+
allowCustomValue,
|
143
143
|
toggleAllOptions: {
|
144
144
|
enabled: true,
|
145
145
|
optionsFilter: filterAll,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"VariableValueSelect.js","sources":["../../../../src/variables/components/VariableValueSelect.tsx"],"sourcesContent":["import { isArray } from 'lodash';\nimport React, { RefCallback, useEffect, useMemo, useState } from 'react';\n\n//@ts-ignore\nimport { Checkbox, InputActionMeta, MultiSelect, Select, ToggleAllState, getSelectStyles, useStyles2, useTheme2 } from '@grafana/ui';\n\nimport { SceneComponentProps } from '../../core/types';\nimport { MultiValueVariable } from '../variants/MultiValueVariable';\nimport { VariableValue, VariableValueSingle } from '../types';\nimport { selectors } from '@grafana/e2e-selectors';\nimport { GrafanaTheme2, SelectableValue } from '@grafana/data';\nimport { css, cx } from '@emotion/css';\nimport { getOptionSearcher } from './getOptionSearcher';\n\nconst filterNoOp = () => true;\n\nconst filterAll = (v: SelectableValue<VariableValueSingle>) => v.value !== '$__all'\n\nconst determineToggleAllState = (\n selectedValues: Array<SelectableValue<VariableValueSingle>>,\n options: Array<SelectableValue<VariableValueSingle>>\n) => {\n if (selectedValues.length === options.filter(filterAll).length) {\n return ToggleAllState.allSelected;\n } else if (\n selectedValues.length === 0 ||\n (selectedValues.length === 1 && selectedValues[0] && selectedValues[0].value === '$__all')\n ) {\n return ToggleAllState.noneSelected;\n } else {\n return ToggleAllState.indeterminate;\n }\n};\n\nexport function toSelectableValue<T>(value: T, label?: string): SelectableValue<T> {\n return {\n value,\n label: label ?? String(value),\n };\n}\n\nexport function VariableValueSelect({ model }: SceneComponentProps<MultiValueVariable>) {\n const { value, text, key, options, includeAll, isReadOnly, allowCustomValue } = model.useState();\n const [inputValue, setInputValue] = useState('');\n const [hasCustomValue, setHasCustomValue] = useState(false);\n const selectValue = toSelectableValue(value, String(text));\n\n const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);\n\n const onInputChange = (value: string, { action }: InputActionMeta) => {\n if (action === 'input-change') {\n setInputValue(value);\n if (model.onSearchChange) {\n model.onSearchChange!(value);\n }\n return value;\n }\n\n return value;\n };\n\n const filteredOptions = optionSearcher(inputValue);\n\n const onOpenMenu = () => {\n if (hasCustomValue) {\n setInputValue(String(text));\n }\n };\n\n const onCloseMenu = () => {\n setInputValue('');\n };\n\n return (\n <Select<VariableValue>\n id={key}\n isValidNewOption={(inputValue) => inputValue.trim().length > 0}\n placeholder=\"Select value\"\n width=\"auto\"\n disabled={isReadOnly}\n value={selectValue}\n inputValue={inputValue}\n allowCustomValue={allowCustomValue ?? true}\n virtualized\n filterOption={filterNoOp}\n tabSelectsValue={false}\n onInputChange={onInputChange}\n onOpenMenu={onOpenMenu}\n onCloseMenu={onCloseMenu}\n options={filteredOptions}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`)}\n onChange={(newValue) => {\n model.changeValueTo(newValue.value!, newValue.label!);\n\n if (hasCustomValue !== newValue.__isNew__) {\n setHasCustomValue(newValue.__isNew__);\n }\n }}\n />\n );\n}\n\nexport function VariableValueSelectMulti({ model }: SceneComponentProps<MultiValueVariable>) {\n const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue } = model.useState();\n const arrayValue = useMemo(() => (isArray(value) ? value : [value]), [value]);\n // To not trigger queries on every selection we store this state locally here and only update the variable onBlur\n const [uncommittedValue, setUncommittedValue] = useState(arrayValue);\n const [inputValue, setInputValue] = useState('');\n\n const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);\n\n // Detect value changes outside\n useEffect(() => {\n setUncommittedValue(arrayValue);\n }, [arrayValue]);\n\n const onInputChange = (value: string, { action }: InputActionMeta) => {\n if (action === 'input-change') {\n setInputValue(value);\n if (model.onSearchChange) {\n model.onSearchChange!(value);\n }\n return value;\n }\n\n if (action === 'input-blur') {\n setInputValue('');\n return '';\n }\n\n return inputValue;\n };\n\n const placeholder = options.length > 0 ? 'Select value' : '';\n const filteredOptions = optionSearcher(inputValue);\n\n return (\n <MultiSelect<VariableValueSingle>\n id={key}\n placeholder={placeholder}\n width=\"auto\"\n inputValue={inputValue}\n disabled={isReadOnly}\n value={uncommittedValue}\n noMultiValueWrap={true}\n maxVisibleValues={maxVisibleValues ?? 5}\n tabSelectsValue={false}\n virtualized\n allowCustomValue={allowCustomValue ?? true}\n //@ts-ignore\n toggleAllOptions={{\n enabled: true,\n optionsFilter: filterAll,\n determineToggleAllState: determineToggleAllState,\n }}\n options={filteredOptions}\n closeMenuOnSelect={false}\n components={{ Option: OptionWithCheckbox }}\n isClearable={true}\n hideSelectedOptions={false}\n onInputChange={onInputChange}\n onBlur={() => {\n model.changeValueTo(uncommittedValue);\n }}\n filterOption={filterNoOp}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`)}\n onChange={(newValue, action) => {\n if (action.action === 'clear' && noValueOnClear) {\n model.changeValueTo([]);\n }\n setUncommittedValue(newValue.map((x) => x.value!));\n }}\n />\n );\n}\n\ninterface SelectMenuOptionProps<T> {\n isDisabled: boolean;\n isFocused: boolean;\n isSelected: boolean;\n innerProps: JSX.IntrinsicElements['div'];\n innerRef: RefCallback<HTMLDivElement>;\n renderOptionLabel?: (value: SelectableValue<T>) => JSX.Element;\n data: SelectableValue<T>;\n indeterminate: boolean; \n}\n\nexport const OptionWithCheckbox = ({\n children,\n data,\n innerProps,\n innerRef,\n isFocused,\n isSelected,\n indeterminate,\n renderOptionLabel,\n}: React.PropsWithChildren<SelectMenuOptionProps<unknown>>) => {\n // We are removing onMouseMove and onMouseOver from innerProps because they cause the whole\n // list to re-render everytime the user hovers over an option. This is a performance issue.\n // See https://github.com/JedWatson/react-select/issues/3128#issuecomment-451936743\n const { onMouseMove, onMouseOver, ...rest } = innerProps;\n const theme = useTheme2();\n const selectStyles = getSelectStyles(theme);\n const optionStyles = useStyles2(getOptionStyles);\n\n return (\n <div\n ref={innerRef}\n className={cx(selectStyles.option, isFocused && selectStyles.optionFocused)}\n {...rest}\n // TODO: use below selector once we update grafana dependencies to ^11.1.0\n // data-testid={selectors.components.Select.option}\n data-testid=\"data-testid Select option\"\n title={data.title}\n >\n <div className={optionStyles.checkbox}>\n <Checkbox indeterminate={indeterminate} value={isSelected} />\n </div>\n <div\n className={selectStyles.optionBody}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts(\n data.label ?? String(data.value)\n )}\n >\n <span>{children}</span>\n </div>\n </div>\n );\n};\n\nOptionWithCheckbox.displayName = 'SelectMenuOptions';\n\nconst getOptionStyles = (theme: GrafanaTheme2) => ({\n checkbox: css({\n marginRight: theme.spacing(2),\n }),\n});\n\nexport function renderSelectForVariable(model: MultiValueVariable) {\n if (model.state.isMulti) {\n return <VariableValueSelectMulti model={model} />;\n } else {\n return <VariableValueSelect model={model} />;\n }\n}\n"],"names":["value","inputValue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,aAAa,MAAM,IAAA,CAAA;AAEzB,MAAM,SAAY,GAAA,CAAC,CAA4C,KAAA,CAAA,CAAE,KAAU,KAAA,QAAA,CAAA;AAE3E,MAAM,uBAAA,GAA0B,CAC9B,cAAA,EACA,OACG,KAAA;AACH,EAAA,IAAI,eAAe,MAAW,KAAA,OAAA,CAAQ,MAAO,CAAA,SAAS,EAAE,MAAQ,EAAA;AAC9D,IAAA,OAAO,cAAe,CAAA,WAAA,CAAA;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.tsx"],"sourcesContent":["import { isArray } from 'lodash';\nimport React, { RefCallback, useEffect, useMemo, useState } from 'react';\n\n//@ts-ignore\nimport { Checkbox, InputActionMeta, MultiSelect, Select, ToggleAllState, getSelectStyles, useStyles2, useTheme2 } from '@grafana/ui';\n\nimport { SceneComponentProps } from '../../core/types';\nimport { MultiValueVariable } from '../variants/MultiValueVariable';\nimport { VariableValue, VariableValueSingle } from '../types';\nimport { selectors } from '@grafana/e2e-selectors';\nimport { GrafanaTheme2, SelectableValue } from '@grafana/data';\nimport { css, cx } from '@emotion/css';\nimport { getOptionSearcher } from './getOptionSearcher';\n\nconst filterNoOp = () => true;\n\nconst filterAll = (v: SelectableValue<VariableValueSingle>) => v.value !== '$__all'\n\nconst determineToggleAllState = (\n selectedValues: Array<SelectableValue<VariableValueSingle>>,\n options: Array<SelectableValue<VariableValueSingle>>\n) => {\n if (selectedValues.length === options.filter(filterAll).length) {\n return ToggleAllState.allSelected;\n } else if (\n selectedValues.length === 0 ||\n (selectedValues.length === 1 && selectedValues[0] && selectedValues[0].value === '$__all')\n ) {\n return ToggleAllState.noneSelected;\n } else {\n return ToggleAllState.indeterminate;\n }\n};\n\nexport function toSelectableValue<T>(value: T, label?: string): SelectableValue<T> {\n return {\n value,\n label: label ?? String(value),\n };\n}\n\nexport function VariableValueSelect({ model }: SceneComponentProps<MultiValueVariable>) {\n const { value, text, key, options, includeAll, isReadOnly, allowCustomValue = true } = model.useState();\n const [inputValue, setInputValue] = useState('');\n const [hasCustomValue, setHasCustomValue] = useState(false);\n const selectValue = toSelectableValue(value, String(text));\n\n const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);\n\n const onInputChange = (value: string, { action }: InputActionMeta) => {\n if (action === 'input-change') {\n setInputValue(value);\n if (model.onSearchChange) {\n model.onSearchChange!(value);\n }\n return value;\n }\n\n return value;\n };\n\n const filteredOptions = optionSearcher(inputValue);\n\n const onOpenMenu = () => {\n if (hasCustomValue) {\n setInputValue(String(text));\n }\n };\n\n const onCloseMenu = () => {\n setInputValue('');\n };\n\n return (\n <Select<VariableValue>\n id={key}\n isValidNewOption={(inputValue) => inputValue.trim().length > 0}\n placeholder=\"Select value\"\n width=\"auto\"\n disabled={isReadOnly}\n value={selectValue}\n inputValue={inputValue}\n allowCustomValue={allowCustomValue}\n virtualized\n filterOption={filterNoOp}\n tabSelectsValue={false}\n onInputChange={onInputChange}\n onOpenMenu={onOpenMenu}\n onCloseMenu={onCloseMenu}\n options={filteredOptions}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`)}\n onChange={(newValue) => {\n model.changeValueTo(newValue.value!, newValue.label!);\n\n if (hasCustomValue !== newValue.__isNew__) {\n setHasCustomValue(newValue.__isNew__);\n }\n }}\n />\n );\n}\n\nexport function VariableValueSelectMulti({ model }: SceneComponentProps<MultiValueVariable>) {\n const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue = true } = model.useState();\n const arrayValue = useMemo(() => (isArray(value) ? value : [value]), [value]);\n // To not trigger queries on every selection we store this state locally here and only update the variable onBlur\n const [uncommittedValue, setUncommittedValue] = useState(arrayValue);\n const [inputValue, setInputValue] = useState('');\n\n const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);\n\n // Detect value changes outside\n useEffect(() => {\n setUncommittedValue(arrayValue);\n }, [arrayValue]);\n\n const onInputChange = (value: string, { action }: InputActionMeta) => {\n if (action === 'input-change') {\n setInputValue(value);\n if (model.onSearchChange) {\n model.onSearchChange!(value);\n }\n return value;\n }\n\n if (action === 'input-blur') {\n setInputValue('');\n return '';\n }\n\n return inputValue;\n };\n\n const placeholder = options.length > 0 ? 'Select value' : '';\n const filteredOptions = optionSearcher(inputValue);\n\n return (\n <MultiSelect<VariableValueSingle>\n id={key}\n placeholder={placeholder}\n width=\"auto\"\n inputValue={inputValue}\n disabled={isReadOnly}\n value={uncommittedValue}\n noMultiValueWrap={true}\n maxVisibleValues={maxVisibleValues ?? 5}\n tabSelectsValue={false}\n virtualized\n allowCustomValue={allowCustomValue}\n //@ts-ignore\n toggleAllOptions={{\n enabled: true,\n optionsFilter: filterAll,\n determineToggleAllState: determineToggleAllState,\n }}\n options={filteredOptions}\n closeMenuOnSelect={false}\n components={{ Option: OptionWithCheckbox }}\n isClearable={true}\n hideSelectedOptions={false}\n onInputChange={onInputChange}\n onBlur={() => {\n model.changeValueTo(uncommittedValue);\n }}\n filterOption={filterNoOp}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`)}\n onChange={(newValue, action) => {\n if (action.action === 'clear' && noValueOnClear) {\n model.changeValueTo([]);\n }\n setUncommittedValue(newValue.map((x) => x.value!));\n }}\n />\n );\n}\n\ninterface SelectMenuOptionProps<T> {\n isDisabled: boolean;\n isFocused: boolean;\n isSelected: boolean;\n innerProps: JSX.IntrinsicElements['div'];\n innerRef: RefCallback<HTMLDivElement>;\n renderOptionLabel?: (value: SelectableValue<T>) => JSX.Element;\n data: SelectableValue<T>;\n indeterminate: boolean; \n}\n\nexport const OptionWithCheckbox = ({\n children,\n data,\n innerProps,\n innerRef,\n isFocused,\n isSelected,\n indeterminate,\n renderOptionLabel,\n}: React.PropsWithChildren<SelectMenuOptionProps<unknown>>) => {\n // We are removing onMouseMove and onMouseOver from innerProps because they cause the whole\n // list to re-render everytime the user hovers over an option. This is a performance issue.\n // See https://github.com/JedWatson/react-select/issues/3128#issuecomment-451936743\n const { onMouseMove, onMouseOver, ...rest } = innerProps;\n const theme = useTheme2();\n const selectStyles = getSelectStyles(theme);\n const optionStyles = useStyles2(getOptionStyles);\n\n return (\n <div\n ref={innerRef}\n className={cx(selectStyles.option, isFocused && selectStyles.optionFocused)}\n {...rest}\n // TODO: use below selector once we update grafana dependencies to ^11.1.0\n // data-testid={selectors.components.Select.option}\n data-testid=\"data-testid Select option\"\n title={data.title}\n >\n <div className={optionStyles.checkbox}>\n <Checkbox indeterminate={indeterminate} value={isSelected} />\n </div>\n <div\n className={selectStyles.optionBody}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts(\n data.label ?? String(data.value)\n )}\n >\n <span>{children}</span>\n </div>\n </div>\n );\n};\n\nOptionWithCheckbox.displayName = 'SelectMenuOptions';\n\nconst getOptionStyles = (theme: GrafanaTheme2) => ({\n checkbox: css({\n marginRight: theme.spacing(2),\n }),\n});\n\nexport function renderSelectForVariable(model: MultiValueVariable) {\n if (model.state.isMulti) {\n return <VariableValueSelectMulti model={model} />;\n } else {\n return <VariableValueSelect model={model} />;\n }\n}\n"],"names":["value","inputValue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,aAAa,MAAM,IAAA,CAAA;AAEzB,MAAM,SAAY,GAAA,CAAC,CAA4C,KAAA,CAAA,CAAE,KAAU,KAAA,QAAA,CAAA;AAE3E,MAAM,uBAAA,GAA0B,CAC9B,cAAA,EACA,OACG,KAAA;AACH,EAAA,IAAI,eAAe,MAAW,KAAA,OAAA,CAAQ,MAAO,CAAA,SAAS,EAAE,MAAQ,EAAA;AAC9D,IAAA,OAAO,cAAe,CAAA,WAAA,CAAA;AAAA,GAEtB,MAAA,IAAA,cAAA,CAAe,MAAW,KAAA,CAAA,IACzB,cAAe,CAAA,MAAA,KAAW,CAAK,IAAA,cAAA,CAAe,CAAM,CAAA,IAAA,cAAA,CAAe,CAAG,CAAA,CAAA,KAAA,KAAU,QACjF,EAAA;AACA,IAAA,OAAO,cAAe,CAAA,YAAA,CAAA;AAAA,GACjB,MAAA;AACL,IAAA,OAAO,cAAe,CAAA,aAAA,CAAA;AAAA,GACxB;AACF,CAAA,CAAA;AAEgB,SAAA,iBAAA,CAAqB,OAAU,KAAoC,EAAA;AACjF,EAAO,OAAA;AAAA,IACL,KAAA;AAAA,IACA,KAAA,EAAO,KAAS,IAAA,IAAA,GAAA,KAAA,GAAA,MAAA,CAAO,KAAK,CAAA;AA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AAA,MAAA,EAAA,IAAA,EAAM,QAAS,CAClB,CACF,CAAA,CAAA;AAEJ,EAAA;AAEA,kBAAA,CAAmB,WAAc,GAAA,mBAAA,CAAA;AAEjC,MAAM,eAAA,GAAkB,CAAC,KAA0B,MAAA;AAAA,EACjD,UAAU,GAAI,CAAA;AAAA,IACZ,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,GAC7B,CAAA;AACH,CAAA,CAAA,CAAA;AAEO,SAAS,wBAAwB,KAA2B,EAAA;AACjE,EAAI,IAAA,KAAA,CAAM,MAAM,OAAS,EAAA;AACvB,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,wBAAA,EAAA;AAAA,MAAyB,KAAA;AAAA,KAAc,CAAA,CAAA;AAAA,GAC1C,MAAA;AACL,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,mBAAA,EAAA;AAAA,MAAoB,KAAA;AAAA,KAAc,CAAA,CAAA;AAAA,GAC5C;AACF;;;;"}
|
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
@@ -2596,7 +2596,7 @@ function toSelectableValue$2(value, label) {
|
|
2596
2596
|
};
|
2597
2597
|
}
|
2598
2598
|
function VariableValueSelect({ model }) {
|
2599
|
-
const { value, text, key, options, includeAll, isReadOnly, allowCustomValue } = model.useState();
|
2599
|
+
const { value, text, key, options, includeAll, isReadOnly, allowCustomValue = true } = model.useState();
|
2600
2600
|
const [inputValue, setInputValue] = React.useState("");
|
2601
2601
|
const [hasCustomValue, setHasCustomValue] = React.useState(false);
|
2602
2602
|
const selectValue = toSelectableValue$2(value, String(text));
|
@@ -2628,7 +2628,7 @@ function VariableValueSelect({ model }) {
|
|
2628
2628
|
disabled: isReadOnly,
|
2629
2629
|
value: selectValue,
|
2630
2630
|
inputValue,
|
2631
|
-
allowCustomValue
|
2631
|
+
allowCustomValue,
|
2632
2632
|
virtualized: true,
|
2633
2633
|
filterOption: filterNoOp$2,
|
2634
2634
|
tabSelectsValue: false,
|
@@ -2646,7 +2646,7 @@ function VariableValueSelect({ model }) {
|
|
2646
2646
|
});
|
2647
2647
|
}
|
2648
2648
|
function VariableValueSelectMulti({ model }) {
|
2649
|
-
const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue } = model.useState();
|
2649
|
+
const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue = true } = model.useState();
|
2650
2650
|
const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
|
2651
2651
|
const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
|
2652
2652
|
const [inputValue, setInputValue] = React.useState("");
|
@@ -2681,7 +2681,7 @@ function VariableValueSelectMulti({ model }) {
|
|
2681
2681
|
maxVisibleValues: maxVisibleValues != null ? maxVisibleValues : 5,
|
2682
2682
|
tabSelectsValue: false,
|
2683
2683
|
virtualized: true,
|
2684
|
-
allowCustomValue
|
2684
|
+
allowCustomValue,
|
2685
2685
|
toggleAllOptions: {
|
2686
2686
|
enabled: true,
|
2687
2687
|
optionsFilter: filterAll,
|
@@ -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;
|