@grafana/scenes 5.16.3--canary.927.11147932712.0 → 5.16.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -3843,14 +3843,7 @@ const switchInputType = (filterInputType, setInputType, handleChangeViewMode, el
3843
3843
  handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3844
3844
  setTimeout(() => element == null ? void 0 : element.focus());
3845
3845
  };
3846
- const generateFilterUpdatePayload = ({
3847
- filterInputType,
3848
- item,
3849
- filter,
3850
- multiValueOperators,
3851
- setFilterMultiValues
3852
- }) => {
3853
- var _a, _b, _c, _d, _e;
3846
+ const generateFilterUpdatePayload = (filterInputType, item) => {
3854
3847
  if (filterInputType === "key") {
3855
3848
  return {
3856
3849
  key: item.value,
@@ -3863,33 +3856,6 @@ const generateFilterUpdatePayload = ({
3863
3856
  valueLabels: [item.label ? item.label : item.value]
3864
3857
  };
3865
3858
  }
3866
- if (filterInputType === "operator") {
3867
- if (multiValueOperators.includes(filter.operator) && !multiValueOperators.includes(item.value)) {
3868
- setFilterMultiValues([]);
3869
- return {
3870
- operator: item.value,
3871
- valueLabels: [((_a = filter.valueLabels) == null ? void 0 : _a[0]) || ((_b = filter.values) == null ? void 0 : _b[0]) || filter.value],
3872
- values: void 0
3873
- };
3874
- }
3875
- if (multiValueOperators.includes(item.value) && !multiValueOperators.includes(filter.operator)) {
3876
- const valueLabels = [((_c = filter.valueLabels) == null ? void 0 : _c[0]) || ((_d = filter.values) == null ? void 0 : _d[0]) || filter.value];
3877
- const values = [filter.value];
3878
- if (values[0]) {
3879
- setFilterMultiValues([
3880
- {
3881
- value: values[0],
3882
- label: (_e = valueLabels == null ? void 0 : valueLabels[0]) != null ? _e : values[0]
3883
- }
3884
- ]);
3885
- }
3886
- return {
3887
- operator: item.value,
3888
- valueLabels,
3889
- values
3890
- };
3891
- }
3892
- }
3893
3859
  return {
3894
3860
  [filterInputType]: item.value
3895
3861
  };
@@ -4208,16 +4174,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4208
4174
  if (multiValueEdit) {
4209
4175
  handleLocalMultiValueChange(selectedItem);
4210
4176
  } else {
4211
- model._updateFilter(
4212
- filter,
4213
- generateFilterUpdatePayload({
4214
- filterInputType,
4215
- item: selectedItem,
4216
- filter,
4217
- multiValueOperators,
4218
- setFilterMultiValues
4219
- })
4220
- );
4177
+ model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, selectedItem));
4221
4178
  switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
4222
4179
  setActiveIndex(0);
4223
4180
  }
@@ -4230,7 +4187,6 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4230
4187
  filterInputType,
4231
4188
  filteredDropDownItems,
4232
4189
  handleLocalMultiValueChange,
4233
- multiValueOperators,
4234
4190
  handleChangeViewMode,
4235
4191
  model,
4236
4192
  refs.domReference
@@ -4394,16 +4350,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4394
4350
  handleLocalMultiValueChange(item);
4395
4351
  (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
4396
4352
  } else {
4397
- model._updateFilter(
4398
- filter,
4399
- generateFilterUpdatePayload({
4400
- filterInputType,
4401
- item,
4402
- filter,
4403
- multiValueOperators,
4404
- setFilterMultiValues
4405
- })
4406
- );
4353
+ model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, item));
4407
4354
  setInputValue("");
4408
4355
  switchToNextInputType(
4409
4356
  filterInputType,
@@ -10889,18 +10836,18 @@ class SceneRefreshPicker extends SceneObjectBase {
10889
10836
  });
10890
10837
  }
10891
10838
  getUrlState() {
10892
- return {
10893
- refresh: this.state.refresh
10894
- };
10839
+ let refresh = this.state.refresh;
10840
+ if (typeof refresh !== "string" || refresh.length === 0) {
10841
+ refresh = void 0;
10842
+ }
10843
+ return { refresh };
10895
10844
  }
10896
10845
  updateFromUrl(values) {
10897
10846
  const { intervals } = this.state;
10898
- const refresh = values.refresh;
10899
- if (refresh && typeof refresh === "string") {
10847
+ let refresh = values.refresh;
10848
+ if (typeof refresh === "string" && isIntervalString(refresh)) {
10900
10849
  if (intervals == null ? void 0 : intervals.includes(refresh)) {
10901
- this.setState({
10902
- refresh
10903
- });
10850
+ this.setState({ refresh });
10904
10851
  } else {
10905
10852
  this.setState({
10906
10853
  refresh: intervals ? intervals[0] : void 0
@@ -10950,6 +10897,14 @@ function useQueryControllerState(model) {
10950
10897
  }
10951
10898
  return queryController.useState().isRunning;
10952
10899
  }
10900
+ function isIntervalString(str) {
10901
+ try {
10902
+ const res = data.rangeUtil.describeInterval(str);
10903
+ return res.count > 0;
10904
+ } catch (e) {
10905
+ return false;
10906
+ }
10907
+ }
10953
10908
 
10954
10909
  const getCompareSeriesRefId = (refId) => `${refId}-compare`;
10955
10910