@grafana/scenes 6.0.3--canary.990.13366792126.0 → 6.1.0--canary.882.13435236858.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/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 +4 -23
- package/dist/esm/components/SceneApp/SceneAppPage.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/core/types.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/services/SceneObjectUrlSyncConfig.js +3 -3
- package/dist/esm/services/SceneObjectUrlSyncConfig.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/components/VariableValueSelect.js +3 -3
- package/dist/esm/variables/components/VariableValueSelect.js.map +1 -1
- package/dist/esm/variables/groupby/GroupByVariable.js +5 -5
- package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
- package/dist/esm/variables/variants/MultiValueVariable.js +17 -2
- package/dist/esm/variables/variants/MultiValueVariable.js.map +1 -1
- package/dist/index.d.ts +22 -58
- package/dist/index.js +48 -196
- 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
|
@@ -984,14 +984,14 @@ class SceneObjectUrlSyncConfig {
|
|
|
984
984
|
updateFromUrl(values) {
|
|
985
985
|
this._sceneObject.updateFromUrl(values);
|
|
986
986
|
}
|
|
987
|
+
shouldCreateHistoryStep(values) {
|
|
988
|
+
return this._nextChangeShouldAddHistoryStep;
|
|
989
|
+
}
|
|
987
990
|
performBrowserHistoryAction(callback) {
|
|
988
991
|
this._nextChangeShouldAddHistoryStep = true;
|
|
989
992
|
callback();
|
|
990
993
|
this._nextChangeShouldAddHistoryStep = false;
|
|
991
994
|
}
|
|
992
|
-
shouldCreateHistoryStep(values) {
|
|
993
|
-
return this._nextChangeShouldAddHistoryStep;
|
|
994
|
-
}
|
|
995
995
|
}
|
|
996
996
|
|
|
997
997
|
const INTERVAL_STRING_REGEX = /^\d+[yYmMsSwWhHdD]$/;
|
|
@@ -1896,7 +1896,8 @@ class MultiValueVariable extends SceneObjectBase {
|
|
|
1896
1896
|
return { value: "", text: "" };
|
|
1897
1897
|
}
|
|
1898
1898
|
}
|
|
1899
|
-
changeValueTo(value, text) {
|
|
1899
|
+
changeValueTo(value, text, isUserAction = false) {
|
|
1900
|
+
var _a, _b;
|
|
1900
1901
|
if (value === this.state.value && text === this.state.text) {
|
|
1901
1902
|
return;
|
|
1902
1903
|
}
|
|
@@ -1926,7 +1927,12 @@ class MultiValueVariable extends SceneObjectBase {
|
|
|
1926
1927
|
if (lodash.isEqual(value, this.state.value) && lodash.isEqual(text, this.state.text)) {
|
|
1927
1928
|
return;
|
|
1928
1929
|
}
|
|
1929
|
-
this.setStateHelper({ value, text, loading: false });
|
|
1930
|
+
const stateChangeAction = () => this.setStateHelper({ value, text, loading: false });
|
|
1931
|
+
if (isUserAction) {
|
|
1932
|
+
(_b = (_a = this._urlSync).performBrowserHistoryAction) == null ? void 0 : _b.call(_a, stateChangeAction);
|
|
1933
|
+
} else {
|
|
1934
|
+
stateChangeAction();
|
|
1935
|
+
}
|
|
1930
1936
|
this.publishEvent(new SceneVariableValueChangedEvent(this), true);
|
|
1931
1937
|
}
|
|
1932
1938
|
findLabelTextForValue(value) {
|
|
@@ -1980,6 +1986,7 @@ function findOptionMatchingCurrent(currentValue, currentText, options) {
|
|
|
1980
1986
|
class MultiValueUrlSyncHandler {
|
|
1981
1987
|
constructor(_sceneObject) {
|
|
1982
1988
|
this._sceneObject = _sceneObject;
|
|
1989
|
+
this._nextChangeShouldAddHistoryStep = false;
|
|
1983
1990
|
}
|
|
1984
1991
|
getKey() {
|
|
1985
1992
|
return `var-${this._sceneObject.state.name}`;
|
|
@@ -2020,6 +2027,14 @@ class MultiValueUrlSyncHandler {
|
|
|
2020
2027
|
this._sceneObject.changeValueTo(urlValue);
|
|
2021
2028
|
}
|
|
2022
2029
|
}
|
|
2030
|
+
performBrowserHistoryAction(callback) {
|
|
2031
|
+
this._nextChangeShouldAddHistoryStep = true;
|
|
2032
|
+
callback();
|
|
2033
|
+
this._nextChangeShouldAddHistoryStep = false;
|
|
2034
|
+
}
|
|
2035
|
+
shouldCreateHistoryStep(values) {
|
|
2036
|
+
return this._nextChangeShouldAddHistoryStep;
|
|
2037
|
+
}
|
|
2023
2038
|
}
|
|
2024
2039
|
function handleLegacyUrlAllValue(value) {
|
|
2025
2040
|
if (lodash.isArray(value) && value[0] === ALL_VARIABLE_TEXT) {
|
|
@@ -2915,7 +2930,7 @@ function VariableValueSelect({ model }) {
|
|
|
2915
2930
|
options: filteredOptions,
|
|
2916
2931
|
"data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`),
|
|
2917
2932
|
onChange: (newValue) => {
|
|
2918
|
-
model.changeValueTo(newValue.value, newValue.label);
|
|
2933
|
+
model.changeValueTo(newValue.value, newValue.label, true);
|
|
2919
2934
|
queryController == null ? void 0 : queryController.startProfile(model);
|
|
2920
2935
|
if (hasCustomValue !== newValue.__isNew__) {
|
|
2921
2936
|
setHasCustomValue(newValue.__isNew__);
|
|
@@ -2982,14 +2997,14 @@ function VariableValueSelectMulti({ model }) {
|
|
|
2982
2997
|
hideSelectedOptions: false,
|
|
2983
2998
|
onInputChange,
|
|
2984
2999
|
onBlur: () => {
|
|
2985
|
-
model.changeValueTo(uncommittedValue);
|
|
3000
|
+
model.changeValueTo(uncommittedValue, void 0, true);
|
|
2986
3001
|
queryController == null ? void 0 : queryController.startProfile(model);
|
|
2987
3002
|
},
|
|
2988
3003
|
filterOption: filterNoOp$2,
|
|
2989
3004
|
"data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`),
|
|
2990
3005
|
onChange: (newValue, action) => {
|
|
2991
3006
|
if (action.action === "clear" && noValueOnClear) {
|
|
2992
|
-
model.changeValueTo([]);
|
|
3007
|
+
model.changeValueTo([], void 0, true);
|
|
2993
3008
|
}
|
|
2994
3009
|
setUncommittedValue(newValue.map((x) => x.value));
|
|
2995
3010
|
}
|
|
@@ -3213,7 +3228,7 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
3213
3228
|
this.isLazy = true;
|
|
3214
3229
|
this._urlSync = new GroupByVariableUrlSyncHandler(this);
|
|
3215
3230
|
this._getKeys = async (ds) => {
|
|
3216
|
-
var _a, _b, _c
|
|
3231
|
+
var _a, _b, _c;
|
|
3217
3232
|
const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, null));
|
|
3218
3233
|
if (override && override.replace) {
|
|
3219
3234
|
return override.values;
|
|
@@ -3230,8 +3245,7 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
3230
3245
|
const response = await ds.getTagKeys(__spreadValues$F({
|
|
3231
3246
|
filters: otherFilters,
|
|
3232
3247
|
queries,
|
|
3233
|
-
timeRange
|
|
3234
|
-
scopes: (_d = this._scopesBridge) == null ? void 0 : _d.getValue()
|
|
3248
|
+
timeRange
|
|
3235
3249
|
}, getEnrichedFiltersRequest(this)));
|
|
3236
3250
|
if (responseHasError(response)) {
|
|
3237
3251
|
this.setState({ error: response.error.message });
|
|
@@ -3389,12 +3403,13 @@ function GroupByVariableRenderer({ model }) {
|
|
|
3389
3403
|
onBlur: () => {
|
|
3390
3404
|
model.changeValueTo(
|
|
3391
3405
|
uncommittedValue.map((x) => x.value),
|
|
3392
|
-
uncommittedValue.map((x) => x.label)
|
|
3406
|
+
uncommittedValue.map((x) => x.label),
|
|
3407
|
+
true
|
|
3393
3408
|
);
|
|
3394
3409
|
},
|
|
3395
3410
|
onChange: (newValue, action) => {
|
|
3396
3411
|
if (action.action === "clear" && noValueOnClear) {
|
|
3397
|
-
model.changeValueTo([]);
|
|
3412
|
+
model.changeValueTo([], void 0, true);
|
|
3398
3413
|
}
|
|
3399
3414
|
setUncommittedValue(newValue);
|
|
3400
3415
|
},
|
|
@@ -5368,13 +5383,9 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5368
5383
|
this._scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };
|
|
5369
5384
|
this._dataSourceSrv = runtime.getDataSourceSrv();
|
|
5370
5385
|
this._urlSync = new AdHocFiltersVariableUrlSyncHandler(this);
|
|
5371
|
-
this._activationHandler = () => {
|
|
5372
|
-
this._scopesBridge = sceneGraph.getScopesBridge(this);
|
|
5373
|
-
};
|
|
5374
5386
|
if (this.state.applyMode === "auto") {
|
|
5375
5387
|
patchGetAdhocFilters(this);
|
|
5376
5388
|
}
|
|
5377
|
-
this.addActivationHandler(this._activationHandler);
|
|
5378
5389
|
}
|
|
5379
5390
|
setState(update) {
|
|
5380
5391
|
let filterExpressionChanged = false;
|
|
@@ -5458,7 +5469,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5458
5469
|
}
|
|
5459
5470
|
}
|
|
5460
5471
|
async _getKeys(currentKey) {
|
|
5461
|
-
var _a, _b, _c
|
|
5472
|
+
var _a, _b, _c;
|
|
5462
5473
|
const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));
|
|
5463
5474
|
if (override && override.replace) {
|
|
5464
5475
|
return dataFromResponse(override.values).map(toSelectableValue);
|
|
@@ -5476,8 +5487,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5476
5487
|
const response = await ds.getTagKeys(__spreadValues$z({
|
|
5477
5488
|
filters: otherFilters,
|
|
5478
5489
|
queries,
|
|
5479
|
-
timeRange
|
|
5480
|
-
scopes: (_d = this._scopesBridge) == null ? void 0 : _d.getValue()
|
|
5490
|
+
timeRange
|
|
5481
5491
|
}, getEnrichedFiltersRequest(this)));
|
|
5482
5492
|
if (responseHasError(response)) {
|
|
5483
5493
|
this.setState({ error: response.error.message });
|
|
@@ -5493,7 +5503,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5493
5503
|
return keys.map(toSelectableValue);
|
|
5494
5504
|
}
|
|
5495
5505
|
async _getValuesFor(filter) {
|
|
5496
|
-
var _a, _b, _c
|
|
5506
|
+
var _a, _b, _c;
|
|
5497
5507
|
const override = await ((_b = (_a = this.state).getTagValuesProvider) == null ? void 0 : _b.call(_a, this, filter));
|
|
5498
5508
|
if (override && override.replace) {
|
|
5499
5509
|
return dataFromResponse(override.values).map(toSelectableValue);
|
|
@@ -5509,8 +5519,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5509
5519
|
key: filter.key,
|
|
5510
5520
|
filters: otherFilters,
|
|
5511
5521
|
timeRange,
|
|
5512
|
-
queries
|
|
5513
|
-
scopes: (_d = this._scopesBridge) == null ? void 0 : _d.getValue()
|
|
5522
|
+
queries
|
|
5514
5523
|
}, getEnrichedFiltersRequest(this)));
|
|
5515
5524
|
if (responseHasError(response)) {
|
|
5516
5525
|
this.setState({ error: response.error.message });
|
|
@@ -5698,7 +5707,6 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5698
5707
|
_onActivate() {
|
|
5699
5708
|
if (this.isQueryModeAuto()) {
|
|
5700
5709
|
const timeRange = sceneGraph.getTimeRange(this);
|
|
5701
|
-
const scopesBridge = sceneGraph.getScopesBridge(this);
|
|
5702
5710
|
const providers = this.getClosestExtraQueryProviders();
|
|
5703
5711
|
for (const provider of providers) {
|
|
5704
5712
|
this._subs.add(
|
|
@@ -5709,7 +5717,6 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5709
5717
|
})
|
|
5710
5718
|
);
|
|
5711
5719
|
}
|
|
5712
|
-
this.subscribeToScopesChanges(scopesBridge);
|
|
5713
5720
|
this.subscribeToTimeRangeChanges(timeRange);
|
|
5714
5721
|
if (this.shouldRunQueriesOnActivate()) {
|
|
5715
5722
|
this.runQueries();
|
|
@@ -5855,21 +5862,6 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5855
5862
|
isDataReadyToDisplay() {
|
|
5856
5863
|
return Boolean(this.state._hasFetchedData);
|
|
5857
5864
|
}
|
|
5858
|
-
subscribeToScopesChanges(scopesBridge) {
|
|
5859
|
-
if (!scopesBridge) {
|
|
5860
|
-
return;
|
|
5861
|
-
}
|
|
5862
|
-
if (this._scopesSubBridge === scopesBridge) {
|
|
5863
|
-
return;
|
|
5864
|
-
}
|
|
5865
|
-
if (this._scopesSub) {
|
|
5866
|
-
this._scopesSub.unsubscribe();
|
|
5867
|
-
}
|
|
5868
|
-
this._scopesSubBridge = scopesBridge;
|
|
5869
|
-
this._scopesSub = scopesBridge.subscribeToValue(() => {
|
|
5870
|
-
this.runWithTimeRangeAndScopes(sceneGraph.getTimeRange(this), scopesBridge);
|
|
5871
|
-
});
|
|
5872
|
-
}
|
|
5873
5865
|
subscribeToTimeRangeChanges(timeRange) {
|
|
5874
5866
|
if (this._timeSubRange === timeRange) {
|
|
5875
5867
|
return;
|
|
@@ -5879,17 +5871,15 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5879
5871
|
}
|
|
5880
5872
|
this._timeSubRange = timeRange;
|
|
5881
5873
|
this._timeSub = timeRange.subscribeToState(() => {
|
|
5882
|
-
this.
|
|
5874
|
+
this.runWithTimeRange(timeRange);
|
|
5883
5875
|
});
|
|
5884
5876
|
}
|
|
5885
5877
|
runQueries() {
|
|
5886
5878
|
const timeRange = sceneGraph.getTimeRange(this);
|
|
5887
|
-
const scopesBridge = sceneGraph.getScopesBridge(this);
|
|
5888
5879
|
if (this.isQueryModeAuto()) {
|
|
5889
5880
|
this.subscribeToTimeRangeChanges(timeRange);
|
|
5890
|
-
this.subscribeToScopesChanges(scopesBridge);
|
|
5891
5881
|
}
|
|
5892
|
-
this.
|
|
5882
|
+
this.runWithTimeRange(timeRange);
|
|
5893
5883
|
}
|
|
5894
5884
|
getMaxDataPoints() {
|
|
5895
5885
|
var _a;
|
|
@@ -5909,8 +5899,8 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5909
5899
|
data: __spreadProps$m(__spreadValues$y({}, this.state.data), { state: schema.LoadingState.Done })
|
|
5910
5900
|
});
|
|
5911
5901
|
}
|
|
5912
|
-
async
|
|
5913
|
-
var _a, _b, _c
|
|
5902
|
+
async runWithTimeRange(timeRange) {
|
|
5903
|
+
var _a, _b, _c;
|
|
5914
5904
|
if (!this.state.maxDataPoints && this.state.maxDataPointsFromWidth && !this._containerWidth) {
|
|
5915
5905
|
return;
|
|
5916
5906
|
}
|
|
@@ -5923,22 +5913,17 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5923
5913
|
this.setState({ data: __spreadProps$m(__spreadValues$y({}, (_b = this.state.data) != null ? _b : emptyPanelData), { state: schema.LoadingState.Loading }) });
|
|
5924
5914
|
return;
|
|
5925
5915
|
}
|
|
5926
|
-
if (scopesBridge == null ? void 0 : scopesBridge.isLoading()) {
|
|
5927
|
-
writeSceneLog("SceneQueryRunner", "Scopes are in loading state, skipping query execution");
|
|
5928
|
-
this.setState({ data: __spreadProps$m(__spreadValues$y({}, (_c = this.state.data) != null ? _c : emptyPanelData), { state: schema.LoadingState.Loading }) });
|
|
5929
|
-
return;
|
|
5930
|
-
}
|
|
5931
5916
|
const { queries } = this.state;
|
|
5932
5917
|
if (!(queries == null ? void 0 : queries.length)) {
|
|
5933
5918
|
this._setNoDataState();
|
|
5934
5919
|
return;
|
|
5935
5920
|
}
|
|
5936
5921
|
try {
|
|
5937
|
-
const datasource = (
|
|
5922
|
+
const datasource = (_c = this.state.datasource) != null ? _c : findFirstDatasource(queries);
|
|
5938
5923
|
const ds = await getDataSource(datasource, this._scopedVars);
|
|
5939
5924
|
this.findAndSubscribeToAdHocFilters(ds.uid);
|
|
5940
5925
|
const runRequest = runtime.getRunRequest();
|
|
5941
|
-
const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds
|
|
5926
|
+
const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds);
|
|
5942
5927
|
writeSceneLog("SceneQueryRunner", "Starting runRequest", this.state.key);
|
|
5943
5928
|
let stream = runRequest(ds, primary);
|
|
5944
5929
|
if (secondaries.length > 0) {
|
|
@@ -5977,7 +5962,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5977
5962
|
clone["_results"].next({ origin: this, data: (_a = this.state.data) != null ? _a : emptyPanelData });
|
|
5978
5963
|
return clone;
|
|
5979
5964
|
}
|
|
5980
|
-
prepareRequests(timeRange, ds
|
|
5965
|
+
prepareRequests(timeRange, ds) {
|
|
5981
5966
|
var _a;
|
|
5982
5967
|
const { minInterval, queries } = this.state;
|
|
5983
5968
|
let request = __spreadValues$y({
|
|
@@ -5997,8 +5982,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5997
5982
|
to: timeRange.state.to
|
|
5998
5983
|
},
|
|
5999
5984
|
cacheTimeout: this.state.cacheTimeout,
|
|
6000
|
-
queryCachingTTL: this.state.queryCachingTTL
|
|
6001
|
-
scopes: scopesBridge == null ? void 0 : scopesBridge.getValue()
|
|
5985
|
+
queryCachingTTL: this.state.queryCachingTTL
|
|
6002
5986
|
}, getEnrichedDataRequest(this));
|
|
6003
5987
|
if (this._adhocFiltersVar) {
|
|
6004
5988
|
request.filters = this._adhocFiltersVar.state.filters.filter(isFilterComplete);
|
|
@@ -6966,108 +6950,6 @@ function containsSearchFilter(query) {
|
|
|
6966
6950
|
return str.indexOf(SEARCH_FILTER_VARIABLE) > -1;
|
|
6967
6951
|
}
|
|
6968
6952
|
|
|
6969
|
-
class SceneScopesBridge extends SceneObjectBase {
|
|
6970
|
-
constructor() {
|
|
6971
|
-
super(...arguments);
|
|
6972
|
-
this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["scopes"] });
|
|
6973
|
-
this._renderBeforeActivation = true;
|
|
6974
|
-
this._contextSubject = new rxjs.BehaviorSubject(void 0);
|
|
6975
|
-
this._pendingScopes = null;
|
|
6976
|
-
}
|
|
6977
|
-
getUrlState() {
|
|
6978
|
-
var _a, _b, _c;
|
|
6979
|
-
return {
|
|
6980
|
-
scopes: (_c = this._pendingScopes) != null ? _c : ((_b = (_a = this.context) == null ? void 0 : _a.state.value) != null ? _b : []).map((scope) => scope.metadata.name)
|
|
6981
|
-
};
|
|
6982
|
-
}
|
|
6983
|
-
updateFromUrl(values) {
|
|
6984
|
-
var _a, _b;
|
|
6985
|
-
let scopes = (_a = values["scopes"]) != null ? _a : [];
|
|
6986
|
-
scopes = (Array.isArray(scopes) ? scopes : [scopes]).map(String);
|
|
6987
|
-
if (!this.context) {
|
|
6988
|
-
this._pendingScopes = scopes;
|
|
6989
|
-
return;
|
|
6990
|
-
}
|
|
6991
|
-
(_b = this.context) == null ? void 0 : _b.changeScopes(scopes);
|
|
6992
|
-
}
|
|
6993
|
-
getValue() {
|
|
6994
|
-
var _a, _b;
|
|
6995
|
-
return (_b = (_a = this.context) == null ? void 0 : _a.state.value) != null ? _b : [];
|
|
6996
|
-
}
|
|
6997
|
-
subscribeToValue(cb) {
|
|
6998
|
-
return this.contextObservable.pipe(
|
|
6999
|
-
rxjs.filter((context) => !!context && !context.state.loading),
|
|
7000
|
-
rxjs.pairwise(),
|
|
7001
|
-
rxjs.map(
|
|
7002
|
-
([prevContext, newContext]) => {
|
|
7003
|
-
var _a, _b;
|
|
7004
|
-
return [(_a = prevContext == null ? void 0 : prevContext.state.value) != null ? _a : [], (_b = newContext == null ? void 0 : newContext.state.value) != null ? _b : []];
|
|
7005
|
-
}
|
|
7006
|
-
),
|
|
7007
|
-
rxjs.filter(([prevScopes, newScopes]) => !lodash.isEqual(prevScopes, newScopes))
|
|
7008
|
-
).subscribe(([prevScopes, newScopes]) => {
|
|
7009
|
-
cb(newScopes, prevScopes);
|
|
7010
|
-
});
|
|
7011
|
-
}
|
|
7012
|
-
isLoading() {
|
|
7013
|
-
var _a, _b;
|
|
7014
|
-
return (_b = (_a = this.context) == null ? void 0 : _a.state.loading) != null ? _b : false;
|
|
7015
|
-
}
|
|
7016
|
-
subscribeToLoading(cb) {
|
|
7017
|
-
return this.contextObservable.pipe(
|
|
7018
|
-
rxjs.filter((context) => !!context),
|
|
7019
|
-
rxjs.pairwise(),
|
|
7020
|
-
rxjs.map(
|
|
7021
|
-
([prevContext, newContext]) => {
|
|
7022
|
-
var _a, _b;
|
|
7023
|
-
return [(_a = prevContext == null ? void 0 : prevContext.state.loading) != null ? _a : false, (_b = newContext == null ? void 0 : newContext.state.loading) != null ? _b : false];
|
|
7024
|
-
}
|
|
7025
|
-
),
|
|
7026
|
-
rxjs.filter(([prevLoading, newLoading]) => prevLoading !== newLoading)
|
|
7027
|
-
).subscribe(([_prevLoading, newLoading]) => {
|
|
7028
|
-
cb(newLoading);
|
|
7029
|
-
});
|
|
7030
|
-
}
|
|
7031
|
-
setEnabled(enabled) {
|
|
7032
|
-
var _a;
|
|
7033
|
-
(_a = this.context) == null ? void 0 : _a.setEnabled(enabled);
|
|
7034
|
-
}
|
|
7035
|
-
setReadOnly(readOnly) {
|
|
7036
|
-
var _a;
|
|
7037
|
-
(_a = this.context) == null ? void 0 : _a.setReadOnly(readOnly);
|
|
7038
|
-
}
|
|
7039
|
-
updateContext(newContext) {
|
|
7040
|
-
var _a, _b;
|
|
7041
|
-
if (this._pendingScopes && newContext) {
|
|
7042
|
-
setTimeout(() => {
|
|
7043
|
-
newContext == null ? void 0 : newContext.changeScopes(this._pendingScopes);
|
|
7044
|
-
this._pendingScopes = null;
|
|
7045
|
-
});
|
|
7046
|
-
}
|
|
7047
|
-
if (this.context !== newContext || ((_a = this.context) == null ? void 0 : _a.state) !== (newContext == null ? void 0 : newContext.state)) {
|
|
7048
|
-
const shouldUpdate = ((_b = this.context) == null ? void 0 : _b.state.value) !== (newContext == null ? void 0 : newContext.state.value);
|
|
7049
|
-
this._contextSubject.next(newContext);
|
|
7050
|
-
if (shouldUpdate) {
|
|
7051
|
-
this.forceRender();
|
|
7052
|
-
}
|
|
7053
|
-
}
|
|
7054
|
-
}
|
|
7055
|
-
get context() {
|
|
7056
|
-
return this._contextSubject.getValue();
|
|
7057
|
-
}
|
|
7058
|
-
get contextObservable() {
|
|
7059
|
-
return this._contextSubject.asObservable();
|
|
7060
|
-
}
|
|
7061
|
-
}
|
|
7062
|
-
SceneScopesBridge.Component = SceneScopesBridgeRenderer;
|
|
7063
|
-
function SceneScopesBridgeRenderer({ model }) {
|
|
7064
|
-
const context = runtime.useScopes();
|
|
7065
|
-
React.useEffect(() => {
|
|
7066
|
-
model.updateContext(context);
|
|
7067
|
-
}, [context, model]);
|
|
7068
|
-
return null;
|
|
7069
|
-
}
|
|
7070
|
-
|
|
7071
6953
|
function getVariables(sceneObject) {
|
|
7072
6954
|
var _a;
|
|
7073
6955
|
return (_a = getClosest(sceneObject, (s) => s.state.$variables)) != null ? _a : EmptyVariableSet;
|
|
@@ -7211,10 +7093,6 @@ function findDescendents(scene, descendentType) {
|
|
|
7211
7093
|
const targetScenes = findAllObjects(scene, isDescendentType);
|
|
7212
7094
|
return targetScenes.filter(isDescendentType);
|
|
7213
7095
|
}
|
|
7214
|
-
function getScopesBridge(sceneObject) {
|
|
7215
|
-
var _a;
|
|
7216
|
-
return (_a = findObject(sceneObject, (s) => s instanceof SceneScopesBridge)) != null ? _a : void 0;
|
|
7217
|
-
}
|
|
7218
7096
|
|
|
7219
7097
|
const sceneGraph = {
|
|
7220
7098
|
getVariables,
|
|
@@ -7231,8 +7109,7 @@ const sceneGraph = {
|
|
|
7231
7109
|
findAllObjects,
|
|
7232
7110
|
getAncestor,
|
|
7233
7111
|
getQueryController,
|
|
7234
|
-
findDescendents
|
|
7235
|
-
getScopesBridge
|
|
7112
|
+
findDescendents
|
|
7236
7113
|
};
|
|
7237
7114
|
|
|
7238
7115
|
class UniqueUrlKeyMapper {
|
|
@@ -12975,10 +12852,6 @@ class SplitLayout extends SceneObjectBase {
|
|
|
12975
12852
|
SplitLayout.Component = SplitLayoutRenderer;
|
|
12976
12853
|
|
|
12977
12854
|
class SceneApp extends SceneObjectBase {
|
|
12978
|
-
constructor() {
|
|
12979
|
-
super(...arguments);
|
|
12980
|
-
this._renderBeforeActivation = true;
|
|
12981
|
-
}
|
|
12982
12855
|
enrichDataRequest() {
|
|
12983
12856
|
return {
|
|
12984
12857
|
app: this.state.name || "app"
|
|
@@ -12986,10 +12859,8 @@ class SceneApp extends SceneObjectBase {
|
|
|
12986
12859
|
}
|
|
12987
12860
|
}
|
|
12988
12861
|
SceneApp.Component = ({ model }) => {
|
|
12989
|
-
const { pages
|
|
12990
|
-
return /* @__PURE__ */ React__default["default"].createElement(
|
|
12991
|
-
model: scopesBridge
|
|
12992
|
-
}), /* @__PURE__ */ React__default["default"].createElement(SceneAppContext.Provider, {
|
|
12862
|
+
const { pages } = model.useState();
|
|
12863
|
+
return /* @__PURE__ */ React__default["default"].createElement(SceneAppContext.Provider, {
|
|
12993
12864
|
value: model
|
|
12994
12865
|
}, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Routes, null, pages.map((page) => /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
12995
12866
|
key: page.state.url,
|
|
@@ -12997,7 +12868,7 @@ SceneApp.Component = ({ model }) => {
|
|
|
12997
12868
|
element: /* @__PURE__ */ React__default["default"].createElement(page.Component, {
|
|
12998
12869
|
model: page
|
|
12999
12870
|
})
|
|
13000
|
-
}))))
|
|
12871
|
+
}))));
|
|
13001
12872
|
};
|
|
13002
12873
|
const SceneAppContext = React.createContext(null);
|
|
13003
12874
|
const sceneAppCache = /* @__PURE__ */ new Map();
|
|
@@ -13352,21 +13223,6 @@ class SceneAppPage extends SceneObjectBase {
|
|
|
13352
13223
|
super(state);
|
|
13353
13224
|
this._sceneCache = /* @__PURE__ */ new Map();
|
|
13354
13225
|
this._drilldownCache = /* @__PURE__ */ new Map();
|
|
13355
|
-
this._activationHandler = () => {
|
|
13356
|
-
if (!this.state.useScopes) {
|
|
13357
|
-
return;
|
|
13358
|
-
}
|
|
13359
|
-
this._scopesBridge = sceneGraph.getScopesBridge(this);
|
|
13360
|
-
if (!this._scopesBridge) {
|
|
13361
|
-
throw new Error("Use of scopes is enabled but no scopes bridge found");
|
|
13362
|
-
}
|
|
13363
|
-
this._scopesBridge.setEnabled(true);
|
|
13364
|
-
return () => {
|
|
13365
|
-
var _a;
|
|
13366
|
-
(_a = this._scopesBridge) == null ? void 0 : _a.setEnabled(false);
|
|
13367
|
-
};
|
|
13368
|
-
};
|
|
13369
|
-
this.addActivationHandler(this._activationHandler);
|
|
13370
13226
|
}
|
|
13371
13227
|
initializeScene(scene) {
|
|
13372
13228
|
this.setState({ initializedScene: scene });
|
|
@@ -13474,16 +13330,13 @@ function SceneAppPageRenderer({ model }) {
|
|
|
13474
13330
|
return /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Routes, null, routes);
|
|
13475
13331
|
}
|
|
13476
13332
|
function getFallbackRoute(page) {
|
|
13333
|
+
var _a, _b, _c;
|
|
13477
13334
|
return /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
13478
13335
|
key: "fallback route",
|
|
13479
13336
|
path: "*",
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
return /* @__PURE__ */ React__default["default"].createElement(SceneAppPageView, {
|
|
13484
|
-
page: fallbackPage
|
|
13485
|
-
});
|
|
13486
|
-
}
|
|
13337
|
+
element: /* @__PURE__ */ React__default["default"].createElement(SceneAppPageView, {
|
|
13338
|
+
page: (_c = (_b = (_a = page.state).getFallbackPage) == null ? void 0 : _b.call(_a)) != null ? _c : getDefaultFallbackPage()
|
|
13339
|
+
})
|
|
13487
13340
|
});
|
|
13488
13341
|
}
|
|
13489
13342
|
function getDefaultFallbackPage() {
|
|
@@ -14366,7 +14219,6 @@ exports.SceneObjectUrlSyncConfig = SceneObjectUrlSyncConfig;
|
|
|
14366
14219
|
exports.SceneQueryRunner = SceneQueryRunner;
|
|
14367
14220
|
exports.SceneReactObject = SceneReactObject;
|
|
14368
14221
|
exports.SceneRefreshPicker = SceneRefreshPicker;
|
|
14369
|
-
exports.SceneScopesBridge = SceneScopesBridge;
|
|
14370
14222
|
exports.SceneTimePicker = SceneTimePicker;
|
|
14371
14223
|
exports.SceneTimeRange = SceneTimeRange;
|
|
14372
14224
|
exports.SceneTimeRangeCompare = SceneTimeRangeCompare;
|