@grafana/scenes 6.11.1 → 6.12.0--canary.1121.15045230319.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -12
- package/dist/esm/components/SceneApp/SceneApp.js +2 -2
- package/dist/esm/components/SceneApp/SceneApp.js.map +1 -1
- package/dist/esm/components/SceneApp/SceneAppPage.js +2 -18
- package/dist/esm/components/SceneApp/SceneAppPage.js.map +1 -1
- package/dist/esm/components/VizPanel/VizPanel.js +2 -2
- package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
- package/dist/esm/core/sceneGraph/index.js +2 -2
- package/dist/esm/core/sceneGraph/index.js.map +1 -1
- package/dist/esm/core/sceneGraph/sceneGraph.js +9 -5
- package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/querying/SceneQueryRunner.js +10 -33
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
- package/dist/esm/variables/VariableDependencyConfig.js +4 -1
- package/dist/esm/variables/VariableDependencyConfig.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +19 -18
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
- package/dist/esm/variables/components/VariableValueSelectors.js +3 -0
- package/dist/esm/variables/components/VariableValueSelectors.js.map +1 -1
- package/dist/esm/variables/constants.js +2 -1
- package/dist/esm/variables/constants.js.map +1 -1
- package/dist/esm/variables/groupby/GroupByVariable.js +2 -2
- package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
- package/dist/esm/variables/sets/SceneVariableSet.js +10 -7
- package/dist/esm/variables/sets/SceneVariableSet.js.map +1 -1
- package/dist/esm/variables/types.js.map +1 -1
- package/dist/esm/variables/variants/ScopesVariable.js +80 -0
- package/dist/esm/variables/variants/ScopesVariable.js.map +1 -0
- package/dist/index.d.ts +56 -53
- package/dist/index.js +112 -151
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/core/SceneScopesBridge.js +0 -93
- package/dist/esm/core/SceneScopesBridge.js.map +0 -1
@@ -0,0 +1,80 @@
|
|
1
|
+
import { SceneObjectBase } from '../../core/SceneObjectBase.js';
|
2
|
+
import { SceneVariableValueChangedEvent } from '../types.js';
|
3
|
+
import { ScopesContext } from '@grafana/runtime';
|
4
|
+
import React, { useContext, useEffect } from 'react';
|
5
|
+
import { VariableHide } from '@grafana/schema';
|
6
|
+
import { SCOPES_VARIABLE_NAME } from '../constants.js';
|
7
|
+
|
8
|
+
class ScopesVariable extends SceneObjectBase {
|
9
|
+
constructor(state) {
|
10
|
+
super({
|
11
|
+
skipUrlSync: true,
|
12
|
+
loading: true,
|
13
|
+
scopes: [],
|
14
|
+
...state,
|
15
|
+
type: "system",
|
16
|
+
name: SCOPES_VARIABLE_NAME,
|
17
|
+
hide: VariableHide.hideVariable
|
18
|
+
});
|
19
|
+
this._renderBeforeActivation = true;
|
20
|
+
}
|
21
|
+
/**
|
22
|
+
* Temporary simple implementation to stringify the scopes.
|
23
|
+
*/
|
24
|
+
getValue(fieldPath) {
|
25
|
+
var _a;
|
26
|
+
const scopes = (_a = this.state.scopes) != null ? _a : [];
|
27
|
+
const scopeNames = scopes.map((scope) => scope.metadata.name);
|
28
|
+
return scopeNames.join(", ");
|
29
|
+
}
|
30
|
+
getScopes() {
|
31
|
+
return this.state.scopes;
|
32
|
+
}
|
33
|
+
/**
|
34
|
+
* This method is used to keep the context up to date with the scopes context received from React
|
35
|
+
* 1) Subscribes to ScopesContext state changes and synchronizes it with the variable state
|
36
|
+
* 2) Handles enable / disabling of scopes based on variable enable option.
|
37
|
+
*/
|
38
|
+
setContext(context) {
|
39
|
+
if (!context) {
|
40
|
+
return;
|
41
|
+
}
|
42
|
+
this._context = context;
|
43
|
+
const oldState = context.state;
|
44
|
+
if (this.state.enable != null) {
|
45
|
+
context.setEnabled(this.state.enable);
|
46
|
+
}
|
47
|
+
const sub = context.stateObservable.subscribe((state) => {
|
48
|
+
this.updateStateFromContext(state);
|
49
|
+
});
|
50
|
+
return () => {
|
51
|
+
sub.unsubscribe();
|
52
|
+
if (this.state.enable != null) {
|
53
|
+
context.setEnabled(oldState.enabled);
|
54
|
+
}
|
55
|
+
};
|
56
|
+
}
|
57
|
+
updateStateFromContext(state) {
|
58
|
+
const loading = state.value.length === 0 ? false : state.loading;
|
59
|
+
this.setState({ scopes: state.value, loading });
|
60
|
+
if (!loading) {
|
61
|
+
this.publishEvent(new SceneVariableValueChangedEvent(this), true);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
/**
|
65
|
+
* Special function that enables variables to be hidden but still render to access react contexts
|
66
|
+
*/
|
67
|
+
hiddenRender() {
|
68
|
+
return /* @__PURE__ */ React.createElement(ScopesVariableRenderer, { model: this });
|
69
|
+
}
|
70
|
+
}
|
71
|
+
function ScopesVariableRenderer({ model }) {
|
72
|
+
const context = useContext(ScopesContext);
|
73
|
+
useEffect(() => {
|
74
|
+
return model.setContext(context);
|
75
|
+
}, [context, model]);
|
76
|
+
return null;
|
77
|
+
}
|
78
|
+
|
79
|
+
export { ScopesVariable };
|
80
|
+
//# sourceMappingURL=ScopesVariable.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ScopesVariable.js","sources":["../../../../src/variables/variants/ScopesVariable.tsx"],"sourcesContent":["import { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneVariable, SceneVariableState, SceneVariableValueChangedEvent, VariableValue } from '../types';\nimport { Scope } from '@grafana/data';\nimport { SceneComponentProps } from '../../core/types';\nimport { ScopesContext, ScopesContextValue } from '@grafana/runtime';\nimport React, { ReactNode, useContext, useEffect } from 'react';\nimport { VariableHide } from '@grafana/schema';\nimport { SCOPES_VARIABLE_NAME } from '../constants';\n\nexport interface ScopesVariableState extends SceneVariableState {\n /**\n * Last captured state from ScopesContext\n */\n scopes: Scope[];\n /**\n * Set to true if you want to the variable to enable / disable scopes when activated / deactivated\n */\n enable?: boolean;\n}\n\nexport class ScopesVariable extends SceneObjectBase<ScopesVariableState> implements SceneVariable<ScopesVariableState> {\n protected _renderBeforeActivation = true;\n protected _context: ScopesContextValue | undefined;\n\n public constructor(state: Partial<ScopesVariableState>) {\n super({\n skipUrlSync: true,\n loading: true,\n scopes: [],\n ...state,\n type: 'system',\n name: SCOPES_VARIABLE_NAME,\n hide: VariableHide.hideVariable,\n });\n }\n\n /**\n * Temporary simple implementation to stringify the scopes.\n */\n public getValue(fieldPath: string): VariableValue {\n const scopes = this.state.scopes ?? [];\n const scopeNames = scopes.map((scope) => scope.metadata.name);\n return scopeNames.join(', ');\n }\n\n public getScopes(): Scope[] | undefined {\n return this.state.scopes;\n }\n\n /**\n * This method is used to keep the context up to date with the scopes context received from React\n * 1) Subscribes to ScopesContext state changes and synchronizes it with the variable state\n * 2) Handles enable / disabling of scopes based on variable enable option.\n */\n public setContext(context: ScopesContextValue | undefined) {\n if (!context) {\n return;\n }\n\n this._context = context;\n\n const oldState = context.state;\n\n // Update scopes enable state if state.enable is defined\n if (this.state.enable != null) {\n context.setEnabled(this.state.enable);\n }\n\n // Subscribe to context state changes\n const sub = context.stateObservable.subscribe((state) => {\n this.updateStateFromContext(state);\n });\n\n return () => {\n sub.unsubscribe();\n\n if (this.state.enable != null) {\n context.setEnabled(oldState.enabled);\n }\n };\n }\n\n public updateStateFromContext(state: { loading: boolean; value: Scope[] }) {\n // There was logic in SceneQueryRunner that said if there are no scopes then loading state should not block query execution\n const loading = state.value.length === 0 ? false : state.loading;\n this.setState({ scopes: state.value, loading });\n\n if (!loading) {\n this.publishEvent(new SceneVariableValueChangedEvent(this), true);\n }\n }\n\n /**\n * Special function that enables variables to be hidden but still render to access react contexts\n */\n public hiddenRender(): ReactNode {\n return <ScopesVariableRenderer model={this} />;\n }\n}\n\nfunction ScopesVariableRenderer({ model }: SceneComponentProps<ScopesVariable>) {\n const context = useContext(ScopesContext);\n\n useEffect(() => {\n return model.setContext(context);\n }, [context, model]);\n\n return null;\n}\n"],"names":[],"mappings":";;;;;;;AAoBO,MAAM,uBAAuB,eAAmF,CAAA;AAAA,EAI9G,YAAY,KAAqC,EAAA;AACtD,IAAM,KAAA,CAAA;AAAA,MACJ,WAAa,EAAA,IAAA;AAAA,MACb,OAAS,EAAA,IAAA;AAAA,MACT,QAAQ,EAAC;AAAA,MACT,GAAG,KAAA;AAAA,MACH,IAAM,EAAA,QAAA;AAAA,MACN,IAAM,EAAA,oBAAA;AAAA,MACN,MAAM,YAAa,CAAA;AAAA,KACpB,CAAA;AAZH,IAAA,IAAA,CAAU,uBAA0B,GAAA,IAAA;AAAA;AAapC;AAAA;AAAA;AAAA,EAKO,SAAS,SAAkC,EAAA;AAvCpD,IAAA,IAAA,EAAA;AAwCI,IAAA,MAAM,MAAS,GAAA,CAAA,EAAA,GAAA,IAAA,CAAK,KAAM,CAAA,MAAA,KAAX,YAAqB,EAAC;AACrC,IAAA,MAAM,aAAa,MAAO,CAAA,GAAA,CAAI,CAAC,KAAU,KAAA,KAAA,CAAM,SAAS,IAAI,CAAA;AAC5D,IAAO,OAAA,UAAA,CAAW,KAAK,IAAI,CAAA;AAAA;AAC7B,EAEO,SAAiC,GAAA;AACtC,IAAA,OAAO,KAAK,KAAM,CAAA,MAAA;AAAA;AACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,WAAW,OAAyC,EAAA;AACzD,IAAA,IAAI,CAAC,OAAS,EAAA;AACZ,MAAA;AAAA;AAGF,IAAA,IAAA,CAAK,QAAW,GAAA,OAAA;AAEhB,IAAA,MAAM,WAAW,OAAQ,CAAA,KAAA;AAGzB,IAAI,IAAA,IAAA,CAAK,KAAM,CAAA,MAAA,IAAU,IAAM,EAAA;AAC7B,MAAQ,OAAA,CAAA,UAAA,CAAW,IAAK,CAAA,KAAA,CAAM,MAAM,CAAA;AAAA;AAItC,IAAA,MAAM,GAAM,GAAA,OAAA,CAAQ,eAAgB,CAAA,SAAA,CAAU,CAAC,KAAU,KAAA;AACvD,MAAA,IAAA,CAAK,uBAAuB,KAAK,CAAA;AAAA,KAClC,CAAA;AAED,IAAA,OAAO,MAAM;AACX,MAAA,GAAA,CAAI,WAAY,EAAA;AAEhB,MAAI,IAAA,IAAA,CAAK,KAAM,CAAA,MAAA,IAAU,IAAM,EAAA;AAC7B,QAAQ,OAAA,CAAA,UAAA,CAAW,SAAS,OAAO,CAAA;AAAA;AACrC,KACF;AAAA;AACF,EAEO,uBAAuB,KAA6C,EAAA;AAEzE,IAAA,MAAM,UAAU,KAAM,CAAA,KAAA,CAAM,MAAW,KAAA,CAAA,GAAI,QAAQ,KAAM,CAAA,OAAA;AACzD,IAAA,IAAA,CAAK,SAAS,EAAE,MAAA,EAAQ,KAAM,CAAA,KAAA,EAAO,SAAS,CAAA;AAE9C,IAAA,IAAI,CAAC,OAAS,EAAA;AACZ,MAAA,IAAA,CAAK,YAAa,CAAA,IAAI,8BAA+B,CAAA,IAAI,GAAG,IAAI,CAAA;AAAA;AAClE;AACF;AAAA;AAAA;AAAA,EAKO,YAA0B,GAAA;AAC/B,IAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,sBAAuB,EAAA,EAAA,KAAA,EAAO,IAAM,EAAA,CAAA;AAAA;AAEhD;AAEA,SAAS,sBAAA,CAAuB,EAAE,KAAA,EAA8C,EAAA;AAC9E,EAAM,MAAA,OAAA,GAAU,WAAW,aAAa,CAAA;AAExC,EAAA,SAAA,CAAU,MAAM;AACd,IAAO,OAAA,KAAA,CAAM,WAAW,OAAO,CAAA;AAAA,GAC9B,EAAA,CAAC,OAAS,EAAA,KAAK,CAAC,CAAA;AAEnB,EAAO,OAAA,IAAA;AACT;;;;"}
|
package/dist/index.d.ts
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
import * as _grafana_data from '@grafana/data';
|
2
|
-
import { BusEventWithPayload, EventBus, BusEvent, BusEventType, BusEventHandler, PanelMenuItem, FieldConfigSource, PanelPlugin, AbsoluteTimeRange, PanelData, InterpolateFunction, PanelModel, TimeRange, DataTransformContext, DataFrame, DataQueryRequest, DataSourceGetTagKeysOptions, DataSourceGetTagValuesOptions,
|
2
|
+
import { BusEventWithPayload, EventBus, BusEvent, BusEventType, BusEventHandler, PanelMenuItem, FieldConfigSource, PanelPlugin, AbsoluteTimeRange, PanelData, InterpolateFunction, PanelModel, TimeRange, DataTransformContext, DataFrame, DataQueryRequest, DataSourceGetTagKeysOptions, DataSourceGetTagValuesOptions, IconName, PageLayoutType, UrlQueryMap, DataQuery as DataQuery$1, DataSourceApi, Registry, RegistryItem, ScopedVars, AdHocVariableFilter, GetTagResponse, MetricFindValue, SelectableValue, VariableRefresh as VariableRefresh$1, VariableSort, Scope, EventFilterOptions, AnnotationEvent, AnnotationQuery, DataTransformerConfig, TimeOption, FieldConfig, FieldType, FieldValueMatcherConfig, ScopedVar, RawTimeRange } from '@grafana/data';
|
3
3
|
import * as React$1 from 'react';
|
4
|
-
import React__default, { ComponentType, CSSProperties, PointerEvent, ForwardRefExoticComponent } from 'react';
|
4
|
+
import React__default, { ComponentType, ReactNode, CSSProperties, PointerEvent, ForwardRefExoticComponent } from 'react';
|
5
5
|
import * as rxjs from 'rxjs';
|
6
6
|
import { Observable, Subscription, Unsubscribable, MonoTypeOperatorFunction, ReplaySubject } from 'rxjs';
|
7
7
|
import * as _grafana_schema from '@grafana/schema';
|
8
8
|
import { VariableType, VariableHide, TimeZone, DataQuery, DataTopic, DataSourceRef, VariableRefresh, LoadingState, DashboardCursorSync, MatcherConfig, TableFieldOptions } from '@grafana/schema';
|
9
9
|
import { PanelContext, WeekStart, IconName as IconName$1 } from '@grafana/ui';
|
10
|
-
import {
|
10
|
+
import { LocationService, VariableInterpolation, ScopesContextValue } from '@grafana/runtime';
|
11
11
|
import { Location } from 'history';
|
12
12
|
import ReactGridLayout from 'react-grid-layout';
|
13
13
|
import { Options, FieldConfig as FieldConfig$1 } from '@grafana/schema/dist/esm/raw/composable/barchart/panelcfg/x/BarChartPanelCfg_types.gen';
|
@@ -63,6 +63,10 @@ interface SceneVariable<TState extends SceneVariableState = SceneVariableState>
|
|
63
63
|
* Allows cancelling variable execution.
|
64
64
|
*/
|
65
65
|
onCancel?(): void;
|
66
|
+
/**
|
67
|
+
* Edge case for variables that is hidden but wants to be render to access react contexts (ScopesVariable)
|
68
|
+
*/
|
69
|
+
hiddenRender?(): React.ReactNode;
|
66
70
|
/**
|
67
71
|
* @experimental
|
68
72
|
* Indicates that a variable loads values lazily when user interacts with the variable dropdown.
|
@@ -275,6 +279,10 @@ interface VariableDependencyConfigOptions<TState extends SceneObjectState> {
|
|
275
279
|
* Handle time macros.
|
276
280
|
*/
|
277
281
|
handleTimeMacros?: boolean;
|
282
|
+
/**
|
283
|
+
* Depends on scopes
|
284
|
+
*/
|
285
|
+
dependsOnScopes?: boolean;
|
278
286
|
}
|
279
287
|
declare class VariableDependencyConfig<TState extends SceneObjectState> implements SceneVariableDependencyConfigLike {
|
280
288
|
private _sceneObject;
|
@@ -366,7 +374,7 @@ interface VizPanelState<TOptions = {}, TFieldConfig = {}> extends SceneObjectSta
|
|
366
374
|
}
|
367
375
|
declare class VizPanel<TOptions = {}, TFieldConfig extends {} = {}> extends SceneObjectBase<VizPanelState<TOptions, TFieldConfig>> {
|
368
376
|
static Component: typeof VizPanelRenderer;
|
369
|
-
protected _variableDependency: VariableDependencyConfig<VizPanelState<
|
377
|
+
protected _variableDependency: VariableDependencyConfig<VizPanelState<TOptions, TFieldConfig>>;
|
370
378
|
protected _panelContext?: PanelContext;
|
371
379
|
private _plugin?;
|
372
380
|
private _prevData?;
|
@@ -406,7 +414,7 @@ declare class VizPanel<TOptions = {}, TFieldConfig extends {} = {}> extends Scen
|
|
406
414
|
private _onSeriesVisibilityChange;
|
407
415
|
private _onInstanceStateChange;
|
408
416
|
private _onToggleLegendSort;
|
409
|
-
clone(
|
417
|
+
clone(): this;
|
410
418
|
private buildPanelContext;
|
411
419
|
}
|
412
420
|
|
@@ -651,36 +659,6 @@ declare class EmbeddedScene extends SceneObjectBase<EmbeddedSceneState> {
|
|
651
659
|
}
|
652
660
|
declare function EmbeddedSceneRenderer({ model }: SceneComponentProps<EmbeddedScene>): React__default.JSX.Element;
|
653
661
|
|
654
|
-
declare class SceneScopesBridge extends SceneObjectBase {
|
655
|
-
static Component: typeof SceneScopesBridgeRenderer;
|
656
|
-
protected _renderBeforeActivation: boolean;
|
657
|
-
private _contextSubject;
|
658
|
-
getValue(): Scope[];
|
659
|
-
/**
|
660
|
-
* Emits values of the selected scopes array. It emits the current value and the previous value if there is a change.
|
661
|
-
* @param cb
|
662
|
-
*/
|
663
|
-
subscribeToValue(cb: (newScopes: Scope[], prevScopes: Scope[]) => void): Unsubscribable;
|
664
|
-
isLoading(): boolean;
|
665
|
-
subscribeToLoading(cb: (loading: boolean) => void): Unsubscribable;
|
666
|
-
setEnabled(enabled: boolean): void;
|
667
|
-
setReadOnly(readOnly: boolean): void;
|
668
|
-
/**
|
669
|
-
* This method is used to keep the context up to date with the scopes context received from React
|
670
|
-
*
|
671
|
-
* Its rationale is:
|
672
|
-
* - When a new context is available, check if we have pending scopes passed from the URL
|
673
|
-
* - If we have pending scopes, ask the new context to load them
|
674
|
-
* - The loading should happen in a setTimeout to allow the existing context to pass its values to the URL sync handler
|
675
|
-
* - If a new context is received, propagate it as a new value in the behavior subject
|
676
|
-
* - If a new value is received, force a re-render to trigger the URL sync handler
|
677
|
-
*/
|
678
|
-
updateContext(newContext: ScopesContextValue | undefined): void;
|
679
|
-
private get context();
|
680
|
-
private get contextObservable();
|
681
|
-
}
|
682
|
-
declare function SceneScopesBridgeRenderer({ model }: SceneComponentProps<SceneScopesBridge>): null;
|
683
|
-
|
684
662
|
interface SceneRouteMatch<Params extends {
|
685
663
|
[K in keyof Params]?: string;
|
686
664
|
} = {}> {
|
@@ -693,7 +671,6 @@ interface SceneAppState extends SceneObjectState {
|
|
693
671
|
pages: SceneAppPageLike[];
|
694
672
|
name?: string;
|
695
673
|
urlSyncOptions?: SceneUrlSyncOptions;
|
696
|
-
scopesBridge?: SceneScopesBridge;
|
697
674
|
}
|
698
675
|
interface SceneAppRoute {
|
699
676
|
path: string;
|
@@ -738,7 +715,6 @@ interface SceneAppPageState extends SceneObjectState {
|
|
738
715
|
*/
|
739
716
|
getFallbackPage?: () => SceneAppPageLike;
|
740
717
|
layout?: PageLayoutType;
|
741
|
-
useScopes?: boolean;
|
742
718
|
}
|
743
719
|
interface SceneAppPageLike extends SceneObject<SceneAppPageState>, DataRequestEnricher {
|
744
720
|
initializeScene(scene: SceneObject): void;
|
@@ -966,8 +942,9 @@ declare class AdHocFiltersVariable extends SceneObjectBase<AdHocFiltersVariableS
|
|
966
942
|
static Component: typeof AdHocFiltersVariableRenderer;
|
967
943
|
private _scopedVars;
|
968
944
|
private _dataSourceSrv;
|
969
|
-
private _scopesBridge;
|
970
945
|
private _originalValues;
|
946
|
+
/** Needed for scopes dependency */
|
947
|
+
protected _variableDependency: VariableDependencyConfig<AdHocFiltersVariableState>;
|
971
948
|
protected _urlSync: AdHocFiltersVariableUrlSyncHandler;
|
972
949
|
constructor(state: Partial<AdHocFiltersVariableState>);
|
973
950
|
private _activationHandler;
|
@@ -1220,7 +1197,6 @@ declare class GroupByVariable extends MultiValueVariable<GroupByVariableState> {
|
|
1220
1197
|
static Component: typeof GroupByVariableRenderer;
|
1221
1198
|
isLazy: boolean;
|
1222
1199
|
protected _urlSync: SceneObjectUrlSyncHandler;
|
1223
|
-
private _scopesBridge;
|
1224
1200
|
validateAndUpdate(): Observable<ValidateAndUpdateResult>;
|
1225
1201
|
private _updateValueGivenNewOptions;
|
1226
1202
|
getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]>;
|
@@ -1417,9 +1393,9 @@ declare function getAncestor<ParentType>(sceneObject: SceneObject, ancestorType:
|
|
1417
1393
|
*/
|
1418
1394
|
declare function findDescendents<T extends SceneObject>(scene: SceneObject, descendentType: SceneType<T>): T[];
|
1419
1395
|
/**
|
1420
|
-
* Will
|
1396
|
+
* Will return the scopes from the scopes variable if available.
|
1421
1397
|
*/
|
1422
|
-
declare function
|
1398
|
+
declare function getScopes(sceneObject: SceneObject): Scope[] | undefined;
|
1423
1399
|
|
1424
1400
|
declare const sceneGraph: {
|
1425
1401
|
getVariables: typeof getVariables;
|
@@ -1437,7 +1413,7 @@ declare const sceneGraph: {
|
|
1437
1413
|
getAncestor: typeof getAncestor;
|
1438
1414
|
getQueryController: typeof getQueryController;
|
1439
1415
|
findDescendents: typeof findDescendents;
|
1440
|
-
|
1416
|
+
getScopes: typeof getScopes;
|
1441
1417
|
};
|
1442
1418
|
|
1443
1419
|
interface ActWhenVariableChangedState extends SceneObjectState {
|
@@ -1704,8 +1680,6 @@ declare class SceneQueryRunner extends SceneObjectBase<QueryRunnerState> impleme
|
|
1704
1680
|
private _dataLayersMerger;
|
1705
1681
|
private _timeSub?;
|
1706
1682
|
private _timeSubRange?;
|
1707
|
-
private _scopesSub?;
|
1708
|
-
private _scopesSubBridge?;
|
1709
1683
|
private _containerWidth?;
|
1710
1684
|
private _variableValueRecorder;
|
1711
1685
|
private _results;
|
@@ -1744,12 +1718,11 @@ declare class SceneQueryRunner extends SceneObjectBase<QueryRunnerState> impleme
|
|
1744
1718
|
private _onDeactivate;
|
1745
1719
|
setContainerWidth(width: number): void;
|
1746
1720
|
isDataReadyToDisplay(): boolean;
|
1747
|
-
private subscribeToScopesChanges;
|
1748
1721
|
private subscribeToTimeRangeChanges;
|
1749
1722
|
runQueries(): void;
|
1750
1723
|
private getMaxDataPoints;
|
1751
1724
|
cancelQuery(): void;
|
1752
|
-
private
|
1725
|
+
private runWithTimeRange;
|
1753
1726
|
clone(withState?: Partial<QueryRunnerState>): this;
|
1754
1727
|
private prepareRequests;
|
1755
1728
|
private onDataReceived;
|
@@ -1884,7 +1857,7 @@ interface VariableSelectProps {
|
|
1884
1857
|
/** To provide an option to hide the label in the variable value selector */
|
1885
1858
|
hideLabel?: boolean;
|
1886
1859
|
}
|
1887
|
-
declare function VariableValueSelectWrapper({ variable, layout, showAlways, hideLabel }: VariableSelectProps): React__default.JSX.Element | null;
|
1860
|
+
declare function VariableValueSelectWrapper({ variable, layout, showAlways, hideLabel }: VariableSelectProps): string | number | boolean | React__default.JSX.Element | Iterable<React__default.ReactNode> | null | undefined;
|
1888
1861
|
|
1889
1862
|
interface VariableValueControlState extends SceneObjectState {
|
1890
1863
|
layout?: ControlsLayout;
|
@@ -1899,8 +1872,6 @@ declare class VariableValueControl extends SceneObjectBase<VariableValueControlS
|
|
1899
1872
|
declare function VariableValueControlRenderer({ model }: SceneComponentProps<VariableValueControl>): React__default.JSX.Element | null;
|
1900
1873
|
|
1901
1874
|
declare class SceneVariableSet extends SceneObjectBase<SceneVariableSetState> implements SceneVariables {
|
1902
|
-
/** Variables that have changed in since the activation or since the first manual value change */
|
1903
|
-
private _variablesThatHaveChanged;
|
1904
1875
|
/** Variables that are scheduled to be validated and updated */
|
1905
1876
|
private _variablesToUpdate;
|
1906
1877
|
/** Variables currently updating */
|
@@ -2003,6 +1974,41 @@ declare class TestVariable extends MultiValueVariable<TestVariableState> {
|
|
2003
1974
|
static Component: ({ model }: SceneComponentProps<MultiValueVariable>) => React__default.JSX.Element;
|
2004
1975
|
}
|
2005
1976
|
|
1977
|
+
interface ScopesVariableState extends SceneVariableState {
|
1978
|
+
/**
|
1979
|
+
* Last captured state from ScopesContext
|
1980
|
+
*/
|
1981
|
+
scopes: Scope[];
|
1982
|
+
/**
|
1983
|
+
* Set to true if you want to the variable to enable / disable scopes when activated / deactivated
|
1984
|
+
*/
|
1985
|
+
enable?: boolean;
|
1986
|
+
}
|
1987
|
+
declare class ScopesVariable extends SceneObjectBase<ScopesVariableState> implements SceneVariable<ScopesVariableState> {
|
1988
|
+
protected _renderBeforeActivation: boolean;
|
1989
|
+
protected _context: ScopesContextValue | undefined;
|
1990
|
+
constructor(state: Partial<ScopesVariableState>);
|
1991
|
+
/**
|
1992
|
+
* Temporary simple implementation to stringify the scopes.
|
1993
|
+
*/
|
1994
|
+
getValue(fieldPath: string): VariableValue;
|
1995
|
+
getScopes(): Scope[] | undefined;
|
1996
|
+
/**
|
1997
|
+
* This method is used to keep the context up to date with the scopes context received from React
|
1998
|
+
* 1) Subscribes to ScopesContext state changes and synchronizes it with the variable state
|
1999
|
+
* 2) Handles enable / disabling of scopes based on variable enable option.
|
2000
|
+
*/
|
2001
|
+
setContext(context: ScopesContextValue | undefined): (() => void) | undefined;
|
2002
|
+
updateStateFromContext(state: {
|
2003
|
+
loading: boolean;
|
2004
|
+
value: Scope[];
|
2005
|
+
}): void;
|
2006
|
+
/**
|
2007
|
+
* Special function that enables variables to be hidden but still render to access react contexts
|
2008
|
+
*/
|
2009
|
+
hiddenRender(): ReactNode;
|
2010
|
+
}
|
2011
|
+
|
2006
2012
|
interface LocalValueVariableState extends SceneVariableState {
|
2007
2013
|
value: VariableValue;
|
2008
2014
|
text: VariableValue;
|
@@ -2492,9 +2498,6 @@ declare class SceneAppPage extends SceneObjectBase<SceneAppPageState> implements
|
|
2492
2498
|
static Component: typeof SceneAppPageRenderer;
|
2493
2499
|
private _sceneCache;
|
2494
2500
|
private _drilldownCache;
|
2495
|
-
private _scopesBridge;
|
2496
|
-
constructor(state: SceneAppPageState);
|
2497
|
-
private _activationHandler;
|
2498
2501
|
initializeScene(scene: EmbeddedScene): void;
|
2499
2502
|
getScene(routeMatch: SceneRouteMatch): EmbeddedScene;
|
2500
2503
|
getDrilldownPage(drilldown: SceneAppDrilldownView, routeMatch: SceneRouteMatch<{}>): SceneAppPageLike;
|
@@ -3029,5 +3032,5 @@ declare const sceneUtils: {
|
|
3029
3032
|
isGroupByVariable: typeof isGroupByVariable;
|
3030
3033
|
};
|
3031
3034
|
|
3032
|
-
export { AdHocFiltersVariable, ConstantVariable, ControlsLabel, CustomVariable, DataProviderProxy, DataSourceVariable, EmbeddedScene, FieldConfigBuilder, FieldConfigBuilders, FieldConfigOverridesBuilder, GroupByVariable, IntervalVariable, LazyLoader, LocalValueVariable, MultiOrSingleValueSelect, MultiValueVariable, NestedScene, NewSceneObjectAddedEvent, PanelBuilders, PanelOptionsBuilders, QueryVariable, RuntimeDataSource, SafeSerializableSceneObject, SceneApp, SceneAppPage, SceneByFrameRepeater, SceneByVariableRepeater, SceneCSSGridItem, SceneCSSGridLayout, SceneCanvasText, SceneControlsSpacer, SceneDataLayerBase, SceneDataLayerControls, SceneDataLayerSet, SceneDataLayerSetBase, SceneDataNode, SceneDataTransformer, SceneDebugger, SceneFlexItem, SceneFlexLayout, SceneGridItem, SceneGridLayout, SceneGridLayoutDragStartEvent, SceneGridRow, SceneObjectBase, SceneObjectRef, SceneObjectStateChangedEvent, SceneObjectUrlSyncConfig, SceneQueryRunner, SceneReactObject, SceneRefreshPicker,
|
3035
|
+
export { AdHocFiltersVariable, ConstantVariable, ControlsLabel, CustomVariable, DataProviderProxy, DataSourceVariable, EmbeddedScene, FieldConfigBuilder, FieldConfigBuilders, FieldConfigOverridesBuilder, GroupByVariable, IntervalVariable, LazyLoader, LocalValueVariable, MultiOrSingleValueSelect, MultiValueVariable, NestedScene, NewSceneObjectAddedEvent, PanelBuilders, PanelOptionsBuilders, QueryVariable, RuntimeDataSource, SafeSerializableSceneObject, SceneApp, SceneAppPage, SceneByFrameRepeater, SceneByVariableRepeater, SceneCSSGridItem, SceneCSSGridLayout, SceneCanvasText, SceneControlsSpacer, SceneDataLayerBase, SceneDataLayerControls, SceneDataLayerSet, SceneDataLayerSetBase, SceneDataNode, SceneDataTransformer, SceneDebugger, SceneFlexItem, SceneFlexLayout, SceneGridItem, SceneGridLayout, SceneGridLayoutDragStartEvent, SceneGridRow, SceneObjectBase, SceneObjectRef, SceneObjectStateChangedEvent, SceneObjectUrlSyncConfig, SceneQueryRunner, SceneReactObject, SceneRefreshPicker, SceneTimePicker, SceneTimeRange, SceneTimeRangeCompare, SceneTimeRangeTransformerBase, SceneTimeZoneOverride, SceneToolbarButton, SceneToolbarInput, SceneVariableSet, SceneVariableValueChangedEvent, ScopesVariable, SplitLayout, TestVariable, TextBoxVariable, UrlSyncContextProvider, UrlSyncManager, UserActionEvent, VariableDependencyConfig, VariableValueControl, VariableValueSelectWrapper, VariableValueSelectors, VizConfigBuilder, VizConfigBuilders, VizPanel, VizPanelBuilder, VizPanelExploreButton, VizPanelMenu, index$1 as behaviors, index as dataLayers, formatRegistry, getExploreURL, isCustomVariableValue, isDataLayer, isDataRequestEnricher, isFiltersRequestEnricher, isSceneObject, registerQueryWithController, registerRuntimeDataSource, sceneGraph, sceneUtils, useSceneApp, useSceneObjectState, useUrlSync };
|
3033
3036
|
export type { AdHocFilterWithLabels, CancelActivationHandler, ControlsLayout, CustomFormatterVariable, CustomTransformOperator, CustomTransformerDefinition, CustomVariableValue, DataLayerFilter, DataRequestEnricher, DeepPartial, EmbeddedSceneState, ExtraQueryDataProcessor, ExtraQueryDescriptor, ExtraQueryProvider, FiltersRequestEnricher, FormatVariable, InterpolationFormatParameter, MacroVariableConstructor, MultiValueVariableState, QueryRunnerState, SceneActivationHandler, SceneAppDrilldownView, SceneAppPageLike, SceneAppPageState, SceneAppRoute, SceneComponent, SceneComponentProps, SceneDataLayerProvider, SceneDataLayerProviderState, SceneDataProvider, SceneDataProviderResult, SceneDataQuery, SceneDataState, SceneDataTransformerState, SceneDeactivationHandler, SceneFlexItemLike, SceneFlexItemState, SceneGridItemLike, SceneGridItemStateLike, SceneInteractionProfileEvent, SceneLayout, SceneLayoutChildOptions, SceneLayoutState, SceneObject, SceneObjectState, SceneObjectStateChangedPayload, SceneObjectUrlSyncHandler, SceneObjectUrlValue, SceneObjectUrlValues, SceneObjectWithUrlSync, SceneQueryControllerEntry, SceneQueryControllerEntryType, SceneQueryControllerLike, SceneRefreshPickerState, SceneRouteMatch, SceneStateChangedHandler, SceneStatelessBehavior, SceneTimeRangeLike, SceneTimeRangeState, SceneUrlSyncOptions, SceneVariable, SceneVariableDependencyConfigLike, SceneVariableSetState, SceneVariableState, SceneVariables, UrlSyncManagerLike, UseStateHookOptions, ValidateAndUpdateResult, VariableCustomFormatterFn, VariableGetOptionsArgs, VariableValue, VariableValueOption, VariableValueSingle, VizConfig, VizPanelState };
|