@grafana/scenes 4.11.2--canary.648.8738574184.0 → 4.11.2
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 +13 -0
- package/dist/esm/components/VizPanel/VizPanelMenu.js +1 -3
- package/dist/esm/components/VizPanel/VizPanelMenu.js.map +1 -1
- package/dist/esm/components/layout/grid/SceneGridRow.js +1 -3
- package/dist/esm/components/layout/grid/SceneGridRow.js.map +1 -1
- package/dist/esm/variables/components/VariableValueSelect.js +0 -3
- package/dist/esm/variables/components/VariableValueSelect.js.map +1 -1
- package/dist/esm/variables/components/VariableValueSelectors.js +2 -5
- package/dist/esm/variables/components/VariableValueSelectors.js.map +1 -1
- package/dist/esm/variables/groupby/GroupByVariable.js +55 -3
- package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
- package/dist/esm/variables/sets/SceneVariableSet.js +3 -0
- package/dist/esm/variables/sets/SceneVariableSet.js.map +1 -1
- package/dist/esm/variables/types.js.map +1 -1
- package/dist/esm/variables/utils.js +20 -2
- package/dist/esm/variables/utils.js.map +1 -1
- package/dist/esm/variables/variants/TestVariable.js +3 -1
- package/dist/esm/variables/variants/TestVariable.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +154 -87
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -25,7 +25,7 @@ var __spreadValues = (a, b) => {
|
|
|
25
25
|
return a;
|
|
26
26
|
};
|
|
27
27
|
class TestVariable extends MultiValueVariable {
|
|
28
|
-
constructor(initialState) {
|
|
28
|
+
constructor(initialState, isLazy = false) {
|
|
29
29
|
super(__spreadValues({
|
|
30
30
|
type: "custom",
|
|
31
31
|
name: "Test",
|
|
@@ -38,9 +38,11 @@ class TestVariable extends MultiValueVariable {
|
|
|
38
38
|
this.completeUpdate = new Subject();
|
|
39
39
|
this.isGettingValues = true;
|
|
40
40
|
this.getValueOptionsCount = 0;
|
|
41
|
+
this.isLazy = false;
|
|
41
42
|
this._variableDependency = new VariableDependencyConfig(this, {
|
|
42
43
|
statePaths: ["query"]
|
|
43
44
|
});
|
|
45
|
+
this.isLazy = isLazy;
|
|
44
46
|
}
|
|
45
47
|
getValueOptions(args) {
|
|
46
48
|
const { delayMs } = this.state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestVariable.js","sources":["../../../../src/variables/variants/TestVariable.tsx"],"sourcesContent":["import { Observable, Subject } from 'rxjs';\n\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { SceneComponentProps } from '../../core/types';\nimport { queryMetricTree } from '../../utils/metricTree';\nimport { VariableDependencyConfig } from '../VariableDependencyConfig';\nimport { renderSelectForVariable } from '../components/VariableValueSelect';\nimport { VariableValueOption } from '../types';\n\nimport { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } from './MultiValueVariable';\nimport { VariableRefresh } from '@grafana/data';\nimport { getClosest } from '../../core/sceneGraph/utils';\nimport { SceneVariableSet } from '../sets/SceneVariableSet';\nimport { SceneQueryControllerEntry } from '../../behaviors/SceneQueryController';\n\nexport interface TestVariableState extends MultiValueVariableState {\n query: string;\n delayMs?: number;\n issuedQuery?: string;\n refresh?: VariableRefresh;\n throwError?: string;\n optionsToReturn?: VariableValueOption[];\n}\n\n/**\n * This variable is only designed for unit tests and potentially e2e tests.\n */\nexport class TestVariable extends MultiValueVariable<TestVariableState> {\n private completeUpdate = new Subject<number>();\n public isGettingValues = true;\n public getValueOptionsCount = 0;\n\n protected _variableDependency = new VariableDependencyConfig(this, {\n statePaths: ['query'],\n });\n\n public constructor(initialState: Partial<TestVariableState
|
|
1
|
+
{"version":3,"file":"TestVariable.js","sources":["../../../../src/variables/variants/TestVariable.tsx"],"sourcesContent":["import { Observable, Subject } from 'rxjs';\n\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { SceneComponentProps } from '../../core/types';\nimport { queryMetricTree } from '../../utils/metricTree';\nimport { VariableDependencyConfig } from '../VariableDependencyConfig';\nimport { renderSelectForVariable } from '../components/VariableValueSelect';\nimport { VariableValueOption } from '../types';\n\nimport { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } from './MultiValueVariable';\nimport { VariableRefresh } from '@grafana/data';\nimport { getClosest } from '../../core/sceneGraph/utils';\nimport { SceneVariableSet } from '../sets/SceneVariableSet';\nimport { SceneQueryControllerEntry } from '../../behaviors/SceneQueryController';\n\nexport interface TestVariableState extends MultiValueVariableState {\n query: string;\n delayMs?: number;\n issuedQuery?: string;\n refresh?: VariableRefresh;\n throwError?: string;\n optionsToReturn?: VariableValueOption[];\n}\n\n/**\n * This variable is only designed for unit tests and potentially e2e tests.\n */\nexport class TestVariable extends MultiValueVariable<TestVariableState> {\n private completeUpdate = new Subject<number>();\n public isGettingValues = true;\n public getValueOptionsCount = 0;\n isLazy = false;\n\n protected _variableDependency = new VariableDependencyConfig(this, {\n statePaths: ['query'],\n });\n\n public constructor(initialState: Partial<TestVariableState>, isLazy = false) {\n super({\n type: 'custom',\n name: 'Test',\n value: 'Value',\n text: 'Text',\n query: 'Query',\n options: [],\n refresh: VariableRefresh.onDashboardLoad,\n ...initialState,\n });\n this.isLazy = isLazy;\n }\n\n public getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]> {\n const { delayMs } = this.state;\n\n this.getValueOptionsCount += 1;\n\n const queryController = sceneGraph.getQueryController(this);\n\n return new Observable<VariableValueOption[]>((observer) => {\n const queryEntry: SceneQueryControllerEntry = {\n type: 'variable',\n origin: this,\n cancel: () => observer.complete(),\n };\n\n if (queryController) {\n queryController.queryStarted(queryEntry);\n }\n\n this.setState({ loading: true });\n\n if (this.state.throwError) {\n throw new Error(this.state.throwError);\n }\n\n const interpolatedQuery = sceneGraph.interpolate(this, this.state.query);\n const options = this.getOptions(interpolatedQuery);\n\n const sub = this.completeUpdate.subscribe({\n next: () => {\n this.setState({ issuedQuery: interpolatedQuery, options, loading: false });\n observer.next(options);\n observer.complete();\n },\n });\n\n let timeout: number | undefined;\n if (delayMs) {\n timeout = window.setTimeout(() => this.signalUpdateCompleted(), delayMs);\n } else if (delayMs === 0) {\n this.signalUpdateCompleted();\n }\n\n this.isGettingValues = true;\n\n return () => {\n sub.unsubscribe();\n window.clearTimeout(timeout);\n this.isGettingValues = false;\n\n if (this.state.loading) {\n this.setState({ loading: false });\n }\n\n if (queryController) {\n queryController.queryCompleted(queryEntry);\n }\n };\n });\n }\n\n public cancel() {\n const sceneVarSet = getClosest(this, (s) => (s instanceof SceneVariableSet ? s : undefined));\n sceneVarSet?.cancel(this);\n }\n\n private getOptions(interpolatedQuery: string) {\n if (this.state.optionsToReturn) {\n return this.state.optionsToReturn;\n }\n\n return queryMetricTree(interpolatedQuery).map((x) => ({ label: x.name, value: x.name }));\n }\n\n /** Useful from tests */\n public signalUpdateCompleted() {\n this.completeUpdate.next(1);\n }\n\n public static Component = ({ model }: SceneComponentProps<MultiValueVariable>) => {\n return renderSelectForVariable(model);\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,MAAM,qBAAqB,kBAAsC,CAAA;AAAA,EAU/D,WAAA,CAAY,YAA0C,EAAA,MAAA,GAAS,KAAO,EAAA;AAC3E,IAAM,KAAA,CAAA,cAAA,CAAA;AAAA,MACJ,IAAM,EAAA,QAAA;AAAA,MACN,IAAM,EAAA,MAAA;AAAA,MACN,KAAO,EAAA,OAAA;AAAA,MACP,IAAM,EAAA,MAAA;AAAA,MACN,KAAO,EAAA,OAAA;AAAA,MACP,SAAS,EAAC;AAAA,MACV,SAAS,eAAgB,CAAA,eAAA;AAAA,KAAA,EACtB,YACJ,CAAA,CAAA,CAAA;AAnBH,IAAQ,IAAA,CAAA,cAAA,GAAiB,IAAI,OAAgB,EAAA,CAAA;AAC7C,IAAA,IAAA,CAAO,eAAkB,GAAA,IAAA,CAAA;AACzB,IAAA,IAAA,CAAO,oBAAuB,GAAA,CAAA,CAAA;AAC9B,IAAS,IAAA,CAAA,MAAA,GAAA,KAAA,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AW,iBAA2B,EAAA;AAC5C,IAAI,IAAA,IAAA,CAAK,MAAM,eAAiB,EAAA;AAC9B,MAAA,OAAO,KAAK,KAAM,CAAA,eAAA,CAAA;AAAA,KACpB;AAEA,IAAA,OAAO,eAAgB,CAAA,iBAAiB,CAAE,CAAA,GAAA,CAAI,CAAC,CAAA,MAAO,EAAE,KAAA,EAAO,CAAE,CAAA,IAAA,EAAM,KAAO,EAAA,CAAA,CAAE,MAAO,CAAA,CAAA,CAAA;AAAA,GACzF;AAAA,EAGO,qBAAwB,GAAA;AAC7B,IAAK,IAAA,CAAA,cAAA,CAAe,KAAK,CAAC,CAAA,CAAA;AAAA,GAC5B;AAKF,CAAA;AAzGa,YAAA,CAsGG,SAAY,GAAA,CAAC,EAAE,KAAA,EAAqD,KAAA;AAChF,EAAA,OAAO,wBAAwB,KAAK,CAAA,CAAA;AACtC,CAAA;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,11 @@ interface SceneVariable<TState extends SceneVariableState = SceneVariableState>
|
|
|
61
61
|
* Allows cancelling variable execution.
|
|
62
62
|
*/
|
|
63
63
|
onCancel?(): void;
|
|
64
|
+
/**
|
|
65
|
+
* @experimental
|
|
66
|
+
* Indicates that a variable loads values lazily when user interacts with the variable dropdown.
|
|
67
|
+
*/
|
|
68
|
+
isLazy?: boolean;
|
|
64
69
|
}
|
|
65
70
|
type VariableValue = VariableValueSingle | VariableValueSingle[];
|
|
66
71
|
type VariableValueSingle = string | boolean | number | CustomVariableValue;
|
|
@@ -903,6 +908,7 @@ type getTagKeysProvider = (set: GroupByVariable, currentKey: string | null) => P
|
|
|
903
908
|
}>;
|
|
904
909
|
declare class GroupByVariable extends MultiValueVariable<GroupByVariableState> {
|
|
905
910
|
static Component: typeof GroupByVariableRenderer;
|
|
911
|
+
isLazy: boolean;
|
|
906
912
|
validateAndUpdate(): Observable<ValidateAndUpdateResult>;
|
|
907
913
|
private _updateValueGivenNewOptions;
|
|
908
914
|
getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]>;
|
|
@@ -1463,8 +1469,9 @@ declare class TestVariable extends MultiValueVariable<TestVariableState> {
|
|
|
1463
1469
|
private completeUpdate;
|
|
1464
1470
|
isGettingValues: boolean;
|
|
1465
1471
|
getValueOptionsCount: number;
|
|
1472
|
+
isLazy: boolean;
|
|
1466
1473
|
protected _variableDependency: VariableDependencyConfig<TestVariableState>;
|
|
1467
|
-
constructor(initialState: Partial<TestVariableState
|
|
1474
|
+
constructor(initialState: Partial<TestVariableState>, isLazy?: boolean);
|
|
1468
1475
|
getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]>;
|
|
1469
1476
|
cancel(): void;
|
|
1470
1477
|
private getOptions;
|
package/dist/index.js
CHANGED
|
@@ -2840,81 +2840,6 @@ class CustomAllValue {
|
|
|
2840
2840
|
}
|
|
2841
2841
|
}
|
|
2842
2842
|
|
|
2843
|
-
function VariableValueSelect({ model }) {
|
|
2844
|
-
const { value, key } = model.useState();
|
|
2845
|
-
const onInputChange = model.onSearchChange ? (value2, meta) => {
|
|
2846
|
-
if (meta.action === "input-change") {
|
|
2847
|
-
model.onSearchChange(value2);
|
|
2848
|
-
}
|
|
2849
|
-
} : void 0;
|
|
2850
|
-
return /* @__PURE__ */ React__default["default"].createElement(ui.Select, {
|
|
2851
|
-
id: key,
|
|
2852
|
-
placeholder: "Select value",
|
|
2853
|
-
width: "auto",
|
|
2854
|
-
value,
|
|
2855
|
-
allowCustomValue: true,
|
|
2856
|
-
virtualized: true,
|
|
2857
|
-
tabSelectsValue: false,
|
|
2858
|
-
onInputChange,
|
|
2859
|
-
options: model.getOptionsForSelect(),
|
|
2860
|
-
"data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`),
|
|
2861
|
-
onChange: (newValue) => {
|
|
2862
|
-
model.changeValueTo(newValue.value, newValue.label);
|
|
2863
|
-
}
|
|
2864
|
-
});
|
|
2865
|
-
}
|
|
2866
|
-
function VariableValueSelectMulti({ model }) {
|
|
2867
|
-
const { value, key, maxVisibleValues, noValueOnClear } = model.useState();
|
|
2868
|
-
const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
|
|
2869
|
-
const options = model.getOptionsForSelect();
|
|
2870
|
-
const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
|
|
2871
|
-
React.useEffect(() => {
|
|
2872
|
-
setUncommittedValue(arrayValue);
|
|
2873
|
-
}, [arrayValue]);
|
|
2874
|
-
const onInputChange = model.onSearchChange ? (value2, meta) => {
|
|
2875
|
-
if (meta.action === "input-change") {
|
|
2876
|
-
model.onSearchChange(value2);
|
|
2877
|
-
}
|
|
2878
|
-
} : void 0;
|
|
2879
|
-
const placeholder = options.length > 0 ? "Select value" : "";
|
|
2880
|
-
return /* @__PURE__ */ React__default["default"].createElement(ui.MultiSelect, {
|
|
2881
|
-
id: key,
|
|
2882
|
-
placeholder,
|
|
2883
|
-
width: "auto",
|
|
2884
|
-
value: uncommittedValue,
|
|
2885
|
-
noMultiValueWrap: true,
|
|
2886
|
-
maxVisibleValues: maxVisibleValues != null ? maxVisibleValues : 5,
|
|
2887
|
-
tabSelectsValue: false,
|
|
2888
|
-
virtualized: true,
|
|
2889
|
-
allowCustomValue: true,
|
|
2890
|
-
options: model.getOptionsForSelect(),
|
|
2891
|
-
closeMenuOnSelect: false,
|
|
2892
|
-
isClearable: true,
|
|
2893
|
-
onInputChange,
|
|
2894
|
-
onBlur: () => {
|
|
2895
|
-
model.changeValueTo(uncommittedValue);
|
|
2896
|
-
},
|
|
2897
|
-
"data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`),
|
|
2898
|
-
onChange: (newValue, action) => {
|
|
2899
|
-
if (action.action === "clear" && noValueOnClear) {
|
|
2900
|
-
model.changeValueTo([]);
|
|
2901
|
-
}
|
|
2902
|
-
setUncommittedValue(newValue.map((x) => x.value));
|
|
2903
|
-
}
|
|
2904
|
-
});
|
|
2905
|
-
}
|
|
2906
|
-
function renderSelectForVariable(model) {
|
|
2907
|
-
if (model.state.isMulti) {
|
|
2908
|
-
return /* @__PURE__ */ React__default["default"].createElement(VariableValueSelectMulti, {
|
|
2909
|
-
model
|
|
2910
|
-
});
|
|
2911
|
-
} else {
|
|
2912
|
-
return /* @__PURE__ */ React__default["default"].createElement(VariableValueSelect, {
|
|
2913
|
-
model
|
|
2914
|
-
});
|
|
2915
|
-
}
|
|
2916
|
-
}
|
|
2917
|
-
|
|
2918
2843
|
var __defProp$z = Object.defineProperty;
|
|
2919
2844
|
var __defProps$n = Object.defineProperties;
|
|
2920
2845
|
var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
|
|
@@ -2950,6 +2875,7 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
2950
2875
|
}, initialState), {
|
|
2951
2876
|
noValueOnClear: true
|
|
2952
2877
|
}));
|
|
2878
|
+
this.isLazy = true;
|
|
2953
2879
|
this._getKeys = async (ds) => {
|
|
2954
2880
|
var _a, _b, _c;
|
|
2955
2881
|
const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, null));
|
|
@@ -3035,7 +2961,56 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
3035
2961
|
}
|
|
3036
2962
|
GroupByVariable.Component = GroupByVariableRenderer;
|
|
3037
2963
|
function GroupByVariableRenderer({ model }) {
|
|
3038
|
-
|
|
2964
|
+
const { value, key, maxVisibleValues, noValueOnClear } = model.useState();
|
|
2965
|
+
const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
|
|
2966
|
+
const [isFetchingOptions, setIsFetchingOptions] = React.useState(false);
|
|
2967
|
+
const [isOptionsOpen, setIsOptionsOpen] = React.useState(false);
|
|
2968
|
+
const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
|
|
2969
|
+
React.useEffect(() => {
|
|
2970
|
+
setUncommittedValue(arrayValue);
|
|
2971
|
+
}, [arrayValue]);
|
|
2972
|
+
const onInputChange = model.onSearchChange ? (value2, meta) => {
|
|
2973
|
+
if (meta.action === "input-change") {
|
|
2974
|
+
model.onSearchChange(value2);
|
|
2975
|
+
}
|
|
2976
|
+
} : void 0;
|
|
2977
|
+
const placeholder = "Select value";
|
|
2978
|
+
return /* @__PURE__ */ React__default["default"].createElement(ui.MultiSelect, {
|
|
2979
|
+
"data-testid": `GroupBySelect-${key}`,
|
|
2980
|
+
id: key,
|
|
2981
|
+
placeholder,
|
|
2982
|
+
width: "auto",
|
|
2983
|
+
value: uncommittedValue,
|
|
2984
|
+
noMultiValueWrap: true,
|
|
2985
|
+
maxVisibleValues: maxVisibleValues != null ? maxVisibleValues : 5,
|
|
2986
|
+
tabSelectsValue: false,
|
|
2987
|
+
virtualized: true,
|
|
2988
|
+
allowCustomValue: true,
|
|
2989
|
+
options: model.getOptionsForSelect(),
|
|
2990
|
+
closeMenuOnSelect: false,
|
|
2991
|
+
isOpen: isOptionsOpen,
|
|
2992
|
+
isClearable: true,
|
|
2993
|
+
isLoading: isFetchingOptions,
|
|
2994
|
+
onInputChange,
|
|
2995
|
+
onBlur: () => {
|
|
2996
|
+
model.changeValueTo(uncommittedValue);
|
|
2997
|
+
},
|
|
2998
|
+
onChange: (newValue, action) => {
|
|
2999
|
+
if (action.action === "clear" && noValueOnClear) {
|
|
3000
|
+
model.changeValueTo([]);
|
|
3001
|
+
}
|
|
3002
|
+
setUncommittedValue(newValue.map((x) => x.value));
|
|
3003
|
+
},
|
|
3004
|
+
onOpenMenu: async () => {
|
|
3005
|
+
setIsFetchingOptions(true);
|
|
3006
|
+
await rxjs.lastValueFrom(model.validateAndUpdate());
|
|
3007
|
+
setIsFetchingOptions(false);
|
|
3008
|
+
setIsOptionsOpen(true);
|
|
3009
|
+
},
|
|
3010
|
+
onCloseMenu: () => {
|
|
3011
|
+
setIsOptionsOpen(false);
|
|
3012
|
+
}
|
|
3013
|
+
});
|
|
3039
3014
|
}
|
|
3040
3015
|
|
|
3041
3016
|
function LoadingIndicator(props) {
|
|
@@ -4051,9 +4026,9 @@ function escapeLokiRegexp(value) {
|
|
|
4051
4026
|
function getQueriesForVariables(sourceObject) {
|
|
4052
4027
|
const runners = sceneGraph.findAllObjects(
|
|
4053
4028
|
sourceObject.getRoot(),
|
|
4054
|
-
(o) => o instanceof SceneQueryRunner
|
|
4029
|
+
(o) => o instanceof SceneQueryRunner
|
|
4055
4030
|
);
|
|
4056
|
-
const applicableRunners = runners.filter((r) => {
|
|
4031
|
+
const applicableRunners = filterOutInactiveRunnerDuplicates(runners).filter((r) => {
|
|
4057
4032
|
var _a, _b;
|
|
4058
4033
|
return ((_a = r.state.datasource) == null ? void 0 : _a.uid) === ((_b = sourceObject.state.datasource) == null ? void 0 : _b.uid);
|
|
4059
4034
|
});
|
|
@@ -4066,6 +4041,24 @@ function getQueriesForVariables(sourceObject) {
|
|
|
4066
4041
|
});
|
|
4067
4042
|
return result;
|
|
4068
4043
|
}
|
|
4044
|
+
function filterOutInactiveRunnerDuplicates(runners) {
|
|
4045
|
+
const groupedItems = {};
|
|
4046
|
+
for (const item of runners) {
|
|
4047
|
+
if (item.state.key) {
|
|
4048
|
+
if (!(item.state.key in groupedItems)) {
|
|
4049
|
+
groupedItems[item.state.key] = [];
|
|
4050
|
+
}
|
|
4051
|
+
groupedItems[item.state.key].push(item);
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
return Object.values(groupedItems).flatMap((group) => {
|
|
4055
|
+
const activeItems = group.filter((item) => item.isActive);
|
|
4056
|
+
if (activeItems.length === 0 && group.length === 1) {
|
|
4057
|
+
return group;
|
|
4058
|
+
}
|
|
4059
|
+
return activeItems;
|
|
4060
|
+
});
|
|
4061
|
+
}
|
|
4069
4062
|
|
|
4070
4063
|
function isAdHocVariable(variable) {
|
|
4071
4064
|
return variable.state.type === "adhoc";
|
|
@@ -5990,8 +5983,7 @@ function VariableValueSelectWrapper({ variable, layout, showAlways }) {
|
|
|
5990
5983
|
}
|
|
5991
5984
|
if (layout === "vertical") {
|
|
5992
5985
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
5993
|
-
className: verticalContainer
|
|
5994
|
-
"data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItem
|
|
5986
|
+
className: verticalContainer
|
|
5995
5987
|
}, /* @__PURE__ */ React__default["default"].createElement(VariableLabel, {
|
|
5996
5988
|
variable,
|
|
5997
5989
|
layout
|
|
@@ -6000,8 +5992,7 @@ function VariableValueSelectWrapper({ variable, layout, showAlways }) {
|
|
|
6000
5992
|
}));
|
|
6001
5993
|
}
|
|
6002
5994
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
6003
|
-
className: containerStyle
|
|
6004
|
-
"data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItem
|
|
5995
|
+
className: containerStyle
|
|
6005
5996
|
}, /* @__PURE__ */ React__default["default"].createElement(VariableLabel, {
|
|
6006
5997
|
variable
|
|
6007
5998
|
}), /* @__PURE__ */ React__default["default"].createElement(variable.Component, {
|
|
@@ -6139,6 +6130,9 @@ class SceneVariableSet extends SceneObjectBase {
|
|
|
6139
6130
|
}
|
|
6140
6131
|
}
|
|
6141
6132
|
_variableNeedsUpdate(variable) {
|
|
6133
|
+
if (variable.isLazy) {
|
|
6134
|
+
return false;
|
|
6135
|
+
}
|
|
6142
6136
|
if (!variable.validateAndUpdate) {
|
|
6143
6137
|
return false;
|
|
6144
6138
|
}
|
|
@@ -6316,6 +6310,79 @@ class ConstantVariable extends SceneObjectBase {
|
|
|
6316
6310
|
}
|
|
6317
6311
|
}
|
|
6318
6312
|
|
|
6313
|
+
function VariableValueSelect({ model }) {
|
|
6314
|
+
const { value, key } = model.useState();
|
|
6315
|
+
const onInputChange = model.onSearchChange ? (value2, meta) => {
|
|
6316
|
+
if (meta.action === "input-change") {
|
|
6317
|
+
model.onSearchChange(value2);
|
|
6318
|
+
}
|
|
6319
|
+
} : void 0;
|
|
6320
|
+
return /* @__PURE__ */ React__default["default"].createElement(ui.Select, {
|
|
6321
|
+
id: key,
|
|
6322
|
+
placeholder: "Select value",
|
|
6323
|
+
width: "auto",
|
|
6324
|
+
value,
|
|
6325
|
+
allowCustomValue: true,
|
|
6326
|
+
virtualized: true,
|
|
6327
|
+
tabSelectsValue: false,
|
|
6328
|
+
onInputChange,
|
|
6329
|
+
options: model.getOptionsForSelect(),
|
|
6330
|
+
onChange: (newValue) => {
|
|
6331
|
+
model.changeValueTo(newValue.value, newValue.label);
|
|
6332
|
+
}
|
|
6333
|
+
});
|
|
6334
|
+
}
|
|
6335
|
+
function VariableValueSelectMulti({ model }) {
|
|
6336
|
+
const { value, key, maxVisibleValues, noValueOnClear } = model.useState();
|
|
6337
|
+
const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
|
|
6338
|
+
const options = model.getOptionsForSelect();
|
|
6339
|
+
const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
|
|
6340
|
+
React.useEffect(() => {
|
|
6341
|
+
setUncommittedValue(arrayValue);
|
|
6342
|
+
}, [arrayValue]);
|
|
6343
|
+
const onInputChange = model.onSearchChange ? (value2, meta) => {
|
|
6344
|
+
if (meta.action === "input-change") {
|
|
6345
|
+
model.onSearchChange(value2);
|
|
6346
|
+
}
|
|
6347
|
+
} : void 0;
|
|
6348
|
+
const placeholder = options.length > 0 ? "Select value" : "";
|
|
6349
|
+
return /* @__PURE__ */ React__default["default"].createElement(ui.MultiSelect, {
|
|
6350
|
+
id: key,
|
|
6351
|
+
placeholder,
|
|
6352
|
+
width: "auto",
|
|
6353
|
+
value: uncommittedValue,
|
|
6354
|
+
noMultiValueWrap: true,
|
|
6355
|
+
maxVisibleValues: maxVisibleValues != null ? maxVisibleValues : 5,
|
|
6356
|
+
tabSelectsValue: false,
|
|
6357
|
+
virtualized: true,
|
|
6358
|
+
allowCustomValue: true,
|
|
6359
|
+
options: model.getOptionsForSelect(),
|
|
6360
|
+
closeMenuOnSelect: false,
|
|
6361
|
+
isClearable: true,
|
|
6362
|
+
onInputChange,
|
|
6363
|
+
onBlur: () => {
|
|
6364
|
+
model.changeValueTo(uncommittedValue);
|
|
6365
|
+
},
|
|
6366
|
+
onChange: (newValue, action) => {
|
|
6367
|
+
if (action.action === "clear" && noValueOnClear) {
|
|
6368
|
+
model.changeValueTo([]);
|
|
6369
|
+
}
|
|
6370
|
+
setUncommittedValue(newValue.map((x) => x.value));
|
|
6371
|
+
}
|
|
6372
|
+
});
|
|
6373
|
+
}
|
|
6374
|
+
function renderSelectForVariable(model) {
|
|
6375
|
+
if (model.state.isMulti) {
|
|
6376
|
+
return /* @__PURE__ */ React__default["default"].createElement(VariableValueSelectMulti, {
|
|
6377
|
+
model
|
|
6378
|
+
});
|
|
6379
|
+
} else {
|
|
6380
|
+
return /* @__PURE__ */ React__default["default"].createElement(VariableValueSelect, {
|
|
6381
|
+
model
|
|
6382
|
+
});
|
|
6383
|
+
}
|
|
6384
|
+
}
|
|
6385
|
+
|
|
6319
6386
|
var __defProp$i = Object.defineProperty;
|
|
6320
6387
|
var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
|
|
6321
6388
|
var __hasOwnProp$i = Object.prototype.hasOwnProperty;
|
|
@@ -6990,7 +7057,7 @@ var __spreadValues$e = (a, b) => {
|
|
|
6990
7057
|
return a;
|
|
6991
7058
|
};
|
|
6992
7059
|
class TestVariable extends MultiValueVariable {
|
|
6993
|
-
constructor(initialState) {
|
|
7060
|
+
constructor(initialState, isLazy = false) {
|
|
6994
7061
|
super(__spreadValues$e({
|
|
6995
7062
|
type: "custom",
|
|
6996
7063
|
name: "Test",
|
|
@@ -7003,9 +7070,11 @@ class TestVariable extends MultiValueVariable {
|
|
|
7003
7070
|
this.completeUpdate = new rxjs.Subject();
|
|
7004
7071
|
this.isGettingValues = true;
|
|
7005
7072
|
this.getValueOptionsCount = 0;
|
|
7073
|
+
this.isLazy = false;
|
|
7006
7074
|
this._variableDependency = new VariableDependencyConfig(this, {
|
|
7007
7075
|
statePaths: ["query"]
|
|
7008
7076
|
});
|
|
7077
|
+
this.isLazy = isLazy;
|
|
7009
7078
|
}
|
|
7010
7079
|
getValueOptions(args) {
|
|
7011
7080
|
const { delayMs } = this.state;
|
|
@@ -7501,8 +7570,7 @@ function VizPanelMenuRenderer({ model }) {
|
|
|
7501
7570
|
childItems: item.subMenu ? renderItems(item.subMenu) : void 0,
|
|
7502
7571
|
url: item.href,
|
|
7503
7572
|
onClick: item.onClick,
|
|
7504
|
-
shortcut: item.shortcut
|
|
7505
|
-
testId: e2eSelectors.selectors.components.Panels.Panel.menuItems(item.text)
|
|
7573
|
+
shortcut: item.shortcut
|
|
7506
7574
|
})
|
|
7507
7575
|
);
|
|
7508
7576
|
};
|
|
@@ -8128,8 +8196,7 @@ function SceneGridRowRenderer({ model }) {
|
|
|
8128
8196
|
}, /* @__PURE__ */ React__default["default"].createElement("button", {
|
|
8129
8197
|
onClick: model.onCollapseToggle,
|
|
8130
8198
|
className: styles.rowTitleButton,
|
|
8131
|
-
"aria-label": isCollapsed ? "Expand row" : "Collapse row"
|
|
8132
|
-
"data-testid": e2eSelectors.selectors.components.DashboardRow.title(sceneGraph.interpolate(model, title, void 0, "text"))
|
|
8199
|
+
"aria-label": isCollapsed ? "Expand row" : "Collapse row"
|
|
8133
8200
|
}, isCollapsible && /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
|
|
8134
8201
|
name: isCollapsed ? "angle-right" : "angle-down"
|
|
8135
8202
|
}), /* @__PURE__ */ React__default["default"].createElement("span", {
|