@grafana/scenes 6.1.2--canary.1060.13501815546.0 → 6.1.2--canary.990.13540617999.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 +9 -3
- package/dist/esm/components/SceneApp/SceneApp.js.map +1 -1
- package/dist/esm/components/SceneApp/SceneAppPage.js +16 -0
- package/dist/esm/components/SceneApp/SceneAppPage.js.map +1 -1
- package/dist/esm/core/SceneScopesBridge.js +111 -0
- package/dist/esm/core/SceneScopesBridge.js.map +1 -0
- package/dist/esm/core/sceneGraph/index.js +3 -2
- package/dist/esm/core/sceneGraph/index.js.map +1 -1
- package/dist/esm/core/sceneGraph/sceneGraph.js +6 -1
- package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/querying/SceneQueryRunner.js +36 -16
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js +8 -14
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxRenderer.js +2 -9
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxRenderer.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +11 -10
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
- package/dist/esm/variables/groupby/GroupByVariable.js +3 -2
- package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
- package/dist/index.d.ts +56 -25
- package/dist/index.js +192 -55
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3228,7 +3228,7 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
3228
3228
|
this.isLazy = true;
|
|
3229
3229
|
this._urlSync = new GroupByVariableUrlSyncHandler(this);
|
|
3230
3230
|
this._getKeys = async (ds) => {
|
|
3231
|
-
var _a, _b, _c;
|
|
3231
|
+
var _a, _b, _c, _d;
|
|
3232
3232
|
const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, null));
|
|
3233
3233
|
if (override && override.replace) {
|
|
3234
3234
|
return override.values;
|
|
@@ -3245,7 +3245,8 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
3245
3245
|
const response = await ds.getTagKeys(__spreadValues$F({
|
|
3246
3246
|
filters: otherFilters,
|
|
3247
3247
|
queries,
|
|
3248
|
-
timeRange
|
|
3248
|
+
timeRange,
|
|
3249
|
+
scopes: (_d = this._scopesBridge) == null ? void 0 : _d.getValue()
|
|
3249
3250
|
}, getEnrichedFiltersRequest(this)));
|
|
3250
3251
|
if (responseHasError(response)) {
|
|
3251
3252
|
this.setState({ error: response.error.message });
|
|
@@ -5104,7 +5105,6 @@ var __spreadValues$A = (a, b) => {
|
|
|
5104
5105
|
return a;
|
|
5105
5106
|
};
|
|
5106
5107
|
var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
|
|
5107
|
-
const LABEL_MAX_VISIBLE_LENGTH = 20;
|
|
5108
5108
|
function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
|
|
5109
5109
|
var _a, _b, _c;
|
|
5110
5110
|
const styles = ui.useStyles2(getStyles$b);
|
|
@@ -5117,13 +5117,13 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
|
|
|
5117
5117
|
const handleChangeViewMode = React.useCallback(
|
|
5118
5118
|
(event, shouldFocusOnPillWrapperOverride) => {
|
|
5119
5119
|
event == null ? void 0 : event.stopPropagation();
|
|
5120
|
-
if (readOnly
|
|
5120
|
+
if (readOnly) {
|
|
5121
5121
|
return;
|
|
5122
5122
|
}
|
|
5123
5123
|
setShouldFocusOnPillWrapper(shouldFocusOnPillWrapperOverride != null ? shouldFocusOnPillWrapperOverride : !viewMode);
|
|
5124
5124
|
setViewMode(!viewMode);
|
|
5125
5125
|
},
|
|
5126
|
-
[readOnly, viewMode
|
|
5126
|
+
[readOnly, viewMode]
|
|
5127
5127
|
);
|
|
5128
5128
|
React.useEffect(() => {
|
|
5129
5129
|
var _a2;
|
|
@@ -5148,7 +5148,7 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
|
|
|
5148
5148
|
className: styles.pillText
|
|
5149
5149
|
}, keyLabel, " ", filter.operator, " ", valueLabel);
|
|
5150
5150
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
5151
|
-
className: css.cx(styles.combinedFilterPill,
|
|
5151
|
+
className: css.cx(styles.combinedFilterPill, { [styles.readOnlyCombinedFilter]: readOnly }),
|
|
5152
5152
|
onClick: (e) => {
|
|
5153
5153
|
e.stopPropagation();
|
|
5154
5154
|
setPopulateInputOnEdit(true);
|
|
@@ -5164,12 +5164,12 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
|
|
|
5164
5164
|
"aria-label": `Edit filter with key ${keyLabel}`,
|
|
5165
5165
|
tabIndex: 0,
|
|
5166
5166
|
ref: pillWrapperRef
|
|
5167
|
-
}, valueLabel.length <
|
|
5167
|
+
}, valueLabel.length < 20 ? pillText : /* @__PURE__ */ React__default["default"].createElement(ui.Tooltip, {
|
|
5168
5168
|
content: /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
5169
5169
|
className: styles.tooltipText
|
|
5170
5170
|
}, valueLabel),
|
|
5171
5171
|
placement: "top"
|
|
5172
|
-
}, pillText), !readOnly
|
|
5172
|
+
}, pillText), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
|
|
5173
5173
|
onClick: (e) => {
|
|
5174
5174
|
e.stopPropagation();
|
|
5175
5175
|
model._removeFilter(filter);
|
|
@@ -5185,14 +5185,9 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
|
|
|
5185
5185
|
},
|
|
5186
5186
|
name: "times",
|
|
5187
5187
|
size: "md",
|
|
5188
|
-
className: styles.
|
|
5188
|
+
className: styles.removeButton,
|
|
5189
5189
|
tooltip: `Remove filter with key ${keyLabel}`
|
|
5190
|
-
}) : null
|
|
5191
|
-
name: "info-circle",
|
|
5192
|
-
size: "md",
|
|
5193
|
-
className: styles.pillIcon,
|
|
5194
|
-
tooltip: `This is a ${filter.source} injected filter`
|
|
5195
|
-
}));
|
|
5190
|
+
}) : null);
|
|
5196
5191
|
}
|
|
5197
5192
|
return /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
|
|
5198
5193
|
filter,
|
|
@@ -5228,7 +5223,7 @@ const getStyles$b = (theme) => ({
|
|
|
5228
5223
|
background: theme.colors.action.selected
|
|
5229
5224
|
}
|
|
5230
5225
|
}),
|
|
5231
|
-
|
|
5226
|
+
removeButton: css.css({
|
|
5232
5227
|
marginInline: theme.spacing(0.5),
|
|
5233
5228
|
cursor: "pointer",
|
|
5234
5229
|
"&:hover": {
|
|
@@ -5262,7 +5257,7 @@ const AdHocFiltersAlwaysWipCombobox = React.forwardRef(function AdHocFiltersAlwa
|
|
|
5262
5257
|
});
|
|
5263
5258
|
|
|
5264
5259
|
const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({ model }) {
|
|
5265
|
-
const {
|
|
5260
|
+
const { filters, readOnly } = model.useState();
|
|
5266
5261
|
const styles = ui.useStyles2(getStyles$a);
|
|
5267
5262
|
const focusOnWipInputRef = React.useRef();
|
|
5268
5263
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
@@ -5275,14 +5270,7 @@ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRen
|
|
|
5275
5270
|
name: "filter",
|
|
5276
5271
|
className: styles.filterIcon,
|
|
5277
5272
|
size: "lg"
|
|
5278
|
-
}),
|
|
5279
|
-
(filter, index) => filter.source ? /* @__PURE__ */ React__default["default"].createElement(AdHocFilterPill, {
|
|
5280
|
-
key: `${index}-${filter.key}`,
|
|
5281
|
-
filter,
|
|
5282
|
-
model,
|
|
5283
|
-
focusOnWipInputRef: focusOnWipInputRef.current
|
|
5284
|
-
}) : null
|
|
5285
|
-
), filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(AdHocFilterPill, {
|
|
5273
|
+
}), filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(AdHocFilterPill, {
|
|
5286
5274
|
key: `${index}-${filter.key}`,
|
|
5287
5275
|
filter,
|
|
5288
5276
|
model,
|
|
@@ -5344,11 +5332,6 @@ var __spreadValues$z = (a, b) => {
|
|
|
5344
5332
|
return a;
|
|
5345
5333
|
};
|
|
5346
5334
|
var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
|
|
5347
|
-
var FilterSource = /* @__PURE__ */ ((FilterSource2) => {
|
|
5348
|
-
FilterSource2["Scopes"] = "scopes";
|
|
5349
|
-
FilterSource2["Dashboards"] = "dashboards";
|
|
5350
|
-
return FilterSource2;
|
|
5351
|
-
})(FilterSource || {});
|
|
5352
5335
|
const OPERATORS = [
|
|
5353
5336
|
{
|
|
5354
5337
|
value: "=",
|
|
@@ -5401,9 +5384,13 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5401
5384
|
this._scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };
|
|
5402
5385
|
this._dataSourceSrv = runtime.getDataSourceSrv();
|
|
5403
5386
|
this._urlSync = new AdHocFiltersVariableUrlSyncHandler(this);
|
|
5387
|
+
this._activationHandler = () => {
|
|
5388
|
+
this._scopesBridge = sceneGraph.getScopesBridge(this);
|
|
5389
|
+
};
|
|
5404
5390
|
if (this.state.applyMode === "auto") {
|
|
5405
5391
|
patchGetAdhocFilters(this);
|
|
5406
5392
|
}
|
|
5393
|
+
this.addActivationHandler(this._activationHandler);
|
|
5407
5394
|
}
|
|
5408
5395
|
setState(update) {
|
|
5409
5396
|
let filterExpressionChanged = false;
|
|
@@ -5487,7 +5474,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5487
5474
|
}
|
|
5488
5475
|
}
|
|
5489
5476
|
async _getKeys(currentKey) {
|
|
5490
|
-
var _a, _b, _c;
|
|
5477
|
+
var _a, _b, _c, _d;
|
|
5491
5478
|
const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));
|
|
5492
5479
|
if (override && override.replace) {
|
|
5493
5480
|
return dataFromResponse(override.values).map(toSelectableValue);
|
|
@@ -5505,7 +5492,8 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5505
5492
|
const response = await ds.getTagKeys(__spreadValues$z({
|
|
5506
5493
|
filters: otherFilters,
|
|
5507
5494
|
queries,
|
|
5508
|
-
timeRange
|
|
5495
|
+
timeRange,
|
|
5496
|
+
scopes: (_d = this._scopesBridge) == null ? void 0 : _d.getValue()
|
|
5509
5497
|
}, getEnrichedFiltersRequest(this)));
|
|
5510
5498
|
if (responseHasError(response)) {
|
|
5511
5499
|
this.setState({ error: response.error.message });
|
|
@@ -5521,7 +5509,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5521
5509
|
return keys.map(toSelectableValue);
|
|
5522
5510
|
}
|
|
5523
5511
|
async _getValuesFor(filter) {
|
|
5524
|
-
var _a, _b, _c;
|
|
5512
|
+
var _a, _b, _c, _d;
|
|
5525
5513
|
const override = await ((_b = (_a = this.state).getTagValuesProvider) == null ? void 0 : _b.call(_a, this, filter));
|
|
5526
5514
|
if (override && override.replace) {
|
|
5527
5515
|
return dataFromResponse(override.values).map(toSelectableValue);
|
|
@@ -5537,7 +5525,8 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5537
5525
|
key: filter.key,
|
|
5538
5526
|
filters: otherFilters,
|
|
5539
5527
|
timeRange,
|
|
5540
|
-
queries
|
|
5528
|
+
queries,
|
|
5529
|
+
scopes: (_d = this._scopesBridge) == null ? void 0 : _d.getValue()
|
|
5541
5530
|
}, getEnrichedFiltersRequest(this)));
|
|
5542
5531
|
if (responseHasError(response)) {
|
|
5543
5532
|
this.setState({ error: response.error.message });
|
|
@@ -5725,6 +5714,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5725
5714
|
_onActivate() {
|
|
5726
5715
|
if (this.isQueryModeAuto()) {
|
|
5727
5716
|
const timeRange = sceneGraph.getTimeRange(this);
|
|
5717
|
+
const scopesBridge = sceneGraph.getScopesBridge(this);
|
|
5728
5718
|
const providers = this.getClosestExtraQueryProviders();
|
|
5729
5719
|
for (const provider of providers) {
|
|
5730
5720
|
this._subs.add(
|
|
@@ -5735,6 +5725,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5735
5725
|
})
|
|
5736
5726
|
);
|
|
5737
5727
|
}
|
|
5728
|
+
this.subscribeToScopesChanges(scopesBridge);
|
|
5738
5729
|
this.subscribeToTimeRangeChanges(timeRange);
|
|
5739
5730
|
if (this.shouldRunQueriesOnActivate()) {
|
|
5740
5731
|
this.runQueries();
|
|
@@ -5880,6 +5871,21 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5880
5871
|
isDataReadyToDisplay() {
|
|
5881
5872
|
return Boolean(this.state._hasFetchedData);
|
|
5882
5873
|
}
|
|
5874
|
+
subscribeToScopesChanges(scopesBridge) {
|
|
5875
|
+
if (!scopesBridge) {
|
|
5876
|
+
return;
|
|
5877
|
+
}
|
|
5878
|
+
if (this._scopesSubBridge === scopesBridge) {
|
|
5879
|
+
return;
|
|
5880
|
+
}
|
|
5881
|
+
if (this._scopesSub) {
|
|
5882
|
+
this._scopesSub.unsubscribe();
|
|
5883
|
+
}
|
|
5884
|
+
this._scopesSubBridge = scopesBridge;
|
|
5885
|
+
this._scopesSub = scopesBridge.subscribeToValue(() => {
|
|
5886
|
+
this.runWithTimeRangeAndScopes(sceneGraph.getTimeRange(this), scopesBridge);
|
|
5887
|
+
});
|
|
5888
|
+
}
|
|
5883
5889
|
subscribeToTimeRangeChanges(timeRange) {
|
|
5884
5890
|
if (this._timeSubRange === timeRange) {
|
|
5885
5891
|
return;
|
|
@@ -5889,15 +5895,17 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5889
5895
|
}
|
|
5890
5896
|
this._timeSubRange = timeRange;
|
|
5891
5897
|
this._timeSub = timeRange.subscribeToState(() => {
|
|
5892
|
-
this.
|
|
5898
|
+
this.runWithTimeRangeAndScopes(timeRange, sceneGraph.getScopesBridge(this));
|
|
5893
5899
|
});
|
|
5894
5900
|
}
|
|
5895
5901
|
runQueries() {
|
|
5896
5902
|
const timeRange = sceneGraph.getTimeRange(this);
|
|
5903
|
+
const scopesBridge = sceneGraph.getScopesBridge(this);
|
|
5897
5904
|
if (this.isQueryModeAuto()) {
|
|
5898
5905
|
this.subscribeToTimeRangeChanges(timeRange);
|
|
5906
|
+
this.subscribeToScopesChanges(scopesBridge);
|
|
5899
5907
|
}
|
|
5900
|
-
this.
|
|
5908
|
+
this.runWithTimeRangeAndScopes(timeRange, scopesBridge);
|
|
5901
5909
|
}
|
|
5902
5910
|
getMaxDataPoints() {
|
|
5903
5911
|
var _a;
|
|
@@ -5917,8 +5925,8 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5917
5925
|
data: __spreadProps$m(__spreadValues$y({}, this.state.data), { state: schema.LoadingState.Done })
|
|
5918
5926
|
});
|
|
5919
5927
|
}
|
|
5920
|
-
async
|
|
5921
|
-
var _a, _b, _c;
|
|
5928
|
+
async runWithTimeRangeAndScopes(timeRange, scopesBridge) {
|
|
5929
|
+
var _a, _b, _c, _d;
|
|
5922
5930
|
if (!this.state.maxDataPoints && this.state.maxDataPointsFromWidth && !this._containerWidth) {
|
|
5923
5931
|
return;
|
|
5924
5932
|
}
|
|
@@ -5931,17 +5939,22 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5931
5939
|
this.setState({ data: __spreadProps$m(__spreadValues$y({}, (_b = this.state.data) != null ? _b : emptyPanelData), { state: schema.LoadingState.Loading }) });
|
|
5932
5940
|
return;
|
|
5933
5941
|
}
|
|
5942
|
+
if (scopesBridge == null ? void 0 : scopesBridge.isLoading()) {
|
|
5943
|
+
writeSceneLog("SceneQueryRunner", "Scopes are in loading state, skipping query execution");
|
|
5944
|
+
this.setState({ data: __spreadProps$m(__spreadValues$y({}, (_c = this.state.data) != null ? _c : emptyPanelData), { state: schema.LoadingState.Loading }) });
|
|
5945
|
+
return;
|
|
5946
|
+
}
|
|
5934
5947
|
const { queries } = this.state;
|
|
5935
5948
|
if (!(queries == null ? void 0 : queries.length)) {
|
|
5936
5949
|
this._setNoDataState();
|
|
5937
5950
|
return;
|
|
5938
5951
|
}
|
|
5939
5952
|
try {
|
|
5940
|
-
const datasource = (
|
|
5953
|
+
const datasource = (_d = this.state.datasource) != null ? _d : findFirstDatasource(queries);
|
|
5941
5954
|
const ds = await getDataSource(datasource, this._scopedVars);
|
|
5942
5955
|
this.findAndSubscribeToAdHocFilters(ds.uid);
|
|
5943
5956
|
const runRequest = runtime.getRunRequest();
|
|
5944
|
-
const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds);
|
|
5957
|
+
const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds, scopesBridge);
|
|
5945
5958
|
writeSceneLog("SceneQueryRunner", "Starting runRequest", this.state.key);
|
|
5946
5959
|
let stream = runRequest(ds, primary);
|
|
5947
5960
|
if (secondaries.length > 0) {
|
|
@@ -5980,8 +5993,8 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
5980
5993
|
clone["_results"].next({ origin: this, data: (_a = this.state.data) != null ? _a : emptyPanelData });
|
|
5981
5994
|
return clone;
|
|
5982
5995
|
}
|
|
5983
|
-
prepareRequests(timeRange, ds) {
|
|
5984
|
-
var _a
|
|
5996
|
+
prepareRequests(timeRange, ds, scopesBridge) {
|
|
5997
|
+
var _a;
|
|
5985
5998
|
const { minInterval, queries } = this.state;
|
|
5986
5999
|
let request = __spreadValues$y({
|
|
5987
6000
|
app: "scenes",
|
|
@@ -6000,15 +6013,11 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
6000
6013
|
to: timeRange.state.to
|
|
6001
6014
|
},
|
|
6002
6015
|
cacheTimeout: this.state.cacheTimeout,
|
|
6003
|
-
queryCachingTTL: this.state.queryCachingTTL
|
|
6016
|
+
queryCachingTTL: this.state.queryCachingTTL,
|
|
6017
|
+
scopes: scopesBridge == null ? void 0 : scopesBridge.getValue()
|
|
6004
6018
|
}, getEnrichedDataRequest(this));
|
|
6005
6019
|
if (this._adhocFiltersVar) {
|
|
6006
|
-
request.filters =
|
|
6007
|
-
if ((_a = this._adhocFiltersVar.state.baseFilters) == null ? void 0 : _a.length) {
|
|
6008
|
-
const injectedBaseFilters = this._adhocFiltersVar.state.baseFilters.filter((filter) => filter.source);
|
|
6009
|
-
request.filters = request.filters.concat(injectedBaseFilters);
|
|
6010
|
-
}
|
|
6011
|
-
request.filters = request.filters.concat(this._adhocFiltersVar.state.filters.filter(isFilterComplete));
|
|
6020
|
+
request.filters = this._adhocFiltersVar.state.filters.filter(isFilterComplete);
|
|
6012
6021
|
}
|
|
6013
6022
|
if (this._groupByVar) {
|
|
6014
6023
|
request.groupByKeys = this._groupByVar.state.value;
|
|
@@ -6031,7 +6040,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
6031
6040
|
const primaryTimeRange = timeRange.state.value;
|
|
6032
6041
|
let secondaryRequests = [];
|
|
6033
6042
|
let secondaryProcessors = /* @__PURE__ */ new Map();
|
|
6034
|
-
for (const provider of (
|
|
6043
|
+
for (const provider of (_a = this.getClosestExtraQueryProviders()) != null ? _a : []) {
|
|
6035
6044
|
for (const { req, processor } of provider.getExtraQueries(request)) {
|
|
6036
6045
|
const requestId = getNextRequestId$1();
|
|
6037
6046
|
secondaryRequests.push(__spreadProps$m(__spreadValues$y({}, req), { requestId }));
|
|
@@ -6973,6 +6982,108 @@ function containsSearchFilter(query) {
|
|
|
6973
6982
|
return str.indexOf(SEARCH_FILTER_VARIABLE) > -1;
|
|
6974
6983
|
}
|
|
6975
6984
|
|
|
6985
|
+
class SceneScopesBridge extends SceneObjectBase {
|
|
6986
|
+
constructor() {
|
|
6987
|
+
super(...arguments);
|
|
6988
|
+
this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["scopes"] });
|
|
6989
|
+
this._renderBeforeActivation = true;
|
|
6990
|
+
this._contextSubject = new rxjs.BehaviorSubject(void 0);
|
|
6991
|
+
this._pendingScopes = null;
|
|
6992
|
+
}
|
|
6993
|
+
getUrlState() {
|
|
6994
|
+
var _a, _b, _c;
|
|
6995
|
+
return {
|
|
6996
|
+
scopes: (_c = this._pendingScopes) != null ? _c : ((_b = (_a = this.context) == null ? void 0 : _a.state.value) != null ? _b : []).map((scope) => scope.metadata.name)
|
|
6997
|
+
};
|
|
6998
|
+
}
|
|
6999
|
+
updateFromUrl(values) {
|
|
7000
|
+
var _a, _b;
|
|
7001
|
+
let scopes = (_a = values["scopes"]) != null ? _a : [];
|
|
7002
|
+
scopes = (Array.isArray(scopes) ? scopes : [scopes]).map(String);
|
|
7003
|
+
if (!this.context) {
|
|
7004
|
+
this._pendingScopes = scopes;
|
|
7005
|
+
return;
|
|
7006
|
+
}
|
|
7007
|
+
(_b = this.context) == null ? void 0 : _b.changeScopes(scopes);
|
|
7008
|
+
}
|
|
7009
|
+
getValue() {
|
|
7010
|
+
var _a, _b;
|
|
7011
|
+
return (_b = (_a = this.context) == null ? void 0 : _a.state.value) != null ? _b : [];
|
|
7012
|
+
}
|
|
7013
|
+
subscribeToValue(cb) {
|
|
7014
|
+
return this.contextObservable.pipe(
|
|
7015
|
+
rxjs.filter((context) => !!context && !context.state.loading),
|
|
7016
|
+
rxjs.pairwise(),
|
|
7017
|
+
rxjs.map(
|
|
7018
|
+
([prevContext, newContext]) => {
|
|
7019
|
+
var _a, _b;
|
|
7020
|
+
return [(_a = prevContext == null ? void 0 : prevContext.state.value) != null ? _a : [], (_b = newContext == null ? void 0 : newContext.state.value) != null ? _b : []];
|
|
7021
|
+
}
|
|
7022
|
+
),
|
|
7023
|
+
rxjs.filter(([prevScopes, newScopes]) => !lodash.isEqual(prevScopes, newScopes))
|
|
7024
|
+
).subscribe(([prevScopes, newScopes]) => {
|
|
7025
|
+
cb(newScopes, prevScopes);
|
|
7026
|
+
});
|
|
7027
|
+
}
|
|
7028
|
+
isLoading() {
|
|
7029
|
+
var _a, _b;
|
|
7030
|
+
return (_b = (_a = this.context) == null ? void 0 : _a.state.loading) != null ? _b : false;
|
|
7031
|
+
}
|
|
7032
|
+
subscribeToLoading(cb) {
|
|
7033
|
+
return this.contextObservable.pipe(
|
|
7034
|
+
rxjs.filter((context) => !!context),
|
|
7035
|
+
rxjs.pairwise(),
|
|
7036
|
+
rxjs.map(
|
|
7037
|
+
([prevContext, newContext]) => {
|
|
7038
|
+
var _a, _b;
|
|
7039
|
+
return [(_a = prevContext == null ? void 0 : prevContext.state.loading) != null ? _a : false, (_b = newContext == null ? void 0 : newContext.state.loading) != null ? _b : false];
|
|
7040
|
+
}
|
|
7041
|
+
),
|
|
7042
|
+
rxjs.filter(([prevLoading, newLoading]) => prevLoading !== newLoading)
|
|
7043
|
+
).subscribe(([_prevLoading, newLoading]) => {
|
|
7044
|
+
cb(newLoading);
|
|
7045
|
+
});
|
|
7046
|
+
}
|
|
7047
|
+
setEnabled(enabled) {
|
|
7048
|
+
var _a;
|
|
7049
|
+
(_a = this.context) == null ? void 0 : _a.setEnabled(enabled);
|
|
7050
|
+
}
|
|
7051
|
+
setReadOnly(readOnly) {
|
|
7052
|
+
var _a;
|
|
7053
|
+
(_a = this.context) == null ? void 0 : _a.setReadOnly(readOnly);
|
|
7054
|
+
}
|
|
7055
|
+
updateContext(newContext) {
|
|
7056
|
+
var _a, _b;
|
|
7057
|
+
if (this._pendingScopes && newContext) {
|
|
7058
|
+
setTimeout(() => {
|
|
7059
|
+
newContext == null ? void 0 : newContext.changeScopes(this._pendingScopes);
|
|
7060
|
+
this._pendingScopes = null;
|
|
7061
|
+
});
|
|
7062
|
+
}
|
|
7063
|
+
if (this.context !== newContext || ((_a = this.context) == null ? void 0 : _a.state) !== (newContext == null ? void 0 : newContext.state)) {
|
|
7064
|
+
const shouldUpdate = ((_b = this.context) == null ? void 0 : _b.state.value) !== (newContext == null ? void 0 : newContext.state.value);
|
|
7065
|
+
this._contextSubject.next(newContext);
|
|
7066
|
+
if (shouldUpdate) {
|
|
7067
|
+
this.forceRender();
|
|
7068
|
+
}
|
|
7069
|
+
}
|
|
7070
|
+
}
|
|
7071
|
+
get context() {
|
|
7072
|
+
return this._contextSubject.getValue();
|
|
7073
|
+
}
|
|
7074
|
+
get contextObservable() {
|
|
7075
|
+
return this._contextSubject.asObservable();
|
|
7076
|
+
}
|
|
7077
|
+
}
|
|
7078
|
+
SceneScopesBridge.Component = SceneScopesBridgeRenderer;
|
|
7079
|
+
function SceneScopesBridgeRenderer({ model }) {
|
|
7080
|
+
const context = runtime.useScopes();
|
|
7081
|
+
React.useEffect(() => {
|
|
7082
|
+
model.updateContext(context);
|
|
7083
|
+
}, [context, model]);
|
|
7084
|
+
return null;
|
|
7085
|
+
}
|
|
7086
|
+
|
|
6976
7087
|
function getVariables(sceneObject) {
|
|
6977
7088
|
var _a;
|
|
6978
7089
|
return (_a = getClosest(sceneObject, (s) => s.state.$variables)) != null ? _a : EmptyVariableSet;
|
|
@@ -7116,6 +7227,10 @@ function findDescendents(scene, descendentType) {
|
|
|
7116
7227
|
const targetScenes = findAllObjects(scene, isDescendentType);
|
|
7117
7228
|
return targetScenes.filter(isDescendentType);
|
|
7118
7229
|
}
|
|
7230
|
+
function getScopesBridge(sceneObject) {
|
|
7231
|
+
var _a;
|
|
7232
|
+
return (_a = findObject(sceneObject, (s) => s instanceof SceneScopesBridge)) != null ? _a : void 0;
|
|
7233
|
+
}
|
|
7119
7234
|
|
|
7120
7235
|
const sceneGraph = {
|
|
7121
7236
|
getVariables,
|
|
@@ -7132,7 +7247,8 @@ const sceneGraph = {
|
|
|
7132
7247
|
findAllObjects,
|
|
7133
7248
|
getAncestor,
|
|
7134
7249
|
getQueryController,
|
|
7135
|
-
findDescendents
|
|
7250
|
+
findDescendents,
|
|
7251
|
+
getScopesBridge
|
|
7136
7252
|
};
|
|
7137
7253
|
|
|
7138
7254
|
class UniqueUrlKeyMapper {
|
|
@@ -12886,6 +13002,10 @@ class SplitLayout extends SceneObjectBase {
|
|
|
12886
13002
|
SplitLayout.Component = SplitLayoutRenderer;
|
|
12887
13003
|
|
|
12888
13004
|
class SceneApp extends SceneObjectBase {
|
|
13005
|
+
constructor() {
|
|
13006
|
+
super(...arguments);
|
|
13007
|
+
this._renderBeforeActivation = true;
|
|
13008
|
+
}
|
|
12889
13009
|
enrichDataRequest() {
|
|
12890
13010
|
return {
|
|
12891
13011
|
app: this.state.name || "app"
|
|
@@ -12893,8 +13013,10 @@ class SceneApp extends SceneObjectBase {
|
|
|
12893
13013
|
}
|
|
12894
13014
|
}
|
|
12895
13015
|
SceneApp.Component = ({ model }) => {
|
|
12896
|
-
const { pages } = model.useState();
|
|
12897
|
-
return /* @__PURE__ */ React__default["default"].createElement(
|
|
13016
|
+
const { pages, scopesBridge } = model.useState();
|
|
13017
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, scopesBridge && /* @__PURE__ */ React__default["default"].createElement(scopesBridge.Component, {
|
|
13018
|
+
model: scopesBridge
|
|
13019
|
+
}), /* @__PURE__ */ React__default["default"].createElement(SceneAppContext.Provider, {
|
|
12898
13020
|
value: model
|
|
12899
13021
|
}, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Routes, null, pages.map((page) => /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
12900
13022
|
key: page.state.url,
|
|
@@ -12902,7 +13024,7 @@ SceneApp.Component = ({ model }) => {
|
|
|
12902
13024
|
element: /* @__PURE__ */ React__default["default"].createElement(page.Component, {
|
|
12903
13025
|
model: page
|
|
12904
13026
|
})
|
|
12905
|
-
}))));
|
|
13027
|
+
})))));
|
|
12906
13028
|
};
|
|
12907
13029
|
const SceneAppContext = React.createContext(null);
|
|
12908
13030
|
const sceneAppCache = /* @__PURE__ */ new Map();
|
|
@@ -13257,6 +13379,21 @@ class SceneAppPage extends SceneObjectBase {
|
|
|
13257
13379
|
super(state);
|
|
13258
13380
|
this._sceneCache = /* @__PURE__ */ new Map();
|
|
13259
13381
|
this._drilldownCache = /* @__PURE__ */ new Map();
|
|
13382
|
+
this._activationHandler = () => {
|
|
13383
|
+
if (!this.state.useScopes) {
|
|
13384
|
+
return;
|
|
13385
|
+
}
|
|
13386
|
+
this._scopesBridge = sceneGraph.getScopesBridge(this);
|
|
13387
|
+
if (!this._scopesBridge) {
|
|
13388
|
+
throw new Error("Use of scopes is enabled but no scopes bridge found");
|
|
13389
|
+
}
|
|
13390
|
+
this._scopesBridge.setEnabled(true);
|
|
13391
|
+
return () => {
|
|
13392
|
+
var _a;
|
|
13393
|
+
(_a = this._scopesBridge) == null ? void 0 : _a.setEnabled(false);
|
|
13394
|
+
};
|
|
13395
|
+
};
|
|
13396
|
+
this.addActivationHandler(this._activationHandler);
|
|
13260
13397
|
}
|
|
13261
13398
|
initializeScene(scene) {
|
|
13262
13399
|
this.setState({ initializedScene: scene });
|
|
@@ -14215,7 +14352,6 @@ exports.EmbeddedScene = EmbeddedScene;
|
|
|
14215
14352
|
exports.FieldConfigBuilder = FieldConfigBuilder;
|
|
14216
14353
|
exports.FieldConfigBuilders = FieldConfigBuilders;
|
|
14217
14354
|
exports.FieldConfigOverridesBuilder = FieldConfigOverridesBuilder;
|
|
14218
|
-
exports.FilterSource = FilterSource;
|
|
14219
14355
|
exports.GroupByVariable = GroupByVariable;
|
|
14220
14356
|
exports.IntervalVariable = IntervalVariable;
|
|
14221
14357
|
exports.LazyLoader = LazyLoader;
|
|
@@ -14256,6 +14392,7 @@ exports.SceneObjectUrlSyncConfig = SceneObjectUrlSyncConfig;
|
|
|
14256
14392
|
exports.SceneQueryRunner = SceneQueryRunner;
|
|
14257
14393
|
exports.SceneReactObject = SceneReactObject;
|
|
14258
14394
|
exports.SceneRefreshPicker = SceneRefreshPicker;
|
|
14395
|
+
exports.SceneScopesBridge = SceneScopesBridge;
|
|
14259
14396
|
exports.SceneTimePicker = SceneTimePicker;
|
|
14260
14397
|
exports.SceneTimeRange = SceneTimeRange;
|
|
14261
14398
|
exports.SceneTimeRangeCompare = SceneTimeRangeCompare;
|