@grafana/scenes 6.24.1--canary.1166.15878540264.0 → 6.26.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
@@ -5157,7 +5157,7 @@ const getStyles$c = (theme) => ({
5157
5157
  color: theme.colors.text.primary,
5158
5158
  boxShadow: theme.shadows.z2,
5159
5159
  overflowY: "auto",
5160
- zIndex: theme.zIndex.portal
5160
+ zIndex: theme.zIndex.dropdown
5161
5161
  }),
5162
5162
  inputStyle: css.css({
5163
5163
  paddingBlock: 0,
@@ -5250,14 +5250,14 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
5250
5250
  };
5251
5251
  if (viewMode) {
5252
5252
  const pillTextContent = `${keyLabel} ${filter.operator} ${valueLabel}`;
5253
- const pillText = /* @__PURE__ */ React__default.default.createElement("span", { className: styles.pillText }, pillTextContent);
5253
+ const pillText = /* @__PURE__ */ React__default.default.createElement("span", { className: css.cx(styles.pillText, filter.nonApplicable && styles.strikethrough) }, pillTextContent);
5254
5254
  return /* @__PURE__ */ React__default.default.createElement(
5255
5255
  "div",
5256
5256
  {
5257
5257
  className: css.cx(
5258
5258
  styles.combinedFilterPill,
5259
5259
  readOnly && styles.readOnlyCombinedFilter,
5260
- isMatchAllFilter(filter) && styles.matchAllPill,
5260
+ (isMatchAllFilter(filter) || filter.nonApplicable) && styles.disabledPill,
5261
5261
  filter.readOnly && styles.filterReadOnly
5262
5262
  ),
5263
5263
  onClick: (e) => {
@@ -5309,7 +5309,7 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
5309
5309
  },
5310
5310
  name: "times",
5311
5311
  size: "md",
5312
- className: styles.pillIcon,
5312
+ className: css.cx(styles.pillIcon, filter.nonApplicable && styles.disabledPillIcon),
5313
5313
  tooltip: i18n.t(
5314
5314
  "grafana-scenes.components.adhoc-filter-pill.remove-filter-with-key",
5315
5315
  "Remove filter with key {{keyLabel}}",
@@ -5424,13 +5424,24 @@ const getStyles$b = (theme) => ({
5424
5424
  cursor: "pointer",
5425
5425
  color: theme.colors.text.disabled
5426
5426
  }),
5427
- matchAllPill: css.css({
5427
+ disabledPillIcon: css.css({
5428
+ marginInline: theme.spacing(0.5),
5429
+ cursor: "pointer",
5430
+ color: theme.colors.text.disabled,
5431
+ "&:hover": {
5432
+ color: theme.colors.text.disabled
5433
+ }
5434
+ }),
5435
+ disabledPill: css.css({
5428
5436
  background: theme.colors.action.selected,
5429
5437
  color: theme.colors.text.disabled,
5430
5438
  border: 0,
5431
5439
  "&:hover": {
5432
5440
  background: theme.colors.action.selected
5433
5441
  }
5442
+ }),
5443
+ strikethrough: css.css({
5444
+ textDecoration: "line-through"
5434
5445
  })
5435
5446
  });
5436
5447
 
@@ -5648,6 +5659,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5648
5659
  });
5649
5660
  this._urlSync = new AdHocFiltersVariableUrlSyncHandler(this);
5650
5661
  this._activationHandler = () => {
5662
+ this._verifyNonApplicableFilters();
5651
5663
  return () => {
5652
5664
  var _a;
5653
5665
  (_a = this.state.originFilters) == null ? void 0 : _a.forEach((filter) => {
@@ -5766,6 +5778,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5766
5778
  original.values = originalFilter == null ? void 0 : originalFilter.value;
5767
5779
  original.valueLabels = originalFilter == null ? void 0 : originalFilter.value;
5768
5780
  original.operator = originalFilter == null ? void 0 : originalFilter.operator;
5781
+ original.nonApplicable = originalFilter == null ? void 0 : originalFilter.nonApplicable;
5769
5782
  this._updateFilter(filter, original);
5770
5783
  }
5771
5784
  }
@@ -5809,6 +5822,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5809
5822
  values: [".*"],
5810
5823
  valueLabels: ["All"],
5811
5824
  matchAllFilter: true,
5825
+ nonApplicable: false,
5812
5826
  restorable: true
5813
5827
  });
5814
5828
  }
@@ -5873,11 +5887,52 @@ class AdHocFiltersVariable extends SceneObjectBase {
5873
5887
  });
5874
5888
  }
5875
5889
  }
5890
+ async _verifyNonApplicableFilters() {
5891
+ var _a, _b, _c;
5892
+ const filters = [...this.state.filters, ...(_a = this.state.originFilters) != null ? _a : []];
5893
+ const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);
5894
+ if (!ds || !ds.getApplicableFilters) {
5895
+ return [];
5896
+ }
5897
+ const timeRange = sceneGraph.getTimeRange(this).state.value;
5898
+ const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : void 0;
5899
+ const response = await ds.getApplicableFilters({
5900
+ filters,
5901
+ queries,
5902
+ timeRange,
5903
+ scopes: sceneGraph.getScopes(this),
5904
+ ...getEnrichedFiltersRequest(this)
5905
+ });
5906
+ const update = {
5907
+ filters: [...this.state.filters],
5908
+ originFilters: [...(_b = this.state.originFilters) != null ? _b : []]
5909
+ };
5910
+ update.filters.forEach((f) => {
5911
+ const isApplicable = response.includes(f.key);
5912
+ if (!isApplicable) {
5913
+ f.nonApplicable = true;
5914
+ }
5915
+ });
5916
+ (_c = update.originFilters) == null ? void 0 : _c.forEach((f) => {
5917
+ const isApplicable = response.includes(f.key);
5918
+ if (!isApplicable) {
5919
+ if (!f.matchAllFilter) {
5920
+ f.nonApplicable = true;
5921
+ }
5922
+ const originalValue = this._originalValues.get(f.key);
5923
+ if (originalValue) {
5924
+ originalValue.nonApplicable = true;
5925
+ }
5926
+ }
5927
+ });
5928
+ this.setState(update);
5929
+ return;
5930
+ }
5876
5931
  /**
5877
5932
  * Get possible keys given current filters. Do not call from plugins directly
5878
5933
  */
5879
5934
  async _getKeys(currentKey) {
5880
- var _a, _b, _c;
5935
+ var _a, _b, _c, _d, _e;
5881
5936
  const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));
5882
5937
  if (override && override.replace) {
5883
5938
  return dataFromResponse(override.values).map(toSelectableValue);
@@ -5889,7 +5944,8 @@ class AdHocFiltersVariable extends SceneObjectBase {
5889
5944
  if (!ds || !ds.getTagKeys) {
5890
5945
  return [];
5891
5946
  }
5892
- const otherFilters = this.state.filters.filter((f) => f.key !== currentKey).concat((_c = this.state.baseFilters) != null ? _c : []);
5947
+ const applicableOriginFilters = (_d = (_c = this.state.originFilters) == null ? void 0 : _c.filter((f) => !f.nonApplicable)) != null ? _d : [];
5948
+ const otherFilters = this.state.filters.filter((f) => f.key !== currentKey && !f.nonApplicable).concat((_e = this.state.baseFilters) != null ? _e : []).concat(applicableOriginFilters);
5893
5949
  const timeRange = sceneGraph.getTimeRange(this).state.value;
5894
5950
  const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : void 0;
5895
5951
  const response = await ds.getTagKeys({
@@ -5982,7 +6038,8 @@ class AdHocFiltersVariable extends SceneObjectBase {
5982
6038
  }
5983
6039
  AdHocFiltersVariable.Component = AdHocFiltersVariableRenderer;
5984
6040
  function renderExpression(builder, filters) {
5985
- return (builder != null ? builder : renderPrometheusLabelFilters)(filters != null ? filters : []);
6041
+ var _a;
6042
+ return (builder != null ? builder : renderPrometheusLabelFilters)((_a = filters == null ? void 0 : filters.filter((f) => isFilterApplicable(f))) != null ? _a : []);
5986
6043
  }
5987
6044
  function AdHocFiltersVariableRenderer({ model }) {
5988
6045
  const { filters, readOnly, addFilterButtonText } = model.useState();
@@ -6023,6 +6080,9 @@ function isMatchAllFilter(filter) {
6023
6080
  function isFilterComplete(filter) {
6024
6081
  return filter.key !== "" && filter.operator !== "" && filter.value !== "";
6025
6082
  }
6083
+ function isFilterApplicable(filter) {
6084
+ return !filter.nonApplicable;
6085
+ }
6026
6086
  function isMultiValueOperator(operatorValue) {
6027
6087
  const operator = OPERATORS.find((o) => o.value === operatorValue);
6028
6088
  if (!operator) {
@@ -6413,7 +6473,7 @@ class SceneQueryRunner extends SceneObjectBase {
6413
6473
  request.filters = [
6414
6474
  ...(_a = this._adhocFiltersVar.state.originFilters) != null ? _a : [],
6415
6475
  ...this._adhocFiltersVar.state.filters
6416
- ].filter(isFilterComplete);
6476
+ ].filter((f) => isFilterComplete(f) && isFilterApplicable(f));
6417
6477
  }
6418
6478
  if (this._groupByVar) {
6419
6479
  request.groupByKeys = this._groupByVar.state.value;
@@ -12033,7 +12093,7 @@ const PREVIOUS_PERIOD_COMPARE_OPTION = {
12033
12093
  value: PREVIOUS_PERIOD_VALUE
12034
12094
  };
12035
12095
  const NO_COMPARE_OPTION = {
12036
- label: "No comparison",
12096
+ label: "None",
12037
12097
  value: NO_PERIOD_VALUE
12038
12098
  };
12039
12099
  const DEFAULT_COMPARE_OPTIONS = [
@@ -12188,7 +12248,7 @@ const timeShiftAlignmentProcessor = (primary, secondary) => {
12188
12248
  function SceneTimeRangeCompareRenderer({ model }) {
12189
12249
  var _a;
12190
12250
  const styles = ui.useStyles2(getStyles$4);
12191
- const { compareWith, compareOptions } = model.useState();
12251
+ const { compareWith, compareOptions, hideCheckbox } = model.useState();
12192
12252
  const [previousCompare, setPreviousCompare] = React__default.default.useState(compareWith);
12193
12253
  const previousValue = (_a = compareOptions.find(({ value: value2 }) => value2 === previousCompare)) != null ? _a : PREVIOUS_PERIOD_COMPARE_OPTION;
12194
12254
  const value = compareOptions.find(({ value: value2 }) => value2 === compareWith);
@@ -12201,7 +12261,13 @@ function SceneTimeRangeCompareRenderer({ model }) {
12201
12261
  model.onCompareWithChanged(previousValue.value);
12202
12262
  }
12203
12263
  };
12204
- return /* @__PURE__ */ React__default.default.createElement(ui.ButtonGroup, null, /* @__PURE__ */ React__default.default.createElement(
12264
+ const selectValue = hideCheckbox && !compareWith ? NO_COMPARE_OPTION : value;
12265
+ const showSelect = hideCheckbox || enabled;
12266
+ const displayValue = hideCheckbox && selectValue ? {
12267
+ ...selectValue,
12268
+ label: `Comparison: ${selectValue.label}`
12269
+ } : selectValue;
12270
+ return /* @__PURE__ */ React__default.default.createElement(ui.ButtonGroup, null, !hideCheckbox && /* @__PURE__ */ React__default.default.createElement(
12205
12271
  ui.ToolbarButton,
12206
12272
  {
12207
12273
  variant: "canvas",
@@ -12217,11 +12283,11 @@ function SceneTimeRangeCompareRenderer({ model }) {
12217
12283
  },
12218
12284
  /* @__PURE__ */ React__default.default.createElement(ui.Checkbox, { label: " ", value: enabled, onClick }),
12219
12285
  /* @__PURE__ */ React__default.default.createElement(i18n.Trans, { i18nKey: "grafana-scenes.components.scene-time-range-compare-renderer.button-label" }, "Comparison")
12220
- ), enabled ? /* @__PURE__ */ React__default.default.createElement(
12286
+ ), showSelect ? /* @__PURE__ */ React__default.default.createElement(
12221
12287
  ui.ButtonSelect,
12222
12288
  {
12223
12289
  variant: "canvas",
12224
- value,
12290
+ value: displayValue,
12225
12291
  options: compareOptions,
12226
12292
  onChange: (v) => {
12227
12293
  model.onCompareWithChanged(v.value);