@grafana/scenes 6.47.1--canary.1303.19372012709.0 → 6.47.1--canary.1303.19493819306.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/index.js CHANGED
@@ -3457,7 +3457,6 @@ class GroupByVariable extends MultiValueVariable {
3457
3457
  });
3458
3458
  this.isLazy = true;
3459
3459
  this._urlSync = new GroupByVariableUrlSyncHandler(this);
3460
- this._applicabilityEnabled = false;
3461
3460
  this._activationHandler = () => {
3462
3461
  this._verifyApplicability();
3463
3462
  if (this.state.defaultValue) {
@@ -3469,6 +3468,7 @@ class GroupByVariable extends MultiValueVariable {
3469
3468
  if (this.state.defaultValue) {
3470
3469
  this.restoreDefaultValues();
3471
3470
  }
3471
+ this.setState({ applicabilityEnabled: false });
3472
3472
  };
3473
3473
  };
3474
3474
  /**
@@ -3589,9 +3589,6 @@ class GroupByVariable extends MultiValueVariable {
3589
3589
  });
3590
3590
  return applicableValues;
3591
3591
  }
3592
- isApplicabilityEnabled() {
3593
- return this._applicabilityEnabled;
3594
- }
3595
3592
  async getGroupByApplicabilityForQueries(value, queries) {
3596
3593
  const ds = await getDataSource(this.state.datasource, {
3597
3594
  __sceneObject: wrapInSafeSerializableSceneObject(this)
@@ -3613,13 +3610,13 @@ class GroupByVariable extends MultiValueVariable {
3613
3610
  const value = this.state.value;
3614
3611
  const response = await this.getGroupByApplicabilityForQueries(value, queries);
3615
3612
  if (!response) {
3616
- this._applicabilityEnabled = false;
3617
3613
  return;
3618
3614
  }
3619
- this._applicabilityEnabled = true;
3620
3615
  if (!lodash.isEqual(response, this.state.keysApplicability)) {
3621
- this.setState({ keysApplicability: response != null ? response : void 0 });
3616
+ this.setState({ keysApplicability: response != null ? response : void 0, applicabilityEnabled: true });
3622
3617
  this.publishEvent(new SceneVariableValueChangedEvent(this), true);
3618
+ } else {
3619
+ this.setState({ applicabilityEnabled: true });
3623
3620
  }
3624
3621
  }
3625
3622
  // This method is related to the defaultValue property. We check if the current value
@@ -7905,7 +7902,6 @@ class AdHocFiltersVariable extends SceneObjectBase {
7905
7902
  // to its original value if edited at some point
7906
7903
  this._originalValues = /* @__PURE__ */ new Map();
7907
7904
  this._prevScopes = [];
7908
- this._applicabilityEnabled = false;
7909
7905
  /** Needed for scopes dependency */
7910
7906
  this._variableDependency = new VariableDependencyConfig(this, {
7911
7907
  dependsOnScopes: true,
@@ -7922,6 +7918,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
7922
7918
  this.restoreOriginalFilter(filter);
7923
7919
  }
7924
7920
  });
7921
+ this.setState({ applicabilityEnabled: false });
7925
7922
  };
7926
7923
  };
7927
7924
  if (this.state.applyMode === "auto") {
@@ -8161,9 +8158,6 @@ class AdHocFiltersVariable extends SceneObjectBase {
8161
8158
  });
8162
8159
  }
8163
8160
  }
8164
- isApplicabilityEnabled() {
8165
- return this._applicabilityEnabled;
8166
- }
8167
8161
  async getFiltersApplicabilityForQueries(filters, queries) {
8168
8162
  const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);
8169
8163
  if (!ds || !ds.getDrilldownsApplicability) {
@@ -8184,15 +8178,14 @@ class AdHocFiltersVariable extends SceneObjectBase {
8184
8178
  const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : void 0;
8185
8179
  const response = await this.getFiltersApplicabilityForQueries(filters, queries != null ? queries : []);
8186
8180
  if (!response) {
8187
- this._applicabilityEnabled = false;
8188
8181
  return;
8189
8182
  }
8190
- this._applicabilityEnabled = true;
8191
8183
  const responseMap = /* @__PURE__ */ new Map();
8192
8184
  response.forEach((filter) => {
8193
8185
  responseMap.set(`${filter.key}${filter.origin ? `-${filter.origin}` : ""}`, filter);
8194
8186
  });
8195
8187
  const update = {
8188
+ applicabilityEnabled: true,
8196
8189
  filters: [...this.state.filters],
8197
8190
  originFilters: [...(_b = this.state.originFilters) != null ? _b : []]
8198
8191
  };
@@ -9078,6 +9071,50 @@ function getNonApplicablePillStyles(theme) {
9078
9071
  })
9079
9072
  };
9080
9073
  }
9074
+ function verifyDrilldownApplicability(sourceObject, queriesDataSource, drilldownDatasource, isApplicabilityEnabled) {
9075
+ const datasourceUid = sceneGraph.interpolate(sourceObject, queriesDataSource == null ? void 0 : queriesDataSource.uid);
9076
+ return Boolean(
9077
+ isApplicabilityEnabled && datasourceUid === sceneGraph.interpolate(sourceObject, drilldownDatasource == null ? void 0 : drilldownDatasource.uid)
9078
+ );
9079
+ }
9080
+ async function getDrilldownApplicability(queryRunner, filtersVar, groupByVar) {
9081
+ var _a, _b, _c, _d, _e, _f;
9082
+ if (!filtersVar && !groupByVar) {
9083
+ return;
9084
+ }
9085
+ const datasource = queryRunner.state.datasource;
9086
+ const queries = (_b = (_a = queryRunner.state.data) == null ? void 0 : _a.request) == null ? void 0 : _b.targets;
9087
+ const ds = await getDataSource(datasource, {
9088
+ __sceneObject: wrapInSafeSerializableSceneObject(queryRunner)
9089
+ });
9090
+ if (!ds.getDrilldownsApplicability) {
9091
+ return;
9092
+ }
9093
+ const dsUid = sceneGraph.interpolate(queryRunner, datasource == null ? void 0 : datasource.uid);
9094
+ const timeRange = sceneGraph.getTimeRange(queryRunner).state.value;
9095
+ const groupByKeys = [];
9096
+ const filters = [];
9097
+ const hasGroupByApplicability = groupByVar && dsUid === sceneGraph.interpolate(groupByVar, (_c = groupByVar == null ? void 0 : groupByVar.state.datasource) == null ? void 0 : _c.uid);
9098
+ const hasFiltersApplicability = filtersVar && dsUid === sceneGraph.interpolate(filtersVar, (_e = (_d = filtersVar.state) == null ? void 0 : _d.datasource) == null ? void 0 : _e.uid);
9099
+ if (!hasGroupByApplicability && !hasFiltersApplicability) {
9100
+ return;
9101
+ }
9102
+ if (hasGroupByApplicability) {
9103
+ groupByKeys.push(
9104
+ ...Array.isArray(groupByVar.state.value) ? groupByVar.state.value.map((v) => String(v)) : groupByVar.state.value ? [String(groupByVar.state.value)] : []
9105
+ );
9106
+ }
9107
+ if (hasFiltersApplicability) {
9108
+ filters.push(...filtersVar.state.filters, ...(_f = filtersVar.state.originFilters) != null ? _f : []);
9109
+ }
9110
+ return await ds.getDrilldownsApplicability({
9111
+ groupByKeys,
9112
+ filters,
9113
+ queries,
9114
+ timeRange,
9115
+ scopes: sceneGraph.getScopes(queryRunner)
9116
+ });
9117
+ }
9081
9118
 
9082
9119
  class ConstantVariable extends SceneObjectBase {
9083
9120
  constructor(initialState) {
@@ -16141,7 +16178,10 @@ const sceneUtils = {
16141
16178
  isGroupByVariable,
16142
16179
  isSwitchVariable,
16143
16180
  isRepeatCloneOrChildOf,
16144
- buildPathIdFor
16181
+ buildPathIdFor,
16182
+ //drilldowns
16183
+ verifyDrilldownApplicability,
16184
+ getDrilldownApplicability
16145
16185
  };
16146
16186
 
16147
16187
  exports.AdHocFiltersComboboxRenderer = AdHocFiltersComboboxRenderer;