@grafana/scenes 5.0.2--canary.794.9497058323.0 → 5.0.3--canary.795.9498844134.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v5.0.2 (Thu Jun 13 2024)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - UrlSync: Remove console.log left in prev PR [#794](https://github.com/grafana/scenes/pull/794) ([@torkelo](https://github.com/torkelo))
6
+
7
+ #### Authors: 1
8
+
9
+ - Torkel Ödegaard ([@torkelo](https://github.com/torkelo))
10
+
11
+ ---
12
+
1
13
  # v5.0.1 (Thu Jun 13 2024)
2
14
 
3
15
  #### 🐛 Bug Fix
@@ -88,6 +88,9 @@ class SceneDataLayerBase extends SceneObjectBase {
88
88
  return this._results;
89
89
  }
90
90
  shouldRunLayerOnActivate() {
91
+ if (!this.state.isEnabled) {
92
+ return false;
93
+ }
91
94
  if (this._variableValueRecorder.hasDependenciesChanged(this)) {
92
95
  writeSceneLog(
93
96
  "SceneDataLayerBase",
@@ -1 +1 @@
1
- {"version":3,"file":"SceneDataLayerBase.js","sources":["../../../../src/querying/layers/SceneDataLayerBase.ts"],"sourcesContent":["import { PanelData } from '@grafana/data';\nimport { ReplaySubject, Unsubscribable } from 'rxjs';\nimport { emptyPanelData } from '../../core/SceneDataNode';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport {\n CancelActivationHandler,\n SceneDataLayerProvider,\n SceneDataProviderResult,\n SceneDataLayerProviderState,\n} from '../../core/types';\nimport { setBaseClassState } from '../../utils/utils';\nimport { writeSceneLog } from '../../utils/writeSceneLog';\nimport { VariableDependencyConfig } from '../../variables/VariableDependencyConfig';\nimport { VariableValueRecorder } from '../../variables/VariableValueRecorder';\n\n/**\n * Base class for data layer. Handles common implementation including enabling/disabling layer and publishing results.\n */\nexport abstract class SceneDataLayerBase<T extends SceneDataLayerProviderState>\n extends SceneObjectBase<T>\n implements SceneDataLayerProvider\n{\n /**\n * Subscription to query results. Should be set when layer runs a query.\n */\n protected querySub?: Unsubscribable;\n\n /**\n * Subject to emit results to.\n */\n private _results = new ReplaySubject<SceneDataProviderResult>(1);\n\n /**\n * Implement logic for enabling the layer. This is called when layer is enabled or when layer is enabled when activated.\n * Use i.e. to setup subscriptions that will trigger layer updates.\n */\n public abstract onEnable(): void;\n\n /**\n * Implement logic for disabling the layer. This is called when layer is disabled.\n * Use i.e. to unsubscribe from subscriptions that trigger layer updates.\n */\n public abstract onDisable(): void;\n\n /**\n * Implement logic running the layer and setting up the querySub subscription.\n */\n protected abstract runLayer(): void;\n\n /**\n * Mark data provider as data layer\n */\n public isDataLayer: true = true;\n\n private _variableValueRecorder = new VariableValueRecorder();\n\n protected _variableDependency: VariableDependencyConfig<T> = new VariableDependencyConfig(this, {\n onVariableUpdateCompleted: this.onVariableUpdateCompleted.bind(this),\n });\n\n /**\n * For variables support in data layer provide variableDependencyStatePaths with keys of the state to be scanned for variables.\n */\n public constructor(initialState: T, variableDependencyStatePaths: Array<keyof T> = []) {\n super({\n isEnabled: true,\n ...initialState,\n });\n\n this._variableDependency.setPaths(variableDependencyStatePaths);\n this.addActivationHandler(() => this.onActivate());\n }\n\n protected onActivate(): CancelActivationHandler {\n if (this.state.isEnabled) {\n this.onEnable();\n }\n\n if (this.shouldRunLayerOnActivate()) {\n this.runLayer();\n }\n\n // Subscribe to layer state changes and enable/disable layer accordingly.\n this.subscribeToState((n, p) => {\n if (!n.isEnabled && this.querySub) {\n // When layer disabled, cancel query and call onDisable that should publish empty results.\n this.querySub.unsubscribe();\n this.querySub = undefined;\n this.onDisable();\n\n // Manually publishing the results to state and results stream as publishPublish results has a guard for the layer to be enabled.\n this._results.next({ origin: this, data: emptyPanelData });\n\n this.setStateHelper({ data: emptyPanelData });\n }\n\n if (n.isEnabled && !p.isEnabled) {\n // When layer enabled, run queries.\n this.onEnable();\n this.runLayer();\n }\n });\n\n return () => {\n this.onDeactivate();\n };\n }\n\n protected onDeactivate(): void {\n if (this.querySub) {\n this.querySub.unsubscribe();\n this.querySub = undefined;\n }\n\n this.onDisable();\n\n this._variableValueRecorder.recordCurrentDependencyValuesForSceneObject(this);\n }\n\n protected onVariableUpdateCompleted(): void {\n this.runLayer();\n }\n\n public cancelQuery() {\n if (this.querySub) {\n this.querySub.unsubscribe();\n this.querySub = undefined;\n\n this.publishResults(emptyPanelData);\n }\n }\n\n protected publishResults(data: PanelData) {\n if (this.state.isEnabled) {\n this._results.next({ origin: this, data });\n this.setStateHelper({ data });\n }\n }\n\n public getResultsStream() {\n return this._results;\n }\n\n private shouldRunLayerOnActivate() {\n if (this._variableValueRecorder.hasDependenciesChanged(this)) {\n writeSceneLog(\n 'SceneDataLayerBase',\n 'Variable dependency changed while inactive, shouldRunLayerOnActivate returns true'\n );\n return true;\n }\n\n if (!this.state.data) {\n return true;\n }\n\n return false;\n }\n\n /**\n * This helper function is to counter the contravariance of setState\n */\n private setStateHelper(state: Partial<SceneDataLayerProviderState>) {\n setBaseClassState<SceneDataLayerProviderState>(this, state);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkBO,MAAe,2BACZ,eAEV,CAAA;AAAA,EA0CS,WAAY,CAAA,YAAA,EAAiB,4BAA+C,GAAA,EAAI,EAAA;AACrF,IAAM,KAAA,CAAA,cAAA,CAAA;AAAA,MACJ,SAAW,EAAA,IAAA;AAAA,KAAA,EACR,YACJ,CAAA,CAAA,CAAA;AArCH,IAAQ,IAAA,CAAA,QAAA,GAAW,IAAI,aAAA,CAAuC,CAAC,CAAA,CAAA;AAsB/D,IAAA,IAAA,CAAO,WAAoB,GAAA,IAAA,CAAA;AAE3B,IAAQ,IAAA,CAAA,sBAAA,GAAyB,IAAI,qBAAsB,EAAA,CAAA;AAE3D,IAAU,IAAA,CAAA,mBAAA,GAAmD,IAAI,wBAAA,CAAyB,IAAM,EAAA;AAAA,MAC9F,yBAA2B,EAAA,IAAA,CAAK,yBAA0B,CAAA,IAAA,CAAK,IAAI,CAAA;AAAA,KACpE,CA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A;AAAA,GACT;AAAA,EAKQ,eAAe,KAA6C,EAAA;AAClE,IAAA,iBAAA,CAA+C,MAAM,KAAK,CAAA,CAAA;AAAA,GAC5D;AACF;;;;"}
1
+ {"version":3,"file":"SceneDataLayerBase.js","sources":["../../../../src/querying/layers/SceneDataLayerBase.ts"],"sourcesContent":["import { PanelData } from '@grafana/data';\nimport { ReplaySubject, Unsubscribable } from 'rxjs';\nimport { emptyPanelData } from '../../core/SceneDataNode';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport {\n CancelActivationHandler,\n SceneDataLayerProvider,\n SceneDataProviderResult,\n SceneDataLayerProviderState,\n} from '../../core/types';\nimport { setBaseClassState } from '../../utils/utils';\nimport { writeSceneLog } from '../../utils/writeSceneLog';\nimport { VariableDependencyConfig } from '../../variables/VariableDependencyConfig';\nimport { VariableValueRecorder } from '../../variables/VariableValueRecorder';\n\n/**\n * Base class for data layer. Handles common implementation including enabling/disabling layer and publishing results.\n */\nexport abstract class SceneDataLayerBase<T extends SceneDataLayerProviderState>\n extends SceneObjectBase<T>\n implements SceneDataLayerProvider\n{\n /**\n * Subscription to query results. Should be set when layer runs a query.\n */\n protected querySub?: Unsubscribable;\n\n /**\n * Subject to emit results to.\n */\n private _results = new ReplaySubject<SceneDataProviderResult>(1);\n\n /**\n * Implement logic for enabling the layer. This is called when layer is enabled or when layer is enabled when activated.\n * Use i.e. to setup subscriptions that will trigger layer updates.\n */\n public abstract onEnable(): void;\n\n /**\n * Implement logic for disabling the layer. This is called when layer is disabled.\n * Use i.e. to unsubscribe from subscriptions that trigger layer updates.\n */\n public abstract onDisable(): void;\n\n /**\n * Implement logic running the layer and setting up the querySub subscription.\n */\n protected abstract runLayer(): void;\n\n /**\n * Mark data provider as data layer\n */\n public isDataLayer: true = true;\n\n private _variableValueRecorder = new VariableValueRecorder();\n\n protected _variableDependency: VariableDependencyConfig<T> = new VariableDependencyConfig(this, {\n onVariableUpdateCompleted: this.onVariableUpdateCompleted.bind(this),\n });\n\n /**\n * For variables support in data layer provide variableDependencyStatePaths with keys of the state to be scanned for variables.\n */\n public constructor(initialState: T, variableDependencyStatePaths: Array<keyof T> = []) {\n super({\n isEnabled: true,\n ...initialState,\n });\n\n this._variableDependency.setPaths(variableDependencyStatePaths);\n this.addActivationHandler(() => this.onActivate());\n }\n\n protected onActivate(): CancelActivationHandler {\n if (this.state.isEnabled) {\n this.onEnable();\n }\n\n if (this.shouldRunLayerOnActivate()) {\n this.runLayer();\n }\n\n // Subscribe to layer state changes and enable/disable layer accordingly.\n this.subscribeToState((n, p) => {\n if (!n.isEnabled && this.querySub) {\n // When layer disabled, cancel query and call onDisable that should publish empty results.\n this.querySub.unsubscribe();\n this.querySub = undefined;\n this.onDisable();\n\n // Manually publishing the results to state and results stream as publishPublish results has a guard for the layer to be enabled.\n this._results.next({ origin: this, data: emptyPanelData });\n\n this.setStateHelper({ data: emptyPanelData });\n }\n\n if (n.isEnabled && !p.isEnabled) {\n // When layer enabled, run queries.\n this.onEnable();\n this.runLayer();\n }\n });\n\n return () => {\n this.onDeactivate();\n };\n }\n\n protected onDeactivate(): void {\n if (this.querySub) {\n this.querySub.unsubscribe();\n this.querySub = undefined;\n }\n\n this.onDisable();\n\n this._variableValueRecorder.recordCurrentDependencyValuesForSceneObject(this);\n }\n\n protected onVariableUpdateCompleted(): void {\n this.runLayer();\n }\n\n public cancelQuery() {\n if (this.querySub) {\n this.querySub.unsubscribe();\n this.querySub = undefined;\n\n this.publishResults(emptyPanelData);\n }\n }\n\n protected publishResults(data: PanelData) {\n if (this.state.isEnabled) {\n this._results.next({ origin: this, data });\n this.setStateHelper({ data });\n }\n }\n\n public getResultsStream() {\n return this._results;\n }\n\n private shouldRunLayerOnActivate() {\n if (!this.state.isEnabled) {\n return false;\n }\n\n if (this._variableValueRecorder.hasDependenciesChanged(this)) {\n writeSceneLog(\n 'SceneDataLayerBase',\n 'Variable dependency changed while inactive, shouldRunLayerOnActivate returns true'\n );\n return true;\n }\n\n if (!this.state.data) {\n return true;\n }\n\n return false;\n }\n\n /**\n * This helper function is to counter the contravariance of setState\n */\n private setStateHelper(state: Partial<SceneDataLayerProviderState>) {\n setBaseClassState<SceneDataLayerProviderState>(this, state);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkBO,MAAe,2BACZ,eAEV,CAAA;AAAA,EA0CS,WAAY,CAAA,YAAA,EAAiB,4BAA+C,GAAA,EAAI,EAAA;AACrF,IAAM,KAAA,CAAA,cAAA,CAAA;AAAA,MACJ,SAAW,EAAA,IAAA;AAAA,KAAA,EACR,YACJ,CAAA,CAAA,CAAA;AArCH,IAAQ,IAAA,CAAA,QAAA,GAAW,IAAI,aAAA,CAAuC,CAAC,CAAA,CAAA;AAsB/D,IAAA,IAAA,CAAO,WAAoB,GAAA,IAAA,CAAA;AAE3B,IAAQ,IAAA,CAAA,sBAAA,GAAyB,IAAI,qBAAsB,EAAA,CAAA;AAE3D,IAAU,IAAA,CAAA,mBAAA,GAAmD,IAAI,wBAAA,CAAyB,IAAM,EAAA;AAAA,MAC9F,yBAA2B,EAAA,IAAA,CAAK,yBAA0B,CAAA,IAAA,CAAK,IAAI,CAAA;AAAA,KACpE,CAAA,CAAA;AAWC,IAAK,IAAA,CAAA,mBAAA,CAAoB,SAAS,4BAA4B,CAAA,CAAA;AAC9D,IAAA,IAAA,CAAK,oBAAqB,CAAA,MAAM,IAAK,CAAA,UAAA,EAAY,CAAA,CAAA;AAAA,GACnD;AAAA,EAEU,UAAsC,GAAA;AAC9C,IAAI,IAAA,IAAA,CAAK,MAAM,SAAW,EAAA;AACxB,MAAA,IAAA,CAAK,QAAS,EAAA,CAAA;AAAA,KAChB;AAEA,IAAI,IAAA,IAAA,CAAK,0BAA4B,EAAA;AACnC,MAAA,IAAA,CAAK,QAAS,EAAA,CAAA;AAAA,KAChB;AAGA,IAAK,IAAA,CAAA,gBAAA,CAAiB,CAAC,CAAA,EAAG,CAAM,KAAA;AAC9B,MAAA,IAAI,CAA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IAAA,CAAK,eAAe,cAAc,CAAA,CAAA;AAAA,KACpC;AAAA,GACF;AAAA,EAEU,eAAe,IAAiB,EAAA;AACxC,IAAI,IAAA,IAAA,CAAK,MAAM,SAAW,EAAA;AACxB,MAAA,IAAA,CAAK,SAAS,IAAK,CAAA,EAAE,MAAQ,EAAA,IAAA,EAAM,MAAM,CAAA,CAAA;AACzC,MAAK,IAAA,CAAA,cAAA,CAAe,EAAE,IAAA,EAAM,CAAA,CAAA;AAAA,KAC9B;AAAA,GACF;AAAA,EAEO,gBAAmB,GAAA;AACxB,IAAA,OAAO,IAAK,CAAA,QAAA,CAAA;AAAA,GACd;AAAA,EAEQ,wBAA2B,GAAA;AACjC,IAAI,IAAA,CAAC,IAAK,CAAA,KAAA,CAAM,SAAW,EAAA;AACzB,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAEA,IAAA,IAAI,IAAK,CAAA,sBAAA,CAAuB,sBAAuB,CAAA,IAAI,CAAG,EAAA;AAC5D,MAAA,aAAA;AAAA,QACE,oBAAA;AAAA,QACA,mFAAA;AAAA,OACF,CAAA;AACA,MAAO,OAAA,IAAA,CAAA;AAAA,KACT;AAEA,IAAI,IAAA,CAAC,IAAK,CAAA,KAAA,CAAM,IAAM,EAAA;AACpB,MAAO,OAAA,IAAA,CAAA;AAAA,KACT;AAEA,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAAA,EAKQ,eAAe,KAA6C,EAAA;AAClE,IAAA,iBAAA,CAA+C,MAAM,KAAK,CAAA,CAAA;AAAA,GAC5D;AACF;;;;"}
package/dist/index.js CHANGED
@@ -5538,6 +5538,9 @@ class SceneDataLayerBase extends SceneObjectBase {
5538
5538
  return this._results;
5539
5539
  }
5540
5540
  shouldRunLayerOnActivate() {
5541
+ if (!this.state.isEnabled) {
5542
+ return false;
5543
+ }
5541
5544
  if (this._variableValueRecorder.hasDependenciesChanged(this)) {
5542
5545
  writeSceneLog(
5543
5546
  "SceneDataLayerBase",