@grafana/scenes 8.1.0 → 8.1.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 +12 -0
- package/dist/esm/core/sceneGraph/getReportInteractionHandler.js +14 -0
- package/dist/esm/core/sceneGraph/getReportInteractionHandler.js.map +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersRecommendations.js +9 -9
- package/dist/esm/variables/adhoc/AdHocFiltersRecommendations.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +24 -32
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.js +40 -39
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6147,6 +6147,16 @@ const getStyles$j = (theme) => ({
|
|
|
6147
6147
|
})
|
|
6148
6148
|
});
|
|
6149
6149
|
|
|
6150
|
+
function isAdHocFilterInteractionHandler(s) {
|
|
6151
|
+
return "isAdHocFilterInteractionHandler" in s;
|
|
6152
|
+
}
|
|
6153
|
+
function getAdHocFilterInteractionHandler(sceneObject) {
|
|
6154
|
+
return getClosest(sceneObject, (s) => {
|
|
6155
|
+
var _a;
|
|
6156
|
+
return (_a = s.state.$behaviors) == null ? void 0 : _a.find(isAdHocFilterInteractionHandler);
|
|
6157
|
+
});
|
|
6158
|
+
}
|
|
6159
|
+
|
|
6150
6160
|
class AdHocFiltersVariableUrlSyncHandler {
|
|
6151
6161
|
constructor(_variable) {
|
|
6152
6162
|
this._variable = _variable;
|
|
@@ -8472,10 +8482,11 @@ function AdHocFiltersRecommendationsRenderer({ model }) {
|
|
|
8472
8482
|
const recentDrilldowns = recentFilters == null ? void 0 : recentFilters.map((filter) => ({
|
|
8473
8483
|
label: `${filter.key} ${filter.operator} ${filter.value}`,
|
|
8474
8484
|
onClick: () => {
|
|
8485
|
+
var _a, _b;
|
|
8475
8486
|
const exists = filters.some((f) => f.key === filter.key && f.value === filter.value);
|
|
8476
8487
|
if (!exists) {
|
|
8477
8488
|
model.addFilterToParent(filter);
|
|
8478
|
-
|
|
8489
|
+
(_b = (_a = getAdHocFilterInteractionHandler(model)) == null ? void 0 : _a.onRecentFilterApplied) == null ? void 0 : _b.call(_a, {
|
|
8479
8490
|
key: filter.key,
|
|
8480
8491
|
operator: filter.operator
|
|
8481
8492
|
});
|
|
@@ -8485,10 +8496,11 @@ function AdHocFiltersRecommendationsRenderer({ model }) {
|
|
|
8485
8496
|
const recommendedDrilldowns = recommendedFilters == null ? void 0 : recommendedFilters.map((filter) => ({
|
|
8486
8497
|
label: `${filter.key} ${filter.operator} ${filter.value}`,
|
|
8487
8498
|
onClick: () => {
|
|
8499
|
+
var _a, _b;
|
|
8488
8500
|
const exists = filters.some((f) => f.key === filter.key && f.value === filter.value);
|
|
8489
8501
|
if (!exists) {
|
|
8490
8502
|
model.addFilterToParent(filter);
|
|
8491
|
-
|
|
8503
|
+
(_b = (_a = getAdHocFilterInteractionHandler(model)) == null ? void 0 : _a.onRecommendedFilterApplied) == null ? void 0 : _b.call(_a, {
|
|
8492
8504
|
key: filter.key,
|
|
8493
8505
|
operator: filter.operator
|
|
8494
8506
|
});
|
|
@@ -8509,19 +8521,17 @@ function AdHocGroupByRecommendationsRenderer({ model }) {
|
|
|
8509
8521
|
const recentDrilldowns = recentGrouping == null ? void 0 : recentGrouping.map((groupBy) => ({
|
|
8510
8522
|
label: `${groupBy.value}`,
|
|
8511
8523
|
onClick: () => {
|
|
8524
|
+
var _a, _b;
|
|
8512
8525
|
model.addGroupByToParent(String(groupBy.value));
|
|
8513
|
-
|
|
8514
|
-
key: String(groupBy.value)
|
|
8515
|
-
});
|
|
8526
|
+
(_b = (_a = getAdHocFilterInteractionHandler(model)) == null ? void 0 : _a.onRecentGroupByApplied) == null ? void 0 : _b.call(_a, { key: String(groupBy.value) });
|
|
8516
8527
|
}
|
|
8517
8528
|
}));
|
|
8518
8529
|
const recommendedDrilldowns = recommendedGrouping == null ? void 0 : recommendedGrouping.map((groupBy) => ({
|
|
8519
8530
|
label: `${groupBy.value}`,
|
|
8520
8531
|
onClick: () => {
|
|
8532
|
+
var _a, _b;
|
|
8521
8533
|
model.addGroupByToParent(String(groupBy.value));
|
|
8522
|
-
|
|
8523
|
-
key: String(groupBy.value)
|
|
8524
|
-
});
|
|
8534
|
+
(_b = (_a = getAdHocFilterInteractionHandler(model)) == null ? void 0 : _a.onRecommendedGroupByApplied) == null ? void 0 : _b.call(_a, { key: String(groupBy.value) });
|
|
8525
8535
|
}
|
|
8526
8536
|
}));
|
|
8527
8537
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
@@ -9281,7 +9291,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
9281
9291
|
* No-op when enableGroupBy is false.
|
|
9282
9292
|
*/
|
|
9283
9293
|
_addGroupByFilter(item) {
|
|
9284
|
-
var _a, _b, _c;
|
|
9294
|
+
var _a, _b, _c, _d, _e;
|
|
9285
9295
|
if (!this.state.enableGroupBy) {
|
|
9286
9296
|
return;
|
|
9287
9297
|
}
|
|
@@ -9296,10 +9306,10 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
9296
9306
|
};
|
|
9297
9307
|
(_c = this._recommendations) == null ? void 0 : _c.storeRecentGrouping(key);
|
|
9298
9308
|
this.updateFilters([...this.state.filters, newFilter]);
|
|
9299
|
-
|
|
9309
|
+
(_e = (_d = getAdHocFilterInteractionHandler(this)) == null ? void 0 : _d.onGroupByAdded) == null ? void 0 : _e.call(_d, { key });
|
|
9300
9310
|
}
|
|
9301
9311
|
restoreOriginalFilter(filter) {
|
|
9302
|
-
var _a;
|
|
9312
|
+
var _a, _b, _c;
|
|
9303
9313
|
if (!filter.restorable) {
|
|
9304
9314
|
return;
|
|
9305
9315
|
}
|
|
@@ -9316,10 +9326,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
9316
9326
|
operator: originalFilter.operator,
|
|
9317
9327
|
nonApplicable: originalFilter.nonApplicable
|
|
9318
9328
|
});
|
|
9319
|
-
|
|
9320
|
-
key: filter.key,
|
|
9321
|
-
origin: filter.origin
|
|
9322
|
-
});
|
|
9329
|
+
(_c = (_b = getAdHocFilterInteractionHandler(this)) == null ? void 0 : _b.onFilterRestored) == null ? void 0 : _c.call(_b, { key: filter.key, origin: filter.origin });
|
|
9323
9330
|
}
|
|
9324
9331
|
/**
|
|
9325
9332
|
* Get the original value for an origin filter before any user modifications.
|
|
@@ -9392,7 +9399,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
9392
9399
|
* Restore all original group by filters.
|
|
9393
9400
|
*/
|
|
9394
9401
|
restoreOriginalGroupBy() {
|
|
9395
|
-
var _a;
|
|
9402
|
+
var _a, _b, _c;
|
|
9396
9403
|
const restoredOrigins = ((_a = this.state.originFilters) != null ? _a : []).map((f) => {
|
|
9397
9404
|
if (!isGroupByFilter(f) || !f.origin) {
|
|
9398
9405
|
return f;
|
|
@@ -9404,13 +9411,13 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
9404
9411
|
originFilters: restoredOrigins,
|
|
9405
9412
|
filters: nonGroupByFilters
|
|
9406
9413
|
});
|
|
9407
|
-
|
|
9414
|
+
(_c = (_b = getAdHocFilterInteractionHandler(this)) == null ? void 0 : _b.onGroupByRestored) == null ? void 0 : _c.call(_b);
|
|
9408
9415
|
}
|
|
9409
9416
|
/**
|
|
9410
9417
|
* Clear all user-added filters and restore origin filters to their original values.
|
|
9411
9418
|
*/
|
|
9412
9419
|
clearAll() {
|
|
9413
|
-
var _a, _b, _c;
|
|
9420
|
+
var _a, _b, _c, _d, _e;
|
|
9414
9421
|
const filtersCount = this.state.filters.length;
|
|
9415
9422
|
const restorableCount = (_b = (_a = this.state.originFilters) == null ? void 0 : _a.filter((f) => f.restorable && !isGroupByFilter(f)).length) != null ? _b : 0;
|
|
9416
9423
|
(_c = this.state.originFilters) == null ? void 0 : _c.forEach((filter) => {
|
|
@@ -9420,7 +9427,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
9420
9427
|
});
|
|
9421
9428
|
this.restoreOriginalGroupBy();
|
|
9422
9429
|
this.setState({ filters: [] });
|
|
9423
|
-
|
|
9430
|
+
(_e = (_d = getAdHocFilterInteractionHandler(this)) == null ? void 0 : _d.onClearAll) == null ? void 0 : _e.call(_d, {
|
|
9424
9431
|
filtersCleared: filtersCount,
|
|
9425
9432
|
originsRestored: restorableCount
|
|
9426
9433
|
});
|
|
@@ -9440,7 +9447,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
9440
9447
|
return this.state.filterExpression;
|
|
9441
9448
|
}
|
|
9442
9449
|
_updateFilter(filter, update) {
|
|
9443
|
-
var _a, _b, _c, _d, _e, _f;
|
|
9450
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
9444
9451
|
const { originFilters, filters, _wip } = this.state;
|
|
9445
9452
|
if ("value" in update && !("values" in update)) {
|
|
9446
9453
|
update = { ...update, values: void 0 };
|
|
@@ -9502,10 +9509,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
9502
9509
|
_wip: void 0
|
|
9503
9510
|
});
|
|
9504
9511
|
this.verifyApplicabilityAndStoreRecentFilter(newFilter);
|
|
9505
|
-
|
|
9506
|
-
key: newFilter.key,
|
|
9507
|
-
operator: newFilter.operator
|
|
9508
|
-
});
|
|
9512
|
+
(_f = (_e = getAdHocFilterInteractionHandler(this)) == null ? void 0 : _e.onFilterAdded) == null ? void 0 : _f.call(_e, { key: newFilter.key, operator: newFilter.operator });
|
|
9509
9513
|
} else {
|
|
9510
9514
|
this.setState({ _wip: { ...filter, ...update } });
|
|
9511
9515
|
}
|
|
@@ -9517,13 +9521,13 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
9517
9521
|
this.setState({ filters: updatedFilters });
|
|
9518
9522
|
const merged = { ...filter, ...update };
|
|
9519
9523
|
if (isGroupByFilter(merged)) {
|
|
9520
|
-
(
|
|
9524
|
+
(_g = this._recommendations) == null ? void 0 : _g.storeRecentGrouping(merged.key);
|
|
9521
9525
|
} else {
|
|
9522
|
-
(
|
|
9526
|
+
(_h = this._recommendations) == null ? void 0 : _h.storeRecentFilter(merged);
|
|
9523
9527
|
}
|
|
9524
9528
|
}
|
|
9525
9529
|
updateToMatchAll(filter) {
|
|
9526
|
-
var _a;
|
|
9530
|
+
var _a, _b, _c, _d, _e;
|
|
9527
9531
|
if (isGroupByFilter(filter) && filter.origin) {
|
|
9528
9532
|
const updatedOrigins = ((_a = this.state.originFilters) != null ? _a : []).map((f) => {
|
|
9529
9533
|
if (f === filter) {
|
|
@@ -9535,10 +9539,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
9535
9539
|
return f;
|
|
9536
9540
|
});
|
|
9537
9541
|
this.setState({ originFilters: updatedOrigins });
|
|
9538
|
-
|
|
9539
|
-
key: filter.key,
|
|
9540
|
-
origin: filter.origin
|
|
9541
|
-
});
|
|
9542
|
+
(_c = (_b = getAdHocFilterInteractionHandler(this)) == null ? void 0 : _b.onGroupByRemoved) == null ? void 0 : _c.call(_b, { key: filter.key, origin: filter.origin });
|
|
9542
9543
|
} else {
|
|
9543
9544
|
this._updateFilter(filter, {
|
|
9544
9545
|
operator: "=~",
|
|
@@ -9549,13 +9550,11 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
9549
9550
|
nonApplicable: false,
|
|
9550
9551
|
restorable: true
|
|
9551
9552
|
});
|
|
9552
|
-
|
|
9553
|
-
key: filter.key,
|
|
9554
|
-
origin: filter.origin
|
|
9555
|
-
});
|
|
9553
|
+
(_e = (_d = getAdHocFilterInteractionHandler(this)) == null ? void 0 : _d.onFilterMatchAll) == null ? void 0 : _e.call(_d, { key: filter.key, origin: filter.origin });
|
|
9556
9554
|
}
|
|
9557
9555
|
}
|
|
9558
9556
|
_removeFilter(filter) {
|
|
9557
|
+
var _a, _b;
|
|
9559
9558
|
if (filter === this.state._wip) {
|
|
9560
9559
|
this.setState({ _wip: void 0 });
|
|
9561
9560
|
return;
|
|
@@ -9565,10 +9564,12 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
9565
9564
|
const isGroupBy = isGroupByFilter(filter);
|
|
9566
9565
|
this.setState({ filters: this.state.filters.filter((f) => f !== filter) });
|
|
9567
9566
|
this._debouncedVerifyApplicability();
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
{ key: filter.key }
|
|
9571
|
-
|
|
9567
|
+
const handler = getAdHocFilterInteractionHandler(this);
|
|
9568
|
+
if (isGroupBy) {
|
|
9569
|
+
(_a = handler == null ? void 0 : handler.onGroupByRemoved) == null ? void 0 : _a.call(handler, { key: filter.key });
|
|
9570
|
+
} else {
|
|
9571
|
+
(_b = handler == null ? void 0 : handler.onFilterRemoved) == null ? void 0 : _b.call(handler, { key: filter.key });
|
|
9572
|
+
}
|
|
9572
9573
|
}
|
|
9573
9574
|
_removeLastFilter() {
|
|
9574
9575
|
const filterToRemove = this.state.filters.at(-1);
|