@grafana/scenes 6.2.1--canary.990.13570008543.0 → 6.2.1
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 +24 -0
- package/dist/esm/components/SceneApp/SceneApp.js +3 -9
- package/dist/esm/components/SceneApp/SceneApp.js.map +1 -1
- package/dist/esm/components/SceneApp/SceneAppPage.js +0 -16
- package/dist/esm/components/SceneApp/SceneAppPage.js.map +1 -1
- package/dist/esm/core/SceneObjectBase.js +7 -0
- package/dist/esm/core/SceneObjectBase.js.map +1 -1
- package/dist/esm/core/sceneGraph/index.js +2 -3
- package/dist/esm/core/sceneGraph/index.js.map +1 -1
- package/dist/esm/core/sceneGraph/sceneGraph.js +1 -6
- package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/querying/SceneQueryRunner.js +8 -33
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +4 -3
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js +1 -22
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +4 -10
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
- package/dist/esm/variables/adhoc/getAdhocOptionSearcher.js +2 -3
- package/dist/esm/variables/adhoc/getAdhocOptionSearcher.js.map +1 -1
- package/dist/esm/variables/components/getOptionSearcher.js +2 -3
- package/dist/esm/variables/components/getOptionSearcher.js.map +1 -1
- package/dist/esm/variables/filter.js +35 -0
- package/dist/esm/variables/filter.js.map +1 -0
- package/dist/esm/variables/groupby/GroupByVariable.js +2 -3
- package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
- package/dist/esm/variables/utils.js +1 -23
- package/dist/esm/variables/utils.js.map +1 -1
- package/dist/index.d.ts +25 -66
- package/dist/index.js +61 -227
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/core/SceneScopesBridge.js +0 -111
- package/dist/esm/core/SceneScopesBridge.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -13,9 +13,9 @@ var schema = require('@grafana/schema');
|
|
|
13
13
|
var ui = require('@grafana/ui');
|
|
14
14
|
var e2eSelectors = require('@grafana/e2e-selectors');
|
|
15
15
|
var css = require('@emotion/css');
|
|
16
|
+
var uFuzzy = require('@leeoniya/ufuzzy');
|
|
16
17
|
var react = require('@floating-ui/react');
|
|
17
18
|
var reactVirtual = require('@tanstack/react-virtual');
|
|
18
|
-
var uFuzzy = require('@leeoniya/ufuzzy');
|
|
19
19
|
var reactUse = require('react-use');
|
|
20
20
|
var operators = require('rxjs/operators');
|
|
21
21
|
var ReactGridLayout = require('react-grid-layout');
|
|
@@ -468,6 +468,13 @@ class SceneObjectBase {
|
|
|
468
468
|
}
|
|
469
469
|
return this._ref;
|
|
470
470
|
}
|
|
471
|
+
toJSON() {
|
|
472
|
+
return {
|
|
473
|
+
type: Object.getPrototypeOf(this).constructor.name,
|
|
474
|
+
isActive: this.isActive,
|
|
475
|
+
state: this.state
|
|
476
|
+
};
|
|
477
|
+
}
|
|
471
478
|
}
|
|
472
479
|
function useSceneObjectState(model, options) {
|
|
473
480
|
var _a;
|
|
@@ -2833,14 +2840,44 @@ function findActiveGroupByVariablesByUid(dsUid) {
|
|
|
2833
2840
|
return void 0;
|
|
2834
2841
|
}
|
|
2835
2842
|
|
|
2843
|
+
const REGEXP_NON_ASCII = /[^ -~]/m;
|
|
2844
|
+
const REGEXP_ONLY_SYMBOLS = /^[\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]+$/m;
|
|
2845
|
+
const outOfOrderLimit = 5;
|
|
2846
|
+
const maxNeedleLength = 25;
|
|
2847
|
+
const maxFuzzyTerms = 5;
|
|
2848
|
+
const rankThreshold = 1e4;
|
|
2849
|
+
const uf = new uFuzzy__default["default"]({ intraMode: 1 });
|
|
2850
|
+
function fuzzyFind(options, haystack, needle) {
|
|
2851
|
+
let matches = [];
|
|
2852
|
+
if (needle === "") {
|
|
2853
|
+
matches = options;
|
|
2854
|
+
} else if (REGEXP_NON_ASCII.test(needle) || REGEXP_ONLY_SYMBOLS.test(needle) || needle.length > maxNeedleLength || uf.split(needle).length > maxFuzzyTerms) {
|
|
2855
|
+
for (let i = 0; i < haystack.length; i++) {
|
|
2856
|
+
let item = haystack[i];
|
|
2857
|
+
if (item.includes(needle)) {
|
|
2858
|
+
matches.push(options[i]);
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
} else {
|
|
2862
|
+
const [idxs, info, order] = uf.search(haystack, needle, outOfOrderLimit, rankThreshold);
|
|
2863
|
+
if (idxs == null ? void 0 : idxs.length) {
|
|
2864
|
+
if (info && order) {
|
|
2865
|
+
matches = order.map((idx) => options[info.idx[idx]]);
|
|
2866
|
+
} else {
|
|
2867
|
+
matches = idxs.map((idx) => options[idx]);
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
return matches;
|
|
2872
|
+
}
|
|
2873
|
+
|
|
2836
2874
|
function getOptionSearcher(options, includeAll = false) {
|
|
2837
2875
|
let allOptions = options;
|
|
2838
2876
|
if (includeAll) {
|
|
2839
2877
|
allOptions = [{ value: ALL_VARIABLE_VALUE, label: ALL_VARIABLE_TEXT }, ...allOptions];
|
|
2840
2878
|
}
|
|
2841
2879
|
const haystack = allOptions.map((o) => o.label);
|
|
2842
|
-
|
|
2843
|
-
return (search) => fuzzySearch(search).map((i) => allOptions[i]);
|
|
2880
|
+
return (search) => fuzzyFind(allOptions, haystack, search);
|
|
2844
2881
|
}
|
|
2845
2882
|
|
|
2846
2883
|
var __defProp$G = Object.defineProperty;
|
|
@@ -3233,7 +3270,7 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
3233
3270
|
this.isLazy = true;
|
|
3234
3271
|
this._urlSync = new GroupByVariableUrlSyncHandler(this);
|
|
3235
3272
|
this._getKeys = async (ds) => {
|
|
3236
|
-
var _a, _b, _c
|
|
3273
|
+
var _a, _b, _c;
|
|
3237
3274
|
const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, null));
|
|
3238
3275
|
if (override && override.replace) {
|
|
3239
3276
|
return override.values;
|
|
@@ -3250,8 +3287,7 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
3250
3287
|
const response = await ds.getTagKeys(__spreadValues$F({
|
|
3251
3288
|
filters: otherFilters,
|
|
3252
3289
|
queries,
|
|
3253
|
-
timeRange
|
|
3254
|
-
scopes: (_d = this._scopesBridge) == null ? void 0 : _d.getValue()
|
|
3290
|
+
timeRange
|
|
3255
3291
|
}, getEnrichedFiltersRequest(this)));
|
|
3256
3292
|
if (responseHasError(response)) {
|
|
3257
3293
|
this.setState({ error: response.error.message });
|
|
@@ -3605,8 +3641,7 @@ function getAdhocOptionSearcher(options) {
|
|
|
3605
3641
|
var _a;
|
|
3606
3642
|
return (_a = o.label) != null ? _a : String(o.value);
|
|
3607
3643
|
});
|
|
3608
|
-
|
|
3609
|
-
return (search) => fuzzySearch(search).map((i) => options[i]);
|
|
3644
|
+
return (search) => fuzzyFind(options, haystack, search);
|
|
3610
3645
|
}
|
|
3611
3646
|
|
|
3612
3647
|
var __defProp$E = Object.defineProperty;
|
|
@@ -4142,26 +4177,6 @@ const VIRTUAL_LIST_OVERSCAN = 5;
|
|
|
4142
4177
|
const VIRTUAL_LIST_ITEM_HEIGHT = 38;
|
|
4143
4178
|
const VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION = 60;
|
|
4144
4179
|
const ERROR_STATE_DROPDOWN_WIDTH = 366;
|
|
4145
|
-
const REGEXP_NON_ASCII = /[^ -~]/m;
|
|
4146
|
-
function searchOptions(options) {
|
|
4147
|
-
const haystack = options.map((o) => {
|
|
4148
|
-
var _a;
|
|
4149
|
-
return (_a = o.label) != null ? _a : o.value;
|
|
4150
|
-
});
|
|
4151
|
-
const fuzzySearch = getFuzzySearcher(haystack);
|
|
4152
|
-
return (search, filterInputType) => {
|
|
4153
|
-
if (REGEXP_NON_ASCII.test(search)) {
|
|
4154
|
-
return options.filter((o) => {
|
|
4155
|
-
var _a, _b;
|
|
4156
|
-
return ((_a = o.label) == null ? void 0 : _a.includes(search)) || ((_b = o.value) == null ? void 0 : _b.includes(search)) || false;
|
|
4157
|
-
});
|
|
4158
|
-
}
|
|
4159
|
-
if (filterInputType === "operator" && search !== "") {
|
|
4160
|
-
search = `"${search}"`;
|
|
4161
|
-
}
|
|
4162
|
-
return fuzzySearch(search).map((i) => options[i]);
|
|
4163
|
-
};
|
|
4164
|
-
}
|
|
4165
4180
|
const flattenOptionGroups = (options) => options.flatMap((option) => option.options ? [option, ...option.options] : [option]);
|
|
4166
4181
|
const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
|
|
4167
4182
|
var _a, _b, _c, _d;
|
|
@@ -4501,7 +4516,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
|
4501
4516
|
const listRef = React.useRef([]);
|
|
4502
4517
|
const disabledIndicesRef = React.useRef([]);
|
|
4503
4518
|
const filterInputTypeRef = React.useRef(!isAlwaysWip ? "value" : "key");
|
|
4504
|
-
const optionsSearcher = React.useMemo(() =>
|
|
4519
|
+
const optionsSearcher = React.useMemo(() => getAdhocOptionSearcher(options), [options]);
|
|
4505
4520
|
const isLastFilter = React.useMemo(() => {
|
|
4506
4521
|
if (isAlwaysWip) {
|
|
4507
4522
|
return false;
|
|
@@ -4610,7 +4625,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
|
4610
4625
|
[refs.domReference]
|
|
4611
4626
|
);
|
|
4612
4627
|
const filteredDropDownItems = flattenOptionGroups(
|
|
4613
|
-
handleOptionGroups(optionsSearcher(preventFiltering ? "" : inputValue
|
|
4628
|
+
handleOptionGroups(optionsSearcher(preventFiltering ? "" : inputValue))
|
|
4614
4629
|
);
|
|
4615
4630
|
if (allowCustomValue && filterInputType !== "operator" && inputValue) {
|
|
4616
4631
|
filteredDropDownItems.push({
|
|
@@ -5407,13 +5422,9 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5407
5422
|
this._scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };
|
|
5408
5423
|
this._dataSourceSrv = runtime.getDataSourceSrv();
|
|
5409
5424
|
this._urlSync = new AdHocFiltersVariableUrlSyncHandler(this);
|
|
5410
|
-
this._activationHandler = () => {
|
|
5411
|
-
this._scopesBridge = sceneGraph.getScopesBridge(this);
|
|
5412
|
-
};
|
|
5413
5425
|
if (this.state.applyMode === "auto") {
|
|
5414
5426
|
patchGetAdhocFilters(this);
|
|
5415
5427
|
}
|
|
5416
|
-
this.addActivationHandler(this._activationHandler);
|
|
5417
5428
|
}
|
|
5418
5429
|
setState(update) {
|
|
5419
5430
|
let filterExpressionChanged = false;
|
|
@@ -5497,7 +5508,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5497
5508
|
}
|
|
5498
5509
|
}
|
|
5499
5510
|
async _getKeys(currentKey) {
|
|
5500
|
-
var _a, _b, _c
|
|
5511
|
+
var _a, _b, _c;
|
|
5501
5512
|
const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));
|
|
5502
5513
|
if (override && override.replace) {
|
|
5503
5514
|
return dataFromResponse(override.values).map(toSelectableValue);
|
|
@@ -5515,8 +5526,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5515
5526
|
const response = await ds.getTagKeys(__spreadValues$z({
|
|
5516
5527
|
filters: otherFilters,
|
|
5517
5528
|
queries,
|
|
5518
|
-
timeRange
|
|
5519
|
-
scopes: (_d = this._scopesBridge) == null ? void 0 : _d.getValue()
|
|
5529
|
+
timeRange
|
|
5520
5530
|
}, getEnrichedFiltersRequest(this)));
|
|
5521
5531
|
if (responseHasError(response)) {
|
|
5522
5532
|
this.setState({ error: response.error.message });
|
|
@@ -5532,7 +5542,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5532
5542
|
return keys.map(toSelectableValue);
|
|
5533
5543
|
}
|
|
5534
5544
|
async _getValuesFor(filter) {
|
|
5535
|
-
var _a, _b, _c
|
|
5545
|
+
var _a, _b, _c;
|
|
5536
5546
|
const override = await ((_b = (_a = this.state).getTagValuesProvider) == null ? void 0 : _b.call(_a, this, filter));
|
|
5537
5547
|
if (override && override.replace) {
|
|
5538
5548
|
return dataFromResponse(override.values).map(toSelectableValue);
|
|
@@ -5548,8 +5558,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5548
5558
|
key: filter.key,
|
|
5549
5559
|
filters: otherFilters,
|
|
5550
5560
|
timeRange,
|
|
5551
|
-
queries
|
|
5552
|
-
scopes: (_d = this._scopesBridge) == null ? void 0 : _d.getValue()
|
|
5561
|
+
queries
|
|
5553
5562
|
}, getEnrichedFiltersRequest(this)));
|
|
5554
5563
|
if (responseHasError(response)) {
|
|
5555
5564
|
this.setState({ error: response.error.message });
|
|
@@ -5737,7 +5746,6 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5737
5746
|
_onActivate() {
|
|
5738
5747
|
if (this.isQueryModeAuto()) {
|
|
5739
5748
|
const timeRange = sceneGraph.getTimeRange(this);
|
|
5740
|
-
const scopesBridge = sceneGraph.getScopesBridge(this);
|
|
5741
5749
|
const providers = this.getClosestExtraQueryProviders();
|
|
5742
5750
|
for (const provider of providers) {
|
|
5743
5751
|
this._subs.add(
|
|
@@ -5748,7 +5756,6 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5748
5756
|
})
|
|
5749
5757
|
);
|
|
5750
5758
|
}
|
|
5751
|
-
this.subscribeToScopesChanges(scopesBridge);
|
|
5752
5759
|
this.subscribeToTimeRangeChanges(timeRange);
|
|
5753
5760
|
if (this.shouldRunQueriesOnActivate()) {
|
|
5754
5761
|
this.runQueries();
|
|
@@ -5894,21 +5901,6 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5894
5901
|
isDataReadyToDisplay() {
|
|
5895
5902
|
return Boolean(this.state._hasFetchedData);
|
|
5896
5903
|
}
|
|
5897
|
-
subscribeToScopesChanges(scopesBridge) {
|
|
5898
|
-
if (!scopesBridge) {
|
|
5899
|
-
return;
|
|
5900
|
-
}
|
|
5901
|
-
if (this._scopesSubBridge === scopesBridge) {
|
|
5902
|
-
return;
|
|
5903
|
-
}
|
|
5904
|
-
if (this._scopesSub) {
|
|
5905
|
-
this._scopesSub.unsubscribe();
|
|
5906
|
-
}
|
|
5907
|
-
this._scopesSubBridge = scopesBridge;
|
|
5908
|
-
this._scopesSub = scopesBridge.subscribeToValue(() => {
|
|
5909
|
-
this.runWithTimeRangeAndScopes(sceneGraph.getTimeRange(this), scopesBridge);
|
|
5910
|
-
});
|
|
5911
|
-
}
|
|
5912
5904
|
subscribeToTimeRangeChanges(timeRange) {
|
|
5913
5905
|
if (this._timeSubRange === timeRange) {
|
|
5914
5906
|
return;
|
|
@@ -5918,17 +5910,15 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5918
5910
|
}
|
|
5919
5911
|
this._timeSubRange = timeRange;
|
|
5920
5912
|
this._timeSub = timeRange.subscribeToState(() => {
|
|
5921
|
-
this.
|
|
5913
|
+
this.runWithTimeRange(timeRange);
|
|
5922
5914
|
});
|
|
5923
5915
|
}
|
|
5924
5916
|
runQueries() {
|
|
5925
5917
|
const timeRange = sceneGraph.getTimeRange(this);
|
|
5926
|
-
const scopesBridge = sceneGraph.getScopesBridge(this);
|
|
5927
5918
|
if (this.isQueryModeAuto()) {
|
|
5928
5919
|
this.subscribeToTimeRangeChanges(timeRange);
|
|
5929
|
-
this.subscribeToScopesChanges(scopesBridge);
|
|
5930
5920
|
}
|
|
5931
|
-
this.
|
|
5921
|
+
this.runWithTimeRange(timeRange);
|
|
5932
5922
|
}
|
|
5933
5923
|
getMaxDataPoints() {
|
|
5934
5924
|
var _a;
|
|
@@ -5948,8 +5938,8 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5948
5938
|
data: __spreadProps$m(__spreadValues$y({}, this.state.data), { state: schema.LoadingState.Done })
|
|
5949
5939
|
});
|
|
5950
5940
|
}
|
|
5951
|
-
async
|
|
5952
|
-
var _a, _b, _c
|
|
5941
|
+
async runWithTimeRange(timeRange) {
|
|
5942
|
+
var _a, _b, _c;
|
|
5953
5943
|
if (!this.state.maxDataPoints && this.state.maxDataPointsFromWidth && !this._containerWidth) {
|
|
5954
5944
|
return;
|
|
5955
5945
|
}
|
|
@@ -5962,22 +5952,17 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5962
5952
|
this.setState({ data: __spreadProps$m(__spreadValues$y({}, (_b = this.state.data) != null ? _b : emptyPanelData), { state: schema.LoadingState.Loading }) });
|
|
5963
5953
|
return;
|
|
5964
5954
|
}
|
|
5965
|
-
if (scopesBridge == null ? void 0 : scopesBridge.isLoading()) {
|
|
5966
|
-
writeSceneLog("SceneQueryRunner", "Scopes are in loading state, skipping query execution");
|
|
5967
|
-
this.setState({ data: __spreadProps$m(__spreadValues$y({}, (_c = this.state.data) != null ? _c : emptyPanelData), { state: schema.LoadingState.Loading }) });
|
|
5968
|
-
return;
|
|
5969
|
-
}
|
|
5970
5955
|
const { queries } = this.state;
|
|
5971
5956
|
if (!(queries == null ? void 0 : queries.length)) {
|
|
5972
5957
|
this._setNoDataState();
|
|
5973
5958
|
return;
|
|
5974
5959
|
}
|
|
5975
5960
|
try {
|
|
5976
|
-
const datasource = (
|
|
5961
|
+
const datasource = (_c = this.state.datasource) != null ? _c : findFirstDatasource(queries);
|
|
5977
5962
|
const ds = await getDataSource(datasource, this._scopedVars);
|
|
5978
5963
|
this.findAndSubscribeToAdHocFilters(ds.uid);
|
|
5979
5964
|
const runRequest = runtime.getRunRequest();
|
|
5980
|
-
const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds
|
|
5965
|
+
const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds);
|
|
5981
5966
|
writeSceneLog("SceneQueryRunner", "Starting runRequest", this.state.key);
|
|
5982
5967
|
let stream = runRequest(ds, primary);
|
|
5983
5968
|
if (secondaries.length > 0) {
|
|
@@ -6016,7 +6001,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
6016
6001
|
clone["_results"].next({ origin: this, data: (_a = this.state.data) != null ? _a : emptyPanelData });
|
|
6017
6002
|
return clone;
|
|
6018
6003
|
}
|
|
6019
|
-
prepareRequests(timeRange, ds
|
|
6004
|
+
prepareRequests(timeRange, ds) {
|
|
6020
6005
|
var _a, _b;
|
|
6021
6006
|
const { minInterval, queries } = this.state;
|
|
6022
6007
|
let request = __spreadValues$y({
|
|
@@ -6036,8 +6021,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
6036
6021
|
to: timeRange.state.to
|
|
6037
6022
|
},
|
|
6038
6023
|
cacheTimeout: this.state.cacheTimeout,
|
|
6039
|
-
queryCachingTTL: this.state.queryCachingTTL
|
|
6040
|
-
scopes: scopesBridge == null ? void 0 : scopesBridge.getValue()
|
|
6024
|
+
queryCachingTTL: this.state.queryCachingTTL
|
|
6041
6025
|
}, getEnrichedDataRequest(this));
|
|
6042
6026
|
if (this._adhocFiltersVar) {
|
|
6043
6027
|
request.filters = [];
|
|
@@ -6310,27 +6294,6 @@ function handleOptionGroups(values) {
|
|
|
6310
6294
|
}
|
|
6311
6295
|
return result;
|
|
6312
6296
|
}
|
|
6313
|
-
function getFuzzySearcher(haystack, limit = 1e4) {
|
|
6314
|
-
const ufuzzy = new uFuzzy__default["default"]();
|
|
6315
|
-
const FIRST = Array.from({ length: Math.min(limit, haystack.length) }, (_, i) => i);
|
|
6316
|
-
return (search) => {
|
|
6317
|
-
if (search === "") {
|
|
6318
|
-
return FIRST;
|
|
6319
|
-
}
|
|
6320
|
-
const [idxs, info, order] = ufuzzy.search(haystack, search);
|
|
6321
|
-
if (idxs) {
|
|
6322
|
-
if (info && order) {
|
|
6323
|
-
const outIdxs = Array(Math.min(order.length, limit));
|
|
6324
|
-
for (let i = 0; i < outIdxs.length; i++) {
|
|
6325
|
-
outIdxs[i] = info.idx[order[i]];
|
|
6326
|
-
}
|
|
6327
|
-
return outIdxs;
|
|
6328
|
-
}
|
|
6329
|
-
return idxs.slice(0, limit);
|
|
6330
|
-
}
|
|
6331
|
-
return [];
|
|
6332
|
-
};
|
|
6333
|
-
}
|
|
6334
6297
|
|
|
6335
6298
|
var __defProp$x = Object.defineProperty;
|
|
6336
6299
|
var __defProps$l = Object.defineProperties;
|
|
@@ -7010,108 +6973,6 @@ function containsSearchFilter(query) {
|
|
|
7010
6973
|
return str.indexOf(SEARCH_FILTER_VARIABLE) > -1;
|
|
7011
6974
|
}
|
|
7012
6975
|
|
|
7013
|
-
class SceneScopesBridge extends SceneObjectBase {
|
|
7014
|
-
constructor() {
|
|
7015
|
-
super(...arguments);
|
|
7016
|
-
this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["scopes"] });
|
|
7017
|
-
this._renderBeforeActivation = true;
|
|
7018
|
-
this._contextSubject = new rxjs.BehaviorSubject(void 0);
|
|
7019
|
-
this._pendingScopes = null;
|
|
7020
|
-
}
|
|
7021
|
-
getUrlState() {
|
|
7022
|
-
var _a, _b, _c;
|
|
7023
|
-
return {
|
|
7024
|
-
scopes: (_c = this._pendingScopes) != null ? _c : ((_b = (_a = this.context) == null ? void 0 : _a.state.value) != null ? _b : []).map((scope) => scope.metadata.name)
|
|
7025
|
-
};
|
|
7026
|
-
}
|
|
7027
|
-
updateFromUrl(values) {
|
|
7028
|
-
var _a, _b;
|
|
7029
|
-
let scopes = (_a = values["scopes"]) != null ? _a : [];
|
|
7030
|
-
scopes = (Array.isArray(scopes) ? scopes : [scopes]).map(String);
|
|
7031
|
-
if (!this.context) {
|
|
7032
|
-
this._pendingScopes = scopes;
|
|
7033
|
-
return;
|
|
7034
|
-
}
|
|
7035
|
-
(_b = this.context) == null ? void 0 : _b.changeScopes(scopes);
|
|
7036
|
-
}
|
|
7037
|
-
getValue() {
|
|
7038
|
-
var _a, _b;
|
|
7039
|
-
return (_b = (_a = this.context) == null ? void 0 : _a.state.value) != null ? _b : [];
|
|
7040
|
-
}
|
|
7041
|
-
subscribeToValue(cb) {
|
|
7042
|
-
return this.contextObservable.pipe(
|
|
7043
|
-
rxjs.filter((context) => !!context && !context.state.loading),
|
|
7044
|
-
rxjs.pairwise(),
|
|
7045
|
-
rxjs.map(
|
|
7046
|
-
([prevContext, newContext]) => {
|
|
7047
|
-
var _a, _b;
|
|
7048
|
-
return [(_a = prevContext == null ? void 0 : prevContext.state.value) != null ? _a : [], (_b = newContext == null ? void 0 : newContext.state.value) != null ? _b : []];
|
|
7049
|
-
}
|
|
7050
|
-
),
|
|
7051
|
-
rxjs.filter(([prevScopes, newScopes]) => !lodash.isEqual(prevScopes, newScopes))
|
|
7052
|
-
).subscribe(([prevScopes, newScopes]) => {
|
|
7053
|
-
cb(newScopes, prevScopes);
|
|
7054
|
-
});
|
|
7055
|
-
}
|
|
7056
|
-
isLoading() {
|
|
7057
|
-
var _a, _b;
|
|
7058
|
-
return (_b = (_a = this.context) == null ? void 0 : _a.state.loading) != null ? _b : false;
|
|
7059
|
-
}
|
|
7060
|
-
subscribeToLoading(cb) {
|
|
7061
|
-
return this.contextObservable.pipe(
|
|
7062
|
-
rxjs.filter((context) => !!context),
|
|
7063
|
-
rxjs.pairwise(),
|
|
7064
|
-
rxjs.map(
|
|
7065
|
-
([prevContext, newContext]) => {
|
|
7066
|
-
var _a, _b;
|
|
7067
|
-
return [(_a = prevContext == null ? void 0 : prevContext.state.loading) != null ? _a : false, (_b = newContext == null ? void 0 : newContext.state.loading) != null ? _b : false];
|
|
7068
|
-
}
|
|
7069
|
-
),
|
|
7070
|
-
rxjs.filter(([prevLoading, newLoading]) => prevLoading !== newLoading)
|
|
7071
|
-
).subscribe(([_prevLoading, newLoading]) => {
|
|
7072
|
-
cb(newLoading);
|
|
7073
|
-
});
|
|
7074
|
-
}
|
|
7075
|
-
setEnabled(enabled) {
|
|
7076
|
-
var _a;
|
|
7077
|
-
(_a = this.context) == null ? void 0 : _a.setEnabled(enabled);
|
|
7078
|
-
}
|
|
7079
|
-
setReadOnly(readOnly) {
|
|
7080
|
-
var _a;
|
|
7081
|
-
(_a = this.context) == null ? void 0 : _a.setReadOnly(readOnly);
|
|
7082
|
-
}
|
|
7083
|
-
updateContext(newContext) {
|
|
7084
|
-
var _a, _b;
|
|
7085
|
-
if (this._pendingScopes && newContext) {
|
|
7086
|
-
setTimeout(() => {
|
|
7087
|
-
newContext == null ? void 0 : newContext.changeScopes(this._pendingScopes);
|
|
7088
|
-
this._pendingScopes = null;
|
|
7089
|
-
});
|
|
7090
|
-
}
|
|
7091
|
-
if (this.context !== newContext || ((_a = this.context) == null ? void 0 : _a.state) !== (newContext == null ? void 0 : newContext.state)) {
|
|
7092
|
-
const shouldUpdate = ((_b = this.context) == null ? void 0 : _b.state.value) !== (newContext == null ? void 0 : newContext.state.value);
|
|
7093
|
-
this._contextSubject.next(newContext);
|
|
7094
|
-
if (shouldUpdate) {
|
|
7095
|
-
this.forceRender();
|
|
7096
|
-
}
|
|
7097
|
-
}
|
|
7098
|
-
}
|
|
7099
|
-
get context() {
|
|
7100
|
-
return this._contextSubject.getValue();
|
|
7101
|
-
}
|
|
7102
|
-
get contextObservable() {
|
|
7103
|
-
return this._contextSubject.asObservable();
|
|
7104
|
-
}
|
|
7105
|
-
}
|
|
7106
|
-
SceneScopesBridge.Component = SceneScopesBridgeRenderer;
|
|
7107
|
-
function SceneScopesBridgeRenderer({ model }) {
|
|
7108
|
-
const context = runtime.useScopes();
|
|
7109
|
-
React.useEffect(() => {
|
|
7110
|
-
model.updateContext(context);
|
|
7111
|
-
}, [context, model]);
|
|
7112
|
-
return null;
|
|
7113
|
-
}
|
|
7114
|
-
|
|
7115
6976
|
function getVariables(sceneObject) {
|
|
7116
6977
|
var _a;
|
|
7117
6978
|
return (_a = getClosest(sceneObject, (s) => s.state.$variables)) != null ? _a : EmptyVariableSet;
|
|
@@ -7255,10 +7116,6 @@ function findDescendents(scene, descendentType) {
|
|
|
7255
7116
|
const targetScenes = findAllObjects(scene, isDescendentType);
|
|
7256
7117
|
return targetScenes.filter(isDescendentType);
|
|
7257
7118
|
}
|
|
7258
|
-
function getScopesBridge(sceneObject) {
|
|
7259
|
-
var _a;
|
|
7260
|
-
return (_a = findObject(sceneObject, (s) => s instanceof SceneScopesBridge)) != null ? _a : void 0;
|
|
7261
|
-
}
|
|
7262
7119
|
|
|
7263
7120
|
const sceneGraph = {
|
|
7264
7121
|
getVariables,
|
|
@@ -7275,8 +7132,7 @@ const sceneGraph = {
|
|
|
7275
7132
|
findAllObjects,
|
|
7276
7133
|
getAncestor,
|
|
7277
7134
|
getQueryController,
|
|
7278
|
-
findDescendents
|
|
7279
|
-
getScopesBridge
|
|
7135
|
+
findDescendents
|
|
7280
7136
|
};
|
|
7281
7137
|
|
|
7282
7138
|
class UniqueUrlKeyMapper {
|
|
@@ -13030,10 +12886,6 @@ class SplitLayout extends SceneObjectBase {
|
|
|
13030
12886
|
SplitLayout.Component = SplitLayoutRenderer;
|
|
13031
12887
|
|
|
13032
12888
|
class SceneApp extends SceneObjectBase {
|
|
13033
|
-
constructor() {
|
|
13034
|
-
super(...arguments);
|
|
13035
|
-
this._renderBeforeActivation = true;
|
|
13036
|
-
}
|
|
13037
12889
|
enrichDataRequest() {
|
|
13038
12890
|
return {
|
|
13039
12891
|
app: this.state.name || "app"
|
|
@@ -13041,10 +12893,8 @@ class SceneApp extends SceneObjectBase {
|
|
|
13041
12893
|
}
|
|
13042
12894
|
}
|
|
13043
12895
|
SceneApp.Component = ({ model }) => {
|
|
13044
|
-
const { pages
|
|
13045
|
-
return /* @__PURE__ */ React__default["default"].createElement(
|
|
13046
|
-
model: scopesBridge
|
|
13047
|
-
}), /* @__PURE__ */ React__default["default"].createElement(SceneAppContext.Provider, {
|
|
12896
|
+
const { pages } = model.useState();
|
|
12897
|
+
return /* @__PURE__ */ React__default["default"].createElement(SceneAppContext.Provider, {
|
|
13048
12898
|
value: model
|
|
13049
12899
|
}, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Routes, null, pages.map((page) => /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
13050
12900
|
key: page.state.url,
|
|
@@ -13052,7 +12902,7 @@ SceneApp.Component = ({ model }) => {
|
|
|
13052
12902
|
element: /* @__PURE__ */ React__default["default"].createElement(page.Component, {
|
|
13053
12903
|
model: page
|
|
13054
12904
|
})
|
|
13055
|
-
}))))
|
|
12905
|
+
}))));
|
|
13056
12906
|
};
|
|
13057
12907
|
const SceneAppContext = React.createContext(null);
|
|
13058
12908
|
const sceneAppCache = /* @__PURE__ */ new Map();
|
|
@@ -13407,21 +13257,6 @@ class SceneAppPage extends SceneObjectBase {
|
|
|
13407
13257
|
super(state);
|
|
13408
13258
|
this._sceneCache = /* @__PURE__ */ new Map();
|
|
13409
13259
|
this._drilldownCache = /* @__PURE__ */ new Map();
|
|
13410
|
-
this._activationHandler = () => {
|
|
13411
|
-
if (!this.state.useScopes) {
|
|
13412
|
-
return;
|
|
13413
|
-
}
|
|
13414
|
-
this._scopesBridge = sceneGraph.getScopesBridge(this);
|
|
13415
|
-
if (!this._scopesBridge) {
|
|
13416
|
-
throw new Error("Use of scopes is enabled but no scopes bridge found");
|
|
13417
|
-
}
|
|
13418
|
-
this._scopesBridge.setEnabled(true);
|
|
13419
|
-
return () => {
|
|
13420
|
-
var _a;
|
|
13421
|
-
(_a = this._scopesBridge) == null ? void 0 : _a.setEnabled(false);
|
|
13422
|
-
};
|
|
13423
|
-
};
|
|
13424
|
-
this.addActivationHandler(this._activationHandler);
|
|
13425
13260
|
}
|
|
13426
13261
|
initializeScene(scene) {
|
|
13427
13262
|
this.setState({ initializedScene: scene });
|
|
@@ -14421,7 +14256,6 @@ exports.SceneObjectUrlSyncConfig = SceneObjectUrlSyncConfig;
|
|
|
14421
14256
|
exports.SceneQueryRunner = SceneQueryRunner;
|
|
14422
14257
|
exports.SceneReactObject = SceneReactObject;
|
|
14423
14258
|
exports.SceneRefreshPicker = SceneRefreshPicker;
|
|
14424
|
-
exports.SceneScopesBridge = SceneScopesBridge;
|
|
14425
14259
|
exports.SceneTimePicker = SceneTimePicker;
|
|
14426
14260
|
exports.SceneTimeRange = SceneTimeRange;
|
|
14427
14261
|
exports.SceneTimeRangeCompare = SceneTimeRangeCompare;
|