@grafana/scenes 6.10.4 → 6.11.0--canary.1121.15019988505.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.
Files changed (36) hide show
  1. package/dist/esm/behaviors/SceneRenderProfiler.js.map +1 -1
  2. package/dist/esm/components/SceneApp/SceneApp.js +2 -2
  3. package/dist/esm/components/SceneApp/SceneApp.js.map +1 -1
  4. package/dist/esm/components/SceneApp/SceneAppPage.js +2 -18
  5. package/dist/esm/components/SceneApp/SceneAppPage.js.map +1 -1
  6. package/dist/esm/components/SceneTimePicker.js +3 -2
  7. package/dist/esm/components/SceneTimePicker.js.map +1 -1
  8. package/dist/esm/core/sceneGraph/index.js +2 -2
  9. package/dist/esm/core/sceneGraph/index.js.map +1 -1
  10. package/dist/esm/core/sceneGraph/sceneGraph.js +9 -5
  11. package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
  12. package/dist/esm/index.js +1 -1
  13. package/dist/esm/index.js.map +1 -1
  14. package/dist/esm/querying/SceneQueryRunner.js +10 -33
  15. package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
  16. package/dist/esm/variables/VariableDependencyConfig.js +4 -1
  17. package/dist/esm/variables/VariableDependencyConfig.js.map +1 -1
  18. package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +19 -18
  19. package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
  20. package/dist/esm/variables/components/VariableValueSelectors.js +3 -0
  21. package/dist/esm/variables/components/VariableValueSelectors.js.map +1 -1
  22. package/dist/esm/variables/constants.js +2 -1
  23. package/dist/esm/variables/constants.js.map +1 -1
  24. package/dist/esm/variables/groupby/GroupByVariable.js +2 -2
  25. package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
  26. package/dist/esm/variables/sets/SceneVariableSet.js +10 -7
  27. package/dist/esm/variables/sets/SceneVariableSet.js.map +1 -1
  28. package/dist/esm/variables/types.js.map +1 -1
  29. package/dist/esm/variables/variants/ScopesVariable.js +80 -0
  30. package/dist/esm/variables/variants/ScopesVariable.js.map +1 -0
  31. package/dist/index.d.ts +55 -51
  32. package/dist/index.js +113 -151
  33. package/dist/index.js.map +1 -1
  34. package/package.json +2 -2
  35. package/dist/esm/core/SceneScopesBridge.js +0 -93
  36. package/dist/esm/core/SceneScopesBridge.js.map +0 -1
package/dist/index.js CHANGED
@@ -1282,6 +1282,7 @@ const AUTO_VARIABLE_TEXT = "Auto";
1282
1282
  const AUTO_VARIABLE_VALUE = "$__auto";
1283
1283
  const VARIABLE_REGEX = /\$(\w+)|\[\[(\w+?)(?::(\w+))?\]\]|\${(\w+)(?:\.([^:^\}]+))?(?::([^\}]+))?}/g;
1284
1284
  const SEARCH_FILTER_VARIABLE = "__searchFilter";
1285
+ const SCOPES_VARIABLE_NAME = "__scopes";
1285
1286
 
1286
1287
  const formatRegistry = new data.Registry(() => {
1287
1288
  const formats = [
@@ -3097,7 +3098,7 @@ class GroupByVariable extends MultiValueVariable {
3097
3098
  * Get possible keys given current filters. Do not call from plugins directly
3098
3099
  */
3099
3100
  this._getKeys = async (ds) => {
3100
- var _a, _b, _c, _d;
3101
+ var _a, _b, _c;
3101
3102
  const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, null));
3102
3103
  if (override && override.replace) {
3103
3104
  return override.values;
@@ -3115,7 +3116,7 @@ class GroupByVariable extends MultiValueVariable {
3115
3116
  filters: otherFilters,
3116
3117
  queries,
3117
3118
  timeRange,
3118
- scopes: (_d = this._scopesBridge) == null ? void 0 : _d.getValue(),
3119
+ scopes: sceneGraph.getScopes(this),
3119
3120
  ...getEnrichedFiltersRequest(this)
3120
3121
  });
3121
3122
  if (responseHasError(response)) {
@@ -5349,25 +5350,21 @@ class AdHocFiltersVariable extends SceneObjectBase {
5349
5350
  // are set on construct and used to restore a baseFilter with an origin
5350
5351
  // to its original value if edited at some point
5351
5352
  this._originalValues = /* @__PURE__ */ new Map();
5353
+ /** Needed for scopes dependency */
5354
+ this._variableDependency = new VariableDependencyConfig(this, {
5355
+ dependsOnScopes: true,
5356
+ onReferencedVariableValueChanged: () => this._updateScopesFilters()
5357
+ });
5352
5358
  this._urlSync = new AdHocFiltersVariableUrlSyncHandler(this);
5353
5359
  this._activationHandler = () => {
5354
- var _a, _b;
5355
- this._scopesBridge = sceneGraph.getScopesBridge(this);
5356
- const scopes = (_a = this._scopesBridge) == null ? void 0 : _a.getValue();
5357
- if (scopes) {
5358
- this._updateScopesFilters(scopes);
5359
- }
5360
- const sub = (_b = this._scopesBridge) == null ? void 0 : _b.subscribeToValue((n, _) => {
5361
- this._updateScopesFilters(n);
5362
- });
5360
+ this._updateScopesFilters();
5363
5361
  return () => {
5364
- var _a2, _b2;
5365
- sub == null ? void 0 : sub.unsubscribe();
5366
- if ((_a2 = this.state.baseFilters) == null ? void 0 : _a2.length) {
5362
+ var _a, _b;
5363
+ if ((_a = this.state.baseFilters) == null ? void 0 : _a.length) {
5367
5364
  this.setState({
5368
5365
  baseFilters: [...this.state.baseFilters.filter((filter) => filter.origin !== "scope")]
5369
5366
  });
5370
- (_b2 = this.state.baseFilters) == null ? void 0 : _b2.forEach((filter) => {
5367
+ (_b = this.state.baseFilters) == null ? void 0 : _b.forEach((filter) => {
5371
5368
  if (filter.origin === "dashboard" && filter.restorable) {
5372
5369
  this.restoreOriginalFilter(filter);
5373
5370
  }
@@ -5389,8 +5386,12 @@ class AdHocFiltersVariable extends SceneObjectBase {
5389
5386
  });
5390
5387
  this.addActivationHandler(this._activationHandler);
5391
5388
  }
5392
- _updateScopesFilters(scopes) {
5389
+ _updateScopesFilters() {
5393
5390
  var _a, _b;
5391
+ const scopes = sceneGraph.getScopes(this);
5392
+ if (!scopes) {
5393
+ return;
5394
+ }
5394
5395
  if (!scopes.length) {
5395
5396
  this.setState({
5396
5397
  baseFilters: (_a = this.state.baseFilters) == null ? void 0 : _a.filter((filter) => filter.origin !== "scope")
@@ -5591,7 +5592,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5591
5592
  * Get possible keys given current filters. Do not call from plugins directly
5592
5593
  */
5593
5594
  async _getKeys(currentKey) {
5594
- var _a, _b, _c, _d;
5595
+ var _a, _b, _c;
5595
5596
  const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));
5596
5597
  if (override && override.replace) {
5597
5598
  return dataFromResponse(override.values).map(toSelectableValue);
@@ -5610,7 +5611,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5610
5611
  filters: otherFilters,
5611
5612
  queries,
5612
5613
  timeRange,
5613
- scopes: (_d = this._scopesBridge) == null ? void 0 : _d.getValue(),
5614
+ scopes: sceneGraph.getScopes(this),
5614
5615
  ...getEnrichedFiltersRequest(this)
5615
5616
  });
5616
5617
  if (responseHasError(response)) {
@@ -5630,7 +5631,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5630
5631
  * Get possible key values for a specific key given current filters. Do not call from plugins directly
5631
5632
  */
5632
5633
  async _getValuesFor(filter) {
5633
- var _a, _b, _c, _d, _e;
5634
+ var _a, _b, _c, _d;
5634
5635
  const override = await ((_b = (_a = this.state).getTagValuesProvider) == null ? void 0 : _b.call(_a, this, filter));
5635
5636
  if (override && override.replace) {
5636
5637
  return dataFromResponse(override.values).map(toSelectableValue);
@@ -5643,7 +5644,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5643
5644
  const otherFilters = this.state.filters.filter((f) => f.key !== filter.key).concat(filteredBaseFilters);
5644
5645
  const timeRange = sceneGraph.getTimeRange(this).state.value;
5645
5646
  const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : void 0;
5646
- let scopes = (_e = this._scopesBridge) == null ? void 0 : _e.getValue();
5647
+ let scopes = sceneGraph.getScopes(this);
5647
5648
  if (filter.origin === "scope") {
5648
5649
  scopes = scopes == null ? void 0 : scopes.map((scope) => {
5649
5650
  return {
@@ -5801,7 +5802,8 @@ class SceneQueryRunner extends SceneObjectBase {
5801
5802
  this._variableDependency = new VariableDependencyConfig(this, {
5802
5803
  statePaths: ["queries", "datasource", "minInterval"],
5803
5804
  onVariableUpdateCompleted: this.onVariableUpdatesCompleted.bind(this),
5804
- onAnyVariableChanged: this.onAnyVariableChanged.bind(this)
5805
+ onAnyVariableChanged: this.onAnyVariableChanged.bind(this),
5806
+ dependsOnScopes: true
5805
5807
  });
5806
5808
  this.onDataReceived = (data$1) => {
5807
5809
  const preProcessedData = data.preProcessPanelData(data$1, this.state.data);
@@ -5822,7 +5824,6 @@ class SceneQueryRunner extends SceneObjectBase {
5822
5824
  _onActivate() {
5823
5825
  if (this.isQueryModeAuto()) {
5824
5826
  const timeRange = sceneGraph.getTimeRange(this);
5825
- const scopesBridge = sceneGraph.getScopesBridge(this);
5826
5827
  const providers = this.getClosestExtraQueryProviders();
5827
5828
  for (const provider of providers) {
5828
5829
  this._subs.add(
@@ -5833,7 +5834,6 @@ class SceneQueryRunner extends SceneObjectBase {
5833
5834
  })
5834
5835
  );
5835
5836
  }
5836
- this.subscribeToScopesChanges(scopesBridge);
5837
5837
  this.subscribeToTimeRangeChanges(timeRange);
5838
5838
  if (this.shouldRunQueriesOnActivate()) {
5839
5839
  this.runQueries();
@@ -5997,21 +5997,6 @@ class SceneQueryRunner extends SceneObjectBase {
5997
5997
  isDataReadyToDisplay() {
5998
5998
  return Boolean(this.state._hasFetchedData);
5999
5999
  }
6000
- subscribeToScopesChanges(scopesBridge) {
6001
- if (!scopesBridge) {
6002
- return;
6003
- }
6004
- if (this._scopesSubBridge === scopesBridge) {
6005
- return;
6006
- }
6007
- if (this._scopesSub) {
6008
- this._scopesSub.unsubscribe();
6009
- }
6010
- this._scopesSubBridge = scopesBridge;
6011
- this._scopesSub = scopesBridge.subscribeToValue(() => {
6012
- this.runWithTimeRangeAndScopes(sceneGraph.getTimeRange(this), scopesBridge);
6013
- });
6014
- }
6015
6000
  subscribeToTimeRangeChanges(timeRange) {
6016
6001
  if (this._timeSubRange === timeRange) {
6017
6002
  return;
@@ -6021,17 +6006,15 @@ class SceneQueryRunner extends SceneObjectBase {
6021
6006
  }
6022
6007
  this._timeSubRange = timeRange;
6023
6008
  this._timeSub = timeRange.subscribeToState(() => {
6024
- this.runWithTimeRangeAndScopes(timeRange, sceneGraph.getScopesBridge(this));
6009
+ this.runWithTimeRange(timeRange);
6025
6010
  });
6026
6011
  }
6027
6012
  runQueries() {
6028
6013
  const timeRange = sceneGraph.getTimeRange(this);
6029
- const scopesBridge = sceneGraph.getScopesBridge(this);
6030
6014
  if (this.isQueryModeAuto()) {
6031
6015
  this.subscribeToTimeRangeChanges(timeRange);
6032
- this.subscribeToScopesChanges(scopesBridge);
6033
6016
  }
6034
- this.runWithTimeRangeAndScopes(timeRange, scopesBridge);
6017
+ this.runWithTimeRange(timeRange);
6035
6018
  }
6036
6019
  getMaxDataPoints() {
6037
6020
  var _a;
@@ -6051,8 +6034,8 @@ class SceneQueryRunner extends SceneObjectBase {
6051
6034
  data: { ...this.state.data, state: schema.LoadingState.Done }
6052
6035
  });
6053
6036
  }
6054
- async runWithTimeRangeAndScopes(timeRange, scopesBridge) {
6055
- var _a, _b, _c, _d;
6037
+ async runWithTimeRange(timeRange) {
6038
+ var _a, _b, _c;
6056
6039
  if (!this.state.maxDataPoints && this.state.maxDataPointsFromWidth && !this._containerWidth) {
6057
6040
  return;
6058
6041
  }
@@ -6065,22 +6048,17 @@ class SceneQueryRunner extends SceneObjectBase {
6065
6048
  this.setState({ data: { ...(_b = this.state.data) != null ? _b : emptyPanelData, state: schema.LoadingState.Loading } });
6066
6049
  return;
6067
6050
  }
6068
- if ((scopesBridge == null ? void 0 : scopesBridge.isLoading()) && (scopesBridge == null ? void 0 : scopesBridge.getValue().length)) {
6069
- writeSceneLog("SceneQueryRunner", "Scopes are in loading state, skipping query execution");
6070
- this.setState({ data: { ...(_c = this.state.data) != null ? _c : emptyPanelData, state: schema.LoadingState.Loading } });
6071
- return;
6072
- }
6073
6051
  const { queries } = this.state;
6074
6052
  if (!(queries == null ? void 0 : queries.length)) {
6075
6053
  this._setNoDataState();
6076
6054
  return;
6077
6055
  }
6078
6056
  try {
6079
- const datasource = (_d = this.state.datasource) != null ? _d : findFirstDatasource(queries);
6057
+ const datasource = (_c = this.state.datasource) != null ? _c : findFirstDatasource(queries);
6080
6058
  const ds = await getDataSource(datasource, this._scopedVars);
6081
6059
  this.findAndSubscribeToAdHocFilters(ds.uid);
6082
6060
  const runRequest = runtime.getRunRequest();
6083
- const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds, scopesBridge);
6061
+ const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds);
6084
6062
  writeSceneLog("SceneQueryRunner", "Starting runRequest", this.state.key);
6085
6063
  let stream = runRequest(ds, primary);
6086
6064
  if (secondaries.length > 0) {
@@ -6121,7 +6099,7 @@ class SceneQueryRunner extends SceneObjectBase {
6121
6099
  clone["_results"].next({ origin: this, data: (_a = this.state.data) != null ? _a : emptyPanelData });
6122
6100
  return clone;
6123
6101
  }
6124
- prepareRequests(timeRange, ds, scopesBridge) {
6102
+ prepareRequests(timeRange, ds) {
6125
6103
  var _a, _b;
6126
6104
  const { minInterval, queries } = this.state;
6127
6105
  let request = {
@@ -6142,7 +6120,7 @@ class SceneQueryRunner extends SceneObjectBase {
6142
6120
  },
6143
6121
  cacheTimeout: this.state.cacheTimeout,
6144
6122
  queryCachingTTL: this.state.queryCachingTTL,
6145
- scopes: scopesBridge == null ? void 0 : scopesBridge.getValue(),
6123
+ scopes: sceneGraph.getScopes(this),
6146
6124
  // This asks the scene root to provide context properties like app, panel and dashboardUID
6147
6125
  ...getEnrichedDataRequest(this)
6148
6126
  };
@@ -6565,6 +6543,9 @@ class VariableDependencyConfig {
6565
6543
  this._dependencies.add(name);
6566
6544
  }
6567
6545
  }
6546
+ if (this._options.dependsOnScopes) {
6547
+ this._dependencies.add(SCOPES_VARIABLE_NAME);
6548
+ }
6568
6549
  if (this._statePaths) {
6569
6550
  for (const path of this._statePaths) {
6570
6551
  if (path === "*") {
@@ -7093,87 +7074,73 @@ function containsSearchFilter(query) {
7093
7074
  return str.indexOf(SEARCH_FILTER_VARIABLE) > -1;
7094
7075
  }
7095
7076
 
7096
- class SceneScopesBridge extends SceneObjectBase {
7097
- constructor() {
7098
- super(...arguments);
7077
+ class ScopesVariable extends SceneObjectBase {
7078
+ constructor(state) {
7079
+ super({
7080
+ skipUrlSync: true,
7081
+ loading: true,
7082
+ scopes: [],
7083
+ ...state,
7084
+ type: "system",
7085
+ name: SCOPES_VARIABLE_NAME,
7086
+ hide: schema.VariableHide.hideVariable
7087
+ });
7099
7088
  this._renderBeforeActivation = true;
7100
- this._contextSubject = new rxjs.BehaviorSubject(void 0);
7101
- }
7102
- getValue() {
7103
- var _a, _b;
7104
- return (_b = (_a = this.context) == null ? void 0 : _a.state.value) != null ? _b : [];
7105
7089
  }
7106
7090
  /**
7107
- * Emits values of the selected scopes array. It emits the current value and the previous value if there is a change.
7108
- * @param cb
7091
+ * Temporary simple implementation to stringify the scopes.
7109
7092
  */
7110
- subscribeToValue(cb) {
7111
- return this.contextObservable.pipe(
7112
- rxjs.map((context) => {
7113
- var _a;
7114
- return (_a = context == null ? void 0 : context.state.value) != null ? _a : [];
7115
- }),
7116
- rxjs.pairwise(),
7117
- rxjs.filter(([prevScopes, newScopes]) => !lodash.isEqual(prevScopes, newScopes))
7118
- ).subscribe(([prevScopes, newScopes]) => {
7119
- cb(newScopes, prevScopes);
7120
- });
7121
- }
7122
- isLoading() {
7123
- var _a, _b;
7124
- return (_b = (_a = this.context) == null ? void 0 : _a.state.loading) != null ? _b : false;
7125
- }
7126
- subscribeToLoading(cb) {
7127
- return this.contextObservable.pipe(
7128
- rxjs.filter((context) => !!context),
7129
- rxjs.pairwise(),
7130
- rxjs.map(
7131
- ([prevContext, newContext]) => {
7132
- var _a, _b;
7133
- return [(_a = prevContext == null ? void 0 : prevContext.state.loading) != null ? _a : false, (_b = newContext == null ? void 0 : newContext.state.loading) != null ? _b : false];
7134
- }
7135
- ),
7136
- rxjs.filter(([prevLoading, newLoading]) => prevLoading !== newLoading)
7137
- ).subscribe(([_prevLoading, newLoading]) => {
7138
- cb(newLoading);
7139
- });
7140
- }
7141
- setEnabled(enabled) {
7093
+ getValue(fieldPath) {
7142
7094
  var _a;
7143
- (_a = this.context) == null ? void 0 : _a.setEnabled(enabled);
7095
+ const scopes = (_a = this.state.scopes) != null ? _a : [];
7096
+ const scopeNames = scopes.map((scope) => scope.metadata.name);
7097
+ return scopeNames.join(", ");
7144
7098
  }
7145
- setReadOnly(readOnly) {
7146
- var _a;
7147
- (_a = this.context) == null ? void 0 : _a.setReadOnly(readOnly);
7099
+ getScopes() {
7100
+ return this.state.scopes;
7148
7101
  }
7149
7102
  /**
7150
7103
  * This method is used to keep the context up to date with the scopes context received from React
7151
- *
7152
- * Its rationale is:
7153
- * - When a new context is available, check if we have pending scopes passed from the URL
7154
- * - If we have pending scopes, ask the new context to load them
7155
- * - The loading should happen in a setTimeout to allow the existing context to pass its values to the URL sync handler
7156
- * - If a new context is received, propagate it as a new value in the behavior subject
7157
- * - If a new value is received, force a re-render to trigger the URL sync handler
7104
+ * 1) Subscribes to ScopesContext state changes and synchronizes it with the variable state
7105
+ * 2) Handles enable / disabling of scopes based on variable enable option.
7158
7106
  */
7159
- updateContext(newContext) {
7160
- var _a;
7161
- if (this.context !== newContext || ((_a = this.context) == null ? void 0 : _a.state) !== (newContext == null ? void 0 : newContext.state)) {
7162
- this._contextSubject.next(newContext);
7107
+ setContext(context) {
7108
+ if (!context) {
7109
+ return;
7163
7110
  }
7111
+ this._context = context;
7112
+ const oldState = context.state;
7113
+ if (this.state.enable != null) {
7114
+ context.setEnabled(this.state.enable);
7115
+ }
7116
+ const sub = context.stateObservable.subscribe((state) => {
7117
+ this.updateStateFromContext(state);
7118
+ });
7119
+ return () => {
7120
+ sub.unsubscribe();
7121
+ if (this.state.enable != null) {
7122
+ context.setEnabled(oldState.enabled);
7123
+ }
7124
+ };
7164
7125
  }
7165
- get context() {
7166
- return this._contextSubject.getValue();
7126
+ updateStateFromContext(state) {
7127
+ const loading = state.value.length === 0 ? false : state.loading;
7128
+ this.setState({ scopes: state.value, loading });
7129
+ if (!loading) {
7130
+ this.publishEvent(new SceneVariableValueChangedEvent(this), true);
7131
+ }
7167
7132
  }
7168
- get contextObservable() {
7169
- return this._contextSubject.asObservable();
7133
+ /**
7134
+ * Special function that enables variables to be hidden but still render to access react contexts
7135
+ */
7136
+ hiddenRender() {
7137
+ return /* @__PURE__ */ React__default.default.createElement(ScopesVariableRenderer, { model: this });
7170
7138
  }
7171
7139
  }
7172
- SceneScopesBridge.Component = SceneScopesBridgeRenderer;
7173
- function SceneScopesBridgeRenderer({ model }) {
7174
- const context = runtime.useScopes();
7140
+ function ScopesVariableRenderer({ model }) {
7141
+ const context = React.useContext(runtime.ScopesContext);
7175
7142
  React.useEffect(() => {
7176
- model.updateContext(context);
7143
+ return model.setContext(context);
7177
7144
  }, [context, model]);
7178
7145
  return null;
7179
7146
  }
@@ -7321,9 +7288,12 @@ function findDescendents(scene, descendentType) {
7321
7288
  const targetScenes = findAllObjects(scene, isDescendentType);
7322
7289
  return targetScenes.filter(isDescendentType);
7323
7290
  }
7324
- function getScopesBridge(sceneObject) {
7325
- var _a;
7326
- return (_a = findObject(sceneObject, (s) => s instanceof SceneScopesBridge)) != null ? _a : void 0;
7291
+ function getScopes(sceneObject) {
7292
+ const scopesVariable = lookupVariable(SCOPES_VARIABLE_NAME, sceneObject);
7293
+ if (scopesVariable instanceof ScopesVariable) {
7294
+ return scopesVariable.state.scopes;
7295
+ }
7296
+ return void 0;
7327
7297
  }
7328
7298
 
7329
7299
  const sceneGraph = {
@@ -7342,7 +7312,7 @@ const sceneGraph = {
7342
7312
  getAncestor,
7343
7313
  getQueryController,
7344
7314
  findDescendents,
7345
- getScopesBridge
7315
+ getScopes
7346
7316
  };
7347
7317
 
7348
7318
  class UniqueUrlKeyMapper {
@@ -9433,6 +9403,9 @@ function VariableValueSelectorsRenderer({ model }) {
9433
9403
  function VariableValueSelectWrapper({ variable, layout, showAlways, hideLabel }) {
9434
9404
  const state = useSceneObjectState(variable, { shouldActivateOrKeepAlive: true });
9435
9405
  if (state.hide === data.VariableHide.hideVariable && !showAlways) {
9406
+ if (variable.hiddenRender) {
9407
+ return variable.hiddenRender();
9408
+ }
9436
9409
  return null;
9437
9410
  }
9438
9411
  if (layout === "vertical") {
@@ -9496,8 +9469,6 @@ function VariableValueControlRenderer({ model }) {
9496
9469
  class SceneVariableSet extends SceneObjectBase {
9497
9470
  constructor(state) {
9498
9471
  super(state);
9499
- /** Variables that have changed in since the activation or since the first manual value change */
9500
- this._variablesThatHaveChanged = /* @__PURE__ */ new Set();
9501
9472
  /** Variables that are scheduled to be validated and updated */
9502
9473
  this._variablesToUpdate = /* @__PURE__ */ new Set();
9503
9474
  /** Variables currently updating */
@@ -9624,7 +9595,8 @@ class SceneVariableSet extends SceneObjectBase {
9624
9595
  _updateNextBatch() {
9625
9596
  for (const variable of this._variablesToUpdate) {
9626
9597
  if (!variable.validateAndUpdate) {
9627
- throw new Error("Variable added to variablesToUpdate but does not have validateAndUpdate");
9598
+ console.error("Variable added to variablesToUpdate but does not have validateAndUpdate");
9599
+ continue;
9628
9600
  }
9629
9601
  if (this._updating.has(variable)) {
9630
9602
  continue;
@@ -9680,7 +9652,6 @@ class SceneVariableSet extends SceneObjectBase {
9680
9652
  this._updateNextBatch();
9681
9653
  }
9682
9654
  _handleVariableValueChanged(variableThatChanged) {
9683
- this._variablesThatHaveChanged.add(variableThatChanged);
9684
9655
  this._addDependentVariablesToUpdateQueue(variableThatChanged);
9685
9656
  if (!this._updating.has(variableThatChanged)) {
9686
9657
  this._updateNextBatch();
@@ -9707,7 +9678,10 @@ class SceneVariableSet extends SceneObjectBase {
9707
9678
  if (this._updating.has(otherVariable) && otherVariable.onCancel) {
9708
9679
  otherVariable.onCancel();
9709
9680
  }
9710
- this._variablesToUpdate.add(otherVariable);
9681
+ if (otherVariable.validateAndUpdate) {
9682
+ this._variablesToUpdate.add(otherVariable);
9683
+ }
9684
+ otherVariable.variableDependency.variableUpdateCompleted(variableThatChanged, true);
9711
9685
  }
9712
9686
  }
9713
9687
  }
@@ -9719,8 +9693,7 @@ class SceneVariableSet extends SceneObjectBase {
9719
9693
  if (!this.parent) {
9720
9694
  return;
9721
9695
  }
9722
- this._traverseSceneAndNotify(this.parent, variable, this._variablesThatHaveChanged.has(variable));
9723
- this._variablesThatHaveChanged.delete(variable);
9696
+ this._traverseSceneAndNotify(this.parent, variable, true);
9724
9697
  }
9725
9698
  /**
9726
9699
  * Recursivly walk the full scene object graph and notify all objects with dependencies that include any of changed variables
@@ -9752,6 +9725,9 @@ class SceneVariableSet extends SceneObjectBase {
9752
9725
  * For example if C depends on variable B which depends on variable A and A is loading this returns true for variable C and B.
9753
9726
  */
9754
9727
  isVariableLoadingOrWaitingToUpdate(variable) {
9728
+ if (variable.state.loading) {
9729
+ return true;
9730
+ }
9755
9731
  if (variable.isAncestorLoading && variable.isAncestorLoading()) {
9756
9732
  return true;
9757
9733
  }
@@ -11435,7 +11411,7 @@ class SceneTimePicker extends SceneObjectBase {
11435
11411
  }
11436
11412
  SceneTimePicker.Component = SceneTimePickerRenderer;
11437
11413
  function SceneTimePickerRenderer({ model }) {
11438
- const { hidePicker, isOnCanvas, quickRanges } = model.useState();
11414
+ const { hidePicker, isOnCanvas, quickRanges, defaultQuickRanges } = model.useState();
11439
11415
  const timeRange = sceneGraph.getTimeRange(model);
11440
11416
  const timeZone = timeRange.getTimeZone();
11441
11417
  const timeRangeState = timeRange.useState();
@@ -11447,6 +11423,7 @@ function SceneTimePickerRenderer({ model }) {
11447
11423
  if (hidePicker) {
11448
11424
  return null;
11449
11425
  }
11426
+ const rangesToUse = quickRanges || defaultQuickRanges;
11450
11427
  return /* @__PURE__ */ React__default.default.createElement(
11451
11428
  ui.TimeRangePicker,
11452
11429
  {
@@ -11467,7 +11444,7 @@ function SceneTimePickerRenderer({ model }) {
11467
11444
  onChangeFiscalYearStartMonth: model.onChangeFiscalYearStartMonth,
11468
11445
  weekStart: timeRangeState.weekStart,
11469
11446
  history: timeRangeHistory,
11470
- quickRanges
11447
+ quickRanges: rangesToUse
11471
11448
  }
11472
11449
  );
11473
11450
  }
@@ -12639,8 +12616,8 @@ class SceneApp extends SceneObjectBase {
12639
12616
  }
12640
12617
  }
12641
12618
  SceneApp.Component = ({ model }) => {
12642
- const { pages, scopesBridge } = model.useState();
12643
- return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, scopesBridge && /* @__PURE__ */ React__default.default.createElement(scopesBridge.Component, { model: scopesBridge }), /* @__PURE__ */ React__default.default.createElement(SceneAppContext.Provider, { value: model }, /* @__PURE__ */ React__default.default.createElement(reactRouterDom.Routes, null, pages.map((page) => /* @__PURE__ */ React__default.default.createElement(reactRouterDom.Route, { key: page.state.url, path: page.state.routePath, element: /* @__PURE__ */ React__default.default.createElement(page.Component, { model: page }) })))));
12619
+ const { pages } = model.useState();
12620
+ return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(SceneAppContext.Provider, { value: model }, /* @__PURE__ */ React__default.default.createElement(reactRouterDom.Routes, null, pages.map((page) => /* @__PURE__ */ React__default.default.createElement(reactRouterDom.Route, { key: page.state.url, path: page.state.routePath, element: /* @__PURE__ */ React__default.default.createElement(page.Component, { model: page }) })))));
12644
12621
  };
12645
12622
  const SceneAppContext = React.createContext(null);
12646
12623
  const sceneAppCache = /* @__PURE__ */ new Map();
@@ -12916,25 +12893,10 @@ function SceneAppDrilldownViewRender({ drilldown, parent }) {
12916
12893
  }
12917
12894
 
12918
12895
  class SceneAppPage extends SceneObjectBase {
12919
- constructor(state) {
12920
- super(state);
12896
+ constructor() {
12897
+ super(...arguments);
12921
12898
  this._sceneCache = /* @__PURE__ */ new Map();
12922
12899
  this._drilldownCache = /* @__PURE__ */ new Map();
12923
- this._activationHandler = () => {
12924
- if (!this.state.useScopes) {
12925
- return;
12926
- }
12927
- this._scopesBridge = sceneGraph.getScopesBridge(this);
12928
- if (!this._scopesBridge) {
12929
- throw new Error("Use of scopes is enabled but no scopes bridge found");
12930
- }
12931
- this._scopesBridge.setEnabled(true);
12932
- return () => {
12933
- var _a;
12934
- (_a = this._scopesBridge) == null ? void 0 : _a.setEnabled(false);
12935
- };
12936
- };
12937
- this.addActivationHandler(this._activationHandler);
12938
12900
  }
12939
12901
  initializeScene(scene) {
12940
12902
  this.setState({ initializedScene: scene });
@@ -14042,7 +14004,6 @@ exports.SceneObjectUrlSyncConfig = SceneObjectUrlSyncConfig;
14042
14004
  exports.SceneQueryRunner = SceneQueryRunner;
14043
14005
  exports.SceneReactObject = SceneReactObject;
14044
14006
  exports.SceneRefreshPicker = SceneRefreshPicker;
14045
- exports.SceneScopesBridge = SceneScopesBridge;
14046
14007
  exports.SceneTimePicker = SceneTimePicker;
14047
14008
  exports.SceneTimeRange = SceneTimeRange;
14048
14009
  exports.SceneTimeRangeCompare = SceneTimeRangeCompare;
@@ -14052,6 +14013,7 @@ exports.SceneToolbarButton = SceneToolbarButton;
14052
14013
  exports.SceneToolbarInput = SceneToolbarInput;
14053
14014
  exports.SceneVariableSet = SceneVariableSet;
14054
14015
  exports.SceneVariableValueChangedEvent = SceneVariableValueChangedEvent;
14016
+ exports.ScopesVariable = ScopesVariable;
14055
14017
  exports.SplitLayout = SplitLayout;
14056
14018
  exports.TestVariable = TestVariable;
14057
14019
  exports.TextBoxVariable = TextBoxVariable;