@grafana/scenes 6.50.0--canary.1312.20243507649.0 → 6.50.0--canary.1312.20266554849.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
@@ -3795,61 +3795,59 @@ class ScopesVariableFormatter {
3795
3795
  }
3796
3796
 
3797
3797
  const getRecentFiltersKey = (datasourceUid) => `grafana.filters.recent.${datasourceUid != null ? datasourceUid : "default"}`;
3798
- class AdHocFiltersRecommendations extends SceneObjectBase {
3799
- constructor(parent) {
3800
- super({});
3801
- this._scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };
3802
- this._activationHandler = () => {
3803
- const json = data.store.get(this._getStorageKey());
3804
- const storedFilters = json ? JSON.parse(json) : [];
3805
- if (storedFilters.length > 0) {
3806
- this._verifyRecentFiltersApplicability(storedFilters);
3807
- } else {
3808
- this.setState({ recentFilters: [] });
3809
- }
3810
- this._fetchRecommendedDrilldowns();
3811
- const scopesVariable = sceneGraph.lookupVariable(SCOPES_VARIABLE_NAME, this);
3812
- let scopesSubscription;
3813
- if (scopesVariable instanceof ScopesVariable) {
3814
- scopesSubscription = scopesVariable.subscribeToState((newState, prevState) => {
3815
- if (newState.scopes !== prevState.scopes) {
3816
- const json2 = data.store.get(this._getStorageKey());
3817
- const storedFilters2 = json2 ? JSON.parse(json2) : [];
3818
- if (storedFilters2.length > 0) {
3819
- this._verifyRecentFiltersApplicability(storedFilters2);
3820
- }
3798
+ class AdHocFiltersRecommendations {
3799
+ constructor(adHocFilter, scopedVars) {
3800
+ this.adHocFilter = adHocFilter;
3801
+ this._scopedVars = scopedVars;
3802
+ }
3803
+ get recentFilters() {
3804
+ return this._recentFilters;
3805
+ }
3806
+ get recommendedFilters() {
3807
+ return this._recommendedFilters;
3808
+ }
3809
+ init() {
3810
+ const json = data.store.get(this._getStorageKey());
3811
+ const storedFilters = json ? JSON.parse(json) : [];
3812
+ if (storedFilters.length > 0) {
3813
+ this._verifyRecentFiltersApplicability(storedFilters);
3814
+ } else {
3815
+ this._recentFilters = [];
3816
+ }
3817
+ this._fetchRecommendedDrilldowns();
3818
+ const scopesVariable = sceneGraph.lookupVariable(SCOPES_VARIABLE_NAME, this.adHocFilter);
3819
+ if (scopesVariable instanceof ScopesVariable) {
3820
+ this.scopesSubscription = scopesVariable.subscribeToState((newState, prevState) => {
3821
+ if (newState.scopes !== prevState.scopes) {
3822
+ const json2 = data.store.get(this._getStorageKey());
3823
+ const storedFilters2 = json2 ? JSON.parse(json2) : [];
3824
+ if (storedFilters2.length > 0) {
3825
+ this._verifyRecentFiltersApplicability(storedFilters2);
3821
3826
  }
3822
- });
3823
- }
3824
- return () => {
3825
- scopesSubscription == null ? void 0 : scopesSubscription.unsubscribe();
3826
- };
3827
- };
3828
- this._parentVariable = parent;
3829
- this.addActivationHandler(this._activationHandler);
3827
+ }
3828
+ });
3829
+ }
3830
3830
  }
3831
- /**
3832
- * Get the parent variable
3833
- */
3834
- get parent() {
3835
- return this._parentVariable;
3831
+ deinit() {
3832
+ var _a;
3833
+ (_a = this.scopesSubscription) == null ? void 0 : _a.unsubscribe();
3836
3834
  }
3837
3835
  _getStorageKey() {
3838
3836
  var _a;
3839
- return getRecentFiltersKey((_a = this._parentVariable.state.datasource) == null ? void 0 : _a.uid);
3837
+ return getRecentFiltersKey((_a = this.adHocFilter.state.datasource) == null ? void 0 : _a.uid);
3840
3838
  }
3841
3839
  async _fetchRecommendedDrilldowns() {
3842
3840
  var _a;
3843
- const parent = this._parentVariable;
3844
- const ds = await getDataSource(parent.state.datasource, this._scopedVars);
3841
+ const adhoc = this.adHocFilter;
3842
+ const ds = await getDataSource(adhoc.state.datasource, this._scopedVars);
3845
3843
  if (!ds || !ds.getRecommendedDrilldowns) {
3846
3844
  return;
3847
3845
  }
3848
- const queries = parent.state.useQueriesAsFilterForOptions ? getQueriesForVariables(parent) : void 0;
3849
- const timeRange = sceneGraph.getTimeRange(this).state.value;
3850
- const scopes = sceneGraph.getScopes(this);
3851
- const filters = [...(_a = parent.state.originFilters) != null ? _a : [], ...parent.state.filters];
3852
- const enrichedRequest = getEnrichedDataRequest(this);
3846
+ const queries = adhoc.state.useQueriesAsFilterForOptions ? getQueriesForVariables(adhoc) : void 0;
3847
+ const timeRange = sceneGraph.getTimeRange(adhoc).state.value;
3848
+ const scopes = sceneGraph.getScopes(adhoc);
3849
+ const filters = [...(_a = adhoc.state.originFilters) != null ? _a : [], ...adhoc.state.filters];
3850
+ const enrichedRequest = getEnrichedDataRequest(adhoc);
3853
3851
  const dashboardUid = enrichedRequest == null ? void 0 : enrichedRequest.dashboardUID;
3854
3852
  try {
3855
3853
  const recommendedDrilldowns = await ds.getRecommendedDrilldowns({
@@ -3861,18 +3859,18 @@ class AdHocFiltersRecommendations extends SceneObjectBase {
3861
3859
  userId: runtime.config.bootData.user.id
3862
3860
  });
3863
3861
  if (recommendedDrilldowns == null ? void 0 : recommendedDrilldowns.filters) {
3864
- this.setState({ recommendedFilters: recommendedDrilldowns.filters });
3862
+ this._recommendedFilters = recommendedDrilldowns.filters;
3865
3863
  }
3866
3864
  } catch (error) {
3867
3865
  console.error("Failed to fetch recommended drilldowns:", error);
3868
3866
  }
3869
3867
  }
3870
3868
  async _verifyRecentFiltersApplicability(storedFilters) {
3871
- const parent = this._parentVariable;
3872
- const queries = parent.state.useQueriesAsFilterForOptions ? getQueriesForVariables(parent) : void 0;
3873
- const response = await this._getFiltersApplicabilityForQueries(storedFilters, queries != null ? queries : []);
3869
+ const adhoc = this.adHocFilter;
3870
+ const queries = adhoc.state.useQueriesAsFilterForOptions ? getQueriesForVariables(adhoc) : void 0;
3871
+ const response = await adhoc.getFiltersApplicabilityForQueries(storedFilters, queries != null ? queries : []);
3874
3872
  if (!response) {
3875
- this.setState({ recentFilters: storedFilters.slice(-3) });
3873
+ this._recentFilters = storedFilters.slice(-3);
3876
3874
  return;
3877
3875
  }
3878
3876
  const applicabilityMap = /* @__PURE__ */ new Map();
@@ -3883,22 +3881,7 @@ class AdHocFiltersRecommendations extends SceneObjectBase {
3883
3881
  const isApplicable = applicabilityMap.get(f.key);
3884
3882
  return isApplicable === void 0 || isApplicable === true;
3885
3883
  }).slice(-3);
3886
- this.setState({ recentFilters: applicableFilters });
3887
- }
3888
- async _getFiltersApplicabilityForQueries(filters, queries) {
3889
- const parent = this._parentVariable;
3890
- const ds = await getDataSource(parent.state.datasource, this._scopedVars);
3891
- if (!ds || !ds.getDrilldownsApplicability) {
3892
- return;
3893
- }
3894
- const timeRange = sceneGraph.getTimeRange(this).state.value;
3895
- return await ds.getDrilldownsApplicability({
3896
- filters,
3897
- queries,
3898
- timeRange,
3899
- scopes: sceneGraph.getScopes(this),
3900
- ...getEnrichedFiltersRequest(this)
3901
- });
3884
+ this._recentFilters = applicableFilters;
3902
3885
  }
3903
3886
  /**
3904
3887
  * Stores a recent filter in localStorage and updates state.
@@ -3910,103 +3893,89 @@ class AdHocFiltersRecommendations extends SceneObjectBase {
3910
3893
  const allRecentFilters = storedFilters ? JSON.parse(storedFilters) : [];
3911
3894
  const updatedStoredFilters = [...allRecentFilters, filter].slice(-10);
3912
3895
  data.store.set(key, JSON.stringify(updatedStoredFilters));
3913
- const parent = this._parentVariable;
3914
- const existingFilter = parent.state.filters.find((f) => f.key === filter.key && !Boolean(f.nonApplicable));
3896
+ const adhoc = this.adHocFilter;
3897
+ const existingFilter = adhoc.state.filters.find((f) => f.key === filter.key && !Boolean(f.nonApplicable));
3915
3898
  if (existingFilter && !Boolean(existingFilter.nonApplicable)) {
3916
- this.setState({ recentFilters: updatedStoredFilters.slice(-3) });
3899
+ this._recentFilters = updatedStoredFilters.slice(-3);
3917
3900
  }
3918
3901
  }
3919
- /**
3920
- * Get the current filters from the parent variable
3921
- */
3922
- getParentFilters() {
3923
- return this._parentVariable.state.filters;
3924
- }
3925
- /**
3926
- * Add a filter to the parent variable
3927
- */
3928
3902
  addFilterToParent(filter) {
3929
- const parent = this._parentVariable;
3930
- parent.updateFilters([...parent.state.filters, filter]);
3903
+ this.adHocFilter.updateFilters([...this.adHocFilter.state.filters, filter]);
3931
3904
  }
3932
- }
3933
- AdHocFiltersRecommendations.Component = AdHocFiltersRecommendationsRenderer;
3934
- function AdHocFiltersRecommendationsRenderer({ model }) {
3935
- const { recentFilters, recommendedFilters } = model.useState();
3936
- const { filters } = model.parent.useState();
3937
- const recentDrilldowns = recentFilters == null ? void 0 : recentFilters.map((filter) => ({
3938
- label: `${filter.key} ${filter.operator} ${filter.value}`,
3939
- onClick: () => {
3940
- model.addFilterToParent(filter);
3941
- }
3942
- }));
3943
- const recommendedDrilldowns = recommendedFilters == null ? void 0 : recommendedFilters.map((filter) => ({
3944
- label: `${filter.key} ${filter.operator} ${filter.value}`,
3945
- onClick: () => {
3946
- const exists = filters.some((f) => f.key === filter.key && f.value === filter.value);
3947
- if (!exists) {
3948
- model.addFilterToParent(filter);
3905
+ render() {
3906
+ var _a, _b;
3907
+ const { filters } = this.adHocFilter.useState();
3908
+ const recentDrilldowns = (_a = this.recentFilters) == null ? void 0 : _a.map((filter) => ({
3909
+ label: `${filter.key} ${filter.operator} ${filter.value}`,
3910
+ onClick: () => {
3911
+ this.addFilterToParent(filter);
3949
3912
  }
3950
- }
3951
- }));
3952
- return /* @__PURE__ */ React__default.default.createElement(DrilldownRecommendations, { recentDrilldowns, recommendedDrilldowns });
3913
+ }));
3914
+ const recommendedDrilldowns = (_b = this.recommendedFilters) == null ? void 0 : _b.map((filter) => ({
3915
+ label: `${filter.key} ${filter.operator} ${filter.value}`,
3916
+ onClick: () => {
3917
+ const exists = filters.some((f) => f.key === filter.key && f.value === filter.value);
3918
+ if (!exists) {
3919
+ this.addFilterToParent(filter);
3920
+ }
3921
+ }
3922
+ }));
3923
+ return /* @__PURE__ */ React__default.default.createElement(DrilldownRecommendations, { recentDrilldowns, recommendedDrilldowns });
3924
+ }
3953
3925
  }
3954
3926
 
3955
3927
  const getRecentGroupingKey = (datasourceUid) => `grafana.grouping.recent.${datasourceUid != null ? datasourceUid : "default"}`;
3956
- class GroupByRecommendations extends SceneObjectBase {
3957
- constructor(parent) {
3958
- super({});
3959
- this._scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };
3960
- this._activationHandler = () => {
3961
- const json = data.store.get(this._getStorageKey());
3962
- const storedGroupings = json ? JSON.parse(json) : [];
3963
- if (storedGroupings.length > 0) {
3964
- this._verifyRecentGroupingsApplicability(storedGroupings);
3965
- } else {
3966
- this.setState({ recentGrouping: [] });
3967
- }
3968
- this._fetchRecommendedDrilldowns();
3969
- const scopesVariable = sceneGraph.lookupVariable(SCOPES_VARIABLE_NAME, this);
3970
- let scopesSubscription;
3971
- if (scopesVariable instanceof ScopesVariable) {
3972
- scopesSubscription = scopesVariable.subscribeToState((newState, prevState) => {
3973
- if (newState.scopes !== prevState.scopes) {
3974
- const json2 = data.store.get(this._getStorageKey());
3975
- const storedGroupings2 = json2 ? JSON.parse(json2) : [];
3976
- if (storedGroupings2.length > 0) {
3977
- this._verifyRecentGroupingsApplicability(storedGroupings2);
3978
- }
3928
+ class GroupByRecommendations {
3929
+ constructor(groupByVariable, scopedVars) {
3930
+ this.groupBy = groupByVariable;
3931
+ this._scopedVars = scopedVars;
3932
+ }
3933
+ get recentGrouping() {
3934
+ return this._recentGrouping;
3935
+ }
3936
+ get recommendedGrouping() {
3937
+ return this._recommendedGrouping;
3938
+ }
3939
+ init() {
3940
+ const json = data.store.get(this._getStorageKey());
3941
+ const storedGroupings = json ? JSON.parse(json) : [];
3942
+ if (storedGroupings.length > 0) {
3943
+ this._verifyRecentGroupingsApplicability(storedGroupings);
3944
+ } else {
3945
+ this._recentGrouping = [];
3946
+ }
3947
+ this._fetchRecommendedDrilldowns();
3948
+ const scopesVariable = sceneGraph.lookupVariable(SCOPES_VARIABLE_NAME, this.groupBy);
3949
+ if (scopesVariable instanceof ScopesVariable) {
3950
+ this.scopesSubscription = scopesVariable.subscribeToState((newState, prevState) => {
3951
+ if (newState.scopes !== prevState.scopes) {
3952
+ const json2 = data.store.get(this._getStorageKey());
3953
+ const storedGroupings2 = json2 ? JSON.parse(json2) : [];
3954
+ if (storedGroupings2.length > 0) {
3955
+ this._verifyRecentGroupingsApplicability(storedGroupings2);
3979
3956
  }
3980
- });
3981
- }
3982
- return () => {
3983
- scopesSubscription == null ? void 0 : scopesSubscription.unsubscribe();
3984
- };
3985
- };
3986
- this._parentVariable = parent;
3987
- this.addActivationHandler(this._activationHandler);
3957
+ }
3958
+ });
3959
+ }
3988
3960
  }
3989
- /**
3990
- * Get the parent variable
3991
- */
3992
- get parent() {
3993
- return this._parentVariable;
3961
+ deinit() {
3962
+ var _a;
3963
+ (_a = this.scopesSubscription) == null ? void 0 : _a.unsubscribe();
3994
3964
  }
3995
3965
  _getStorageKey() {
3996
3966
  var _a;
3997
- return getRecentGroupingKey((_a = this._parentVariable.state.datasource) == null ? void 0 : _a.uid);
3967
+ return getRecentGroupingKey((_a = this.groupBy.state.datasource) == null ? void 0 : _a.uid);
3998
3968
  }
3999
3969
  async _fetchRecommendedDrilldowns() {
4000
- const parent = this._parentVariable;
4001
- const ds = await getDataSource(parent.state.datasource, this._scopedVars);
3970
+ const ds = await getDataSource(this.groupBy.state.datasource, this._scopedVars);
4002
3971
  if (!ds || !ds.getRecommendedDrilldowns) {
4003
3972
  return;
4004
3973
  }
4005
- const queries = getQueriesForVariables(parent);
4006
- const timeRange = sceneGraph.getTimeRange(this).state.value;
4007
- const scopes = sceneGraph.getScopes(this);
4008
- const groupByKeys = Array.isArray(parent.state.value) ? parent.state.value.map((v) => String(v)) : parent.state.value ? [String(parent.state.value)] : [];
4009
- const enrichedRequest = getEnrichedDataRequest(this);
3974
+ const queries = getQueriesForVariables(this.groupBy);
3975
+ const timeRange = sceneGraph.getTimeRange(this.groupBy).state.value;
3976
+ const scopes = sceneGraph.getScopes(this.groupBy);
3977
+ const groupByKeys = Array.isArray(this.groupBy.state.value) ? this.groupBy.state.value.map((v) => String(v)) : this.groupBy.state.value ? [String(this.groupBy.state.value)] : [];
3978
+ const enrichedRequest = getEnrichedDataRequest(this.groupBy);
4010
3979
  const dashboardUid = enrichedRequest == null ? void 0 : enrichedRequest.dashboardUID;
4011
3980
  try {
4012
3981
  const recommendedDrilldowns = await ds.getRecommendedDrilldowns({
@@ -4018,20 +3987,18 @@ class GroupByRecommendations extends SceneObjectBase {
4018
3987
  userId: runtime.config.bootData.user.id
4019
3988
  });
4020
3989
  if (recommendedDrilldowns == null ? void 0 : recommendedDrilldowns.groupByKeys) {
4021
- this.setState({
4022
- recommendedGrouping: recommendedDrilldowns.groupByKeys.map((key) => ({ value: key, text: key }))
4023
- });
3990
+ this._recommendedGrouping = recommendedDrilldowns.groupByKeys.map((key) => ({ value: key, text: key }));
4024
3991
  }
4025
3992
  } catch (error) {
4026
3993
  console.error("Failed to fetch recommended drilldowns:", error);
4027
3994
  }
4028
3995
  }
4029
3996
  async _verifyRecentGroupingsApplicability(storedGroupings) {
4030
- const queries = getQueriesForVariables(this._parentVariable);
3997
+ const queries = getQueriesForVariables(this.groupBy);
4031
3998
  const keys = storedGroupings.map((g) => String(g.value));
4032
- const response = await this._getGroupByApplicabilityForQueries(keys, queries);
3999
+ const response = await this.groupBy.getGroupByApplicabilityForQueries(keys, queries);
4033
4000
  if (!response) {
4034
- this.setState({ recentGrouping: storedGroupings.slice(-3) });
4001
+ this._recentGrouping = storedGroupings.slice(-3);
4035
4002
  return;
4036
4003
  }
4037
4004
  const applicabilityMap = /* @__PURE__ */ new Map();
@@ -4042,22 +4009,7 @@ class GroupByRecommendations extends SceneObjectBase {
4042
4009
  const isApplicable = applicabilityMap.get(String(g.value));
4043
4010
  return isApplicable === void 0 || isApplicable === true;
4044
4011
  }).slice(-3);
4045
- this.setState({ recentGrouping: applicableGroupings });
4046
- }
4047
- async _getGroupByApplicabilityForQueries(value, queries) {
4048
- const parent = this._parentVariable;
4049
- const ds = await getDataSource(parent.state.datasource, this._scopedVars);
4050
- if (!ds || !ds.getDrilldownsApplicability) {
4051
- return;
4052
- }
4053
- const timeRange = sceneGraph.getTimeRange(this).state.value;
4054
- return await ds.getDrilldownsApplicability({
4055
- groupByKeys: Array.isArray(value) ? value.map((v) => String(v)) : value ? [String(value)] : [],
4056
- queries,
4057
- timeRange,
4058
- scopes: sceneGraph.getScopes(this),
4059
- ...getEnrichedFiltersRequest(this)
4060
- });
4012
+ this._recentGrouping = applicableGroupings;
4061
4013
  }
4062
4014
  /**
4063
4015
  * Stores recent groupings in localStorage and updates state.
@@ -4079,51 +4031,41 @@ class GroupByRecommendations extends SceneObjectBase {
4079
4031
  ];
4080
4032
  const limitedStoredGroupings = updatedStoredGroupings.slice(-10);
4081
4033
  data.store.set(key, JSON.stringify(limitedStoredGroupings));
4082
- this.setState({ recentGrouping: limitedStoredGroupings.slice(-3) });
4083
- }
4084
- /**
4085
- * Get the current values from the parent variable
4086
- */
4087
- getParentValues() {
4088
- const parent = this._parentVariable;
4089
- const value = lodash.isArray(parent.state.value) ? parent.state.value : [parent.state.value];
4090
- const text = lodash.isArray(parent.state.text) ? parent.state.text.map(String) : [String(parent.state.text)];
4091
- return { value, text };
4034
+ this._recentGrouping = limitedStoredGroupings.slice(-3);
4092
4035
  }
4093
4036
  /**
4094
4037
  * Add a grouping value to the parent variable
4095
4038
  */
4096
4039
  addValueToParent(newValue, newText) {
4097
- const parent = this._parentVariable;
4098
- const { value, text } = this.getParentValues();
4040
+ const value = lodash.isArray(this.groupBy.state.value) ? this.groupBy.state.value : [this.groupBy.state.value];
4041
+ const text = lodash.isArray(this.groupBy.state.text) ? this.groupBy.state.text.map(String) : [String(this.groupBy.state.text)];
4099
4042
  if (value.includes(newValue)) {
4100
4043
  return;
4101
4044
  }
4102
- parent.changeValueTo(
4045
+ this.groupBy.changeValueTo(
4103
4046
  [...value.filter((v) => v !== ""), newValue],
4104
4047
  [...text.filter((t) => t !== ""), newText != null ? newText : String(newValue)],
4105
4048
  true
4106
4049
  );
4107
4050
  }
4108
- }
4109
- GroupByRecommendations.Component = GroupByRecommendationsRenderer;
4110
- function GroupByRecommendationsRenderer({ model }) {
4111
- const { recentGrouping, recommendedGrouping } = model.useState();
4112
- const recentDrilldowns = recentGrouping == null ? void 0 : recentGrouping.map((groupBy) => ({
4113
- label: `${groupBy.value}`,
4114
- onClick: () => {
4115
- var _a;
4116
- model.addValueToParent(groupBy.value, (_a = groupBy.text) != null ? _a : String(groupBy.value));
4117
- }
4118
- }));
4119
- const recommendedDrilldowns = recommendedGrouping == null ? void 0 : recommendedGrouping.map((groupBy) => ({
4120
- label: `${groupBy.value}`,
4121
- onClick: () => {
4122
- var _a;
4123
- model.addValueToParent(groupBy.value, (_a = groupBy.text) != null ? _a : String(groupBy.value));
4124
- }
4125
- }));
4126
- return /* @__PURE__ */ React__default.default.createElement(DrilldownRecommendations, { recentDrilldowns, recommendedDrilldowns });
4051
+ render() {
4052
+ var _a, _b;
4053
+ const recentDrilldowns = (_a = this.recentGrouping) == null ? void 0 : _a.map((groupBy) => ({
4054
+ label: `${groupBy.value}`,
4055
+ onClick: () => {
4056
+ var _a2;
4057
+ this.addValueToParent(groupBy.value, (_a2 = groupBy.text) != null ? _a2 : String(groupBy.value));
4058
+ }
4059
+ }));
4060
+ const recommendedDrilldowns = (_b = this.recommendedGrouping) == null ? void 0 : _b.map((groupBy) => ({
4061
+ label: `${groupBy.value}`,
4062
+ onClick: () => {
4063
+ var _a2;
4064
+ this.addValueToParent(groupBy.value, (_a2 = groupBy.text) != null ? _a2 : String(groupBy.value));
4065
+ }
4066
+ }));
4067
+ return /* @__PURE__ */ React__default.default.createElement(DrilldownRecommendations, { recentDrilldowns, recommendedDrilldowns });
4068
+ }
4127
4069
  }
4128
4070
 
4129
4071
  class GroupByVariable extends MultiValueVariable {
@@ -4144,6 +4086,7 @@ class GroupByVariable extends MultiValueVariable {
4144
4086
  });
4145
4087
  this.isLazy = true;
4146
4088
  this._urlSync = new GroupByVariableUrlSyncHandler(this);
4089
+ this._scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };
4147
4090
  this._activationHandler = () => {
4148
4091
  this._verifyApplicability();
4149
4092
  if (this.state.defaultValue) {
@@ -4152,15 +4095,17 @@ class GroupByVariable extends MultiValueVariable {
4152
4095
  }
4153
4096
  }
4154
4097
  if (this.state.drilldownRecommendationsEnabled && !this.state._valueRecommendations) {
4155
- const valueRecommendations = new GroupByRecommendations(this);
4098
+ const valueRecommendations = new GroupByRecommendations(this, this._scopedVars);
4156
4099
  this.setState({ _valueRecommendations: valueRecommendations });
4157
- valueRecommendations.activate();
4100
+ valueRecommendations.init();
4158
4101
  }
4159
4102
  return () => {
4103
+ var _a;
4160
4104
  if (this.state.defaultValue) {
4161
4105
  this.restoreDefaultValues();
4162
4106
  }
4163
4107
  this.setState({ applicabilityEnabled: false });
4108
+ (_a = this.state._valueRecommendations) == null ? void 0 : _a.deinit();
4164
4109
  };
4165
4110
  };
4166
4111
  /**
@@ -4241,11 +4186,7 @@ class GroupByVariable extends MultiValueVariable {
4241
4186
  );
4242
4187
  }
4243
4188
  this.setState({ loading: true, error: null });
4244
- return rxjs.from(
4245
- getDataSource(this.state.datasource, {
4246
- __sceneObject: wrapInSafeSerializableSceneObject(this)
4247
- })
4248
- ).pipe(
4189
+ return rxjs.from(getDataSource(this.state.datasource, this._scopedVars)).pipe(
4249
4190
  rxjs.mergeMap((ds) => {
4250
4191
  return rxjs.from(this._getKeys(ds)).pipe(
4251
4192
  rxjs.tap((response) => {
@@ -4282,9 +4223,7 @@ class GroupByVariable extends MultiValueVariable {
4282
4223
  return applicableValues;
4283
4224
  }
4284
4225
  async getGroupByApplicabilityForQueries(value, queries) {
4285
- const ds = await getDataSource(this.state.datasource, {
4286
- __sceneObject: wrapInSafeSerializableSceneObject(this)
4287
- });
4226
+ const ds = await getDataSource(this.state.datasource, this._scopedVars);
4288
4227
  if (!ds.getDrilldownsApplicability) {
4289
4228
  return;
4290
4229
  }
@@ -4536,7 +4475,7 @@ function GroupByVariableRenderer({ model }) {
4536
4475
  if (!drilldownRecommendationsEnabled || !_valueRecommendations) {
4537
4476
  return select;
4538
4477
  }
4539
- return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.wrapper }, /* @__PURE__ */ React__default.default.createElement("div", { className: styles.recommendations }, /* @__PURE__ */ React__default.default.createElement(_valueRecommendations.Component, { model: _valueRecommendations })), select);
4478
+ return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.wrapper }, /* @__PURE__ */ React__default.default.createElement("div", { className: styles.recommendations }, _valueRecommendations.render()), select);
4540
4479
  }
4541
4480
  const filterNoOp$1 = () => true;
4542
4481
  function WideMenu(props) {
@@ -8376,7 +8315,7 @@ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRen
8376
8315
  }
8377
8316
  },
8378
8317
  /* @__PURE__ */ React__default.default.createElement(ui.Icon, { name: "filter", className: styles.filterIcon, size: "lg" }),
8379
- drilldownRecommendationsEnabled && valueRecommendations && /* @__PURE__ */ React__default.default.createElement(valueRecommendations.Component, { model: valueRecommendations }),
8318
+ drilldownRecommendationsEnabled && valueRecommendations && valueRecommendations.render(),
8380
8319
  originFilters == null ? void 0 : originFilters.map(
8381
8320
  (filter, index) => filter.origin ? /* @__PURE__ */ React__default.default.createElement(
8382
8321
  AdHocFilterPill,
@@ -8661,18 +8600,19 @@ class AdHocFiltersVariable extends SceneObjectBase {
8661
8600
  this._activationHandler = () => {
8662
8601
  this._debouncedVerifyApplicability();
8663
8602
  if (this.state.drilldownRecommendationsEnabled && !this.state._valueRecommendations) {
8664
- const valueRecommendations = new AdHocFiltersRecommendations(this);
8603
+ const valueRecommendations = new AdHocFiltersRecommendations(this, this._scopedVars);
8665
8604
  this.setState({ _valueRecommendations: valueRecommendations });
8666
- valueRecommendations.activate();
8605
+ valueRecommendations.init();
8667
8606
  }
8668
8607
  return () => {
8669
- var _a;
8608
+ var _a, _b;
8670
8609
  (_a = this.state.originFilters) == null ? void 0 : _a.forEach((filter) => {
8671
8610
  if (filter.restorable) {
8672
8611
  this.restoreOriginalFilter(filter);
8673
8612
  }
8674
8613
  });
8675
8614
  this.setState({ applicabilityEnabled: false });
8615
+ (_b = this.state._valueRecommendations) == null ? void 0 : _b.deinit();
8676
8616
  };
8677
8617
  };
8678
8618
  if (this.state.applyMode === "auto") {