@grafana/scenes 6.11.1 → 6.12.0--canary.1121.15045230319.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/CHANGELOG.md +0 -12
- package/dist/esm/components/SceneApp/SceneApp.js +2 -2
- package/dist/esm/components/SceneApp/SceneApp.js.map +1 -1
- package/dist/esm/components/SceneApp/SceneAppPage.js +2 -18
- package/dist/esm/components/SceneApp/SceneAppPage.js.map +1 -1
- package/dist/esm/components/VizPanel/VizPanel.js +2 -2
- package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
- package/dist/esm/core/sceneGraph/index.js +2 -2
- package/dist/esm/core/sceneGraph/index.js.map +1 -1
- package/dist/esm/core/sceneGraph/sceneGraph.js +9 -5
- package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/querying/SceneQueryRunner.js +10 -33
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
- package/dist/esm/variables/VariableDependencyConfig.js +4 -1
- package/dist/esm/variables/VariableDependencyConfig.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +19 -18
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
- package/dist/esm/variables/components/VariableValueSelectors.js +3 -0
- package/dist/esm/variables/components/VariableValueSelectors.js.map +1 -1
- package/dist/esm/variables/constants.js +2 -1
- package/dist/esm/variables/constants.js.map +1 -1
- package/dist/esm/variables/groupby/GroupByVariable.js +2 -2
- package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
- package/dist/esm/variables/sets/SceneVariableSet.js +10 -7
- package/dist/esm/variables/sets/SceneVariableSet.js.map +1 -1
- package/dist/esm/variables/types.js.map +1 -1
- package/dist/esm/variables/variants/ScopesVariable.js +80 -0
- package/dist/esm/variables/variants/ScopesVariable.js.map +1 -0
- package/dist/index.d.ts +56 -53
- package/dist/index.js +112 -151
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/core/SceneScopesBridge.js +0 -93
- package/dist/esm/core/SceneScopesBridge.js.map +0 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@grafana/scenes",
|
3
|
-
"version": "6.
|
3
|
+
"version": "6.12.0--canary.1121.15045230319.0",
|
4
4
|
"description": "Grafana framework for building dynamic dashboards",
|
5
5
|
"author": "Grafana Labs",
|
6
6
|
"license": "AGPL-3.0-only",
|
@@ -116,5 +116,5 @@
|
|
116
116
|
"prettier --write"
|
117
117
|
]
|
118
118
|
},
|
119
|
-
"gitHead": "
|
119
|
+
"gitHead": "2c8ded7d9fffe2fd3fc9e6c41905527927bfefe9"
|
120
120
|
}
|
@@ -1,93 +0,0 @@
|
|
1
|
-
import { isEqual } from 'lodash';
|
2
|
-
import { useEffect } from 'react';
|
3
|
-
import { BehaviorSubject, map, pairwise, filter } from 'rxjs';
|
4
|
-
import { useScopes } from '@grafana/runtime';
|
5
|
-
import { SceneObjectBase } from './SceneObjectBase.js';
|
6
|
-
|
7
|
-
class SceneScopesBridge extends SceneObjectBase {
|
8
|
-
constructor() {
|
9
|
-
super(...arguments);
|
10
|
-
this._renderBeforeActivation = true;
|
11
|
-
this._contextSubject = new BehaviorSubject(void 0);
|
12
|
-
}
|
13
|
-
getValue() {
|
14
|
-
var _a, _b;
|
15
|
-
return (_b = (_a = this.context) == null ? void 0 : _a.state.value) != null ? _b : [];
|
16
|
-
}
|
17
|
-
/**
|
18
|
-
* Emits values of the selected scopes array. It emits the current value and the previous value if there is a change.
|
19
|
-
* @param cb
|
20
|
-
*/
|
21
|
-
subscribeToValue(cb) {
|
22
|
-
return this.contextObservable.pipe(
|
23
|
-
map((context) => {
|
24
|
-
var _a;
|
25
|
-
return (_a = context == null ? void 0 : context.state.value) != null ? _a : [];
|
26
|
-
}),
|
27
|
-
pairwise(),
|
28
|
-
filter(([prevScopes, newScopes]) => !isEqual(prevScopes, newScopes))
|
29
|
-
).subscribe(([prevScopes, newScopes]) => {
|
30
|
-
cb(newScopes, prevScopes);
|
31
|
-
});
|
32
|
-
}
|
33
|
-
isLoading() {
|
34
|
-
var _a, _b;
|
35
|
-
return (_b = (_a = this.context) == null ? void 0 : _a.state.loading) != null ? _b : false;
|
36
|
-
}
|
37
|
-
subscribeToLoading(cb) {
|
38
|
-
return this.contextObservable.pipe(
|
39
|
-
filter((context) => !!context),
|
40
|
-
pairwise(),
|
41
|
-
map(
|
42
|
-
([prevContext, newContext]) => {
|
43
|
-
var _a, _b;
|
44
|
-
return [(_a = prevContext == null ? void 0 : prevContext.state.loading) != null ? _a : false, (_b = newContext == null ? void 0 : newContext.state.loading) != null ? _b : false];
|
45
|
-
}
|
46
|
-
),
|
47
|
-
filter(([prevLoading, newLoading]) => prevLoading !== newLoading)
|
48
|
-
).subscribe(([_prevLoading, newLoading]) => {
|
49
|
-
cb(newLoading);
|
50
|
-
});
|
51
|
-
}
|
52
|
-
setEnabled(enabled) {
|
53
|
-
var _a;
|
54
|
-
(_a = this.context) == null ? void 0 : _a.setEnabled(enabled);
|
55
|
-
}
|
56
|
-
setReadOnly(readOnly) {
|
57
|
-
var _a;
|
58
|
-
(_a = this.context) == null ? void 0 : _a.setReadOnly(readOnly);
|
59
|
-
}
|
60
|
-
/**
|
61
|
-
* This method is used to keep the context up to date with the scopes context received from React
|
62
|
-
*
|
63
|
-
* Its rationale is:
|
64
|
-
* - When a new context is available, check if we have pending scopes passed from the URL
|
65
|
-
* - If we have pending scopes, ask the new context to load them
|
66
|
-
* - The loading should happen in a setTimeout to allow the existing context to pass its values to the URL sync handler
|
67
|
-
* - If a new context is received, propagate it as a new value in the behavior subject
|
68
|
-
* - If a new value is received, force a re-render to trigger the URL sync handler
|
69
|
-
*/
|
70
|
-
updateContext(newContext) {
|
71
|
-
var _a;
|
72
|
-
if (this.context !== newContext || ((_a = this.context) == null ? void 0 : _a.state) !== (newContext == null ? void 0 : newContext.state)) {
|
73
|
-
this._contextSubject.next(newContext);
|
74
|
-
}
|
75
|
-
}
|
76
|
-
get context() {
|
77
|
-
return this._contextSubject.getValue();
|
78
|
-
}
|
79
|
-
get contextObservable() {
|
80
|
-
return this._contextSubject.asObservable();
|
81
|
-
}
|
82
|
-
}
|
83
|
-
SceneScopesBridge.Component = SceneScopesBridgeRenderer;
|
84
|
-
function SceneScopesBridgeRenderer({ model }) {
|
85
|
-
const context = useScopes();
|
86
|
-
useEffect(() => {
|
87
|
-
model.updateContext(context);
|
88
|
-
}, [context, model]);
|
89
|
-
return null;
|
90
|
-
}
|
91
|
-
|
92
|
-
export { SceneScopesBridge };
|
93
|
-
//# sourceMappingURL=SceneScopesBridge.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"SceneScopesBridge.js","sources":["../../../src/core/SceneScopesBridge.ts"],"sourcesContent":["import { isEqual } from 'lodash';\nimport { useEffect } from 'react';\nimport { BehaviorSubject, filter, map, Observable, pairwise, Unsubscribable } from 'rxjs';\n\nimport { Scope } from '@grafana/data';\nimport { ScopesContextValue, useScopes } from '@grafana/runtime';\n\nimport { SceneObjectBase } from './SceneObjectBase';\nimport { SceneComponentProps } from './types';\n\nexport class SceneScopesBridge extends SceneObjectBase {\n static Component = SceneScopesBridgeRenderer;\n\n protected _renderBeforeActivation = true;\n\n private _contextSubject = new BehaviorSubject<ScopesContextValue | undefined>(undefined);\n\n public getValue(): Scope[] {\n return this.context?.state.value ?? [];\n }\n\n /**\n * Emits values of the selected scopes array. It emits the current value and the previous value if there is a change.\n * @param cb\n */\n public subscribeToValue(cb: (newScopes: Scope[], prevScopes: Scope[]) => void): Unsubscribable {\n return this.contextObservable\n .pipe(\n map((context) => context?.state.value ?? []),\n pairwise(),\n filter(([prevScopes, newScopes]) => !isEqual(prevScopes, newScopes))\n )\n .subscribe(([prevScopes, newScopes]) => {\n cb(newScopes, prevScopes);\n });\n }\n\n public isLoading(): boolean {\n return this.context?.state.loading ?? false;\n }\n\n public subscribeToLoading(cb: (loading: boolean) => void): Unsubscribable {\n return this.contextObservable\n .pipe(\n filter((context) => !!context),\n pairwise(),\n map(\n ([prevContext, newContext]) =>\n [prevContext?.state.loading ?? false, newContext?.state.loading ?? false] as [boolean, boolean]\n ),\n filter(([prevLoading, newLoading]) => prevLoading !== newLoading)\n )\n .subscribe(([_prevLoading, newLoading]) => {\n cb(newLoading);\n });\n }\n\n public setEnabled(enabled: boolean) {\n this.context?.setEnabled(enabled);\n }\n\n public setReadOnly(readOnly: boolean) {\n this.context?.setReadOnly(readOnly);\n }\n\n /**\n * This method is used to keep the context up to date with the scopes context received from React\n *\n * Its rationale is:\n * - When a new context is available, check if we have pending scopes passed from the URL\n * - If we have pending scopes, ask the new context to load them\n * - The loading should happen in a setTimeout to allow the existing context to pass its values to the URL sync handler\n * - If a new context is received, propagate it as a new value in the behavior subject\n * - If a new value is received, force a re-render to trigger the URL sync handler\n */\n public updateContext(newContext: ScopesContextValue | undefined) {\n if (this.context !== newContext || this.context?.state !== newContext?.state) {\n this._contextSubject.next(newContext);\n }\n }\n\n private get context(): ScopesContextValue | undefined {\n return this._contextSubject.getValue();\n }\n\n private get contextObservable(): Observable<ScopesContextValue | undefined> {\n return this._contextSubject.asObservable();\n }\n}\n\nfunction SceneScopesBridgeRenderer({ model }: SceneComponentProps<SceneScopesBridge>) {\n const context = useScopes();\n\n useEffect(() => {\n model.updateContext(context);\n }, [context, model]);\n\n return null;\n}\n"],"names":[],"mappings":";;;;;;AAUO,MAAM,0BAA0B,eAAgB,CAAA;AAAA,EAAhD,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAGL,IAAA,IAAA,CAAU,uBAA0B,GAAA,IAAA;AAEpC,IAAQ,IAAA,CAAA,eAAA,GAAkB,IAAI,eAAA,CAAgD,MAAS,CAAA;AAAA;AAAA,EAEhF,QAAoB,GAAA;AAjB7B,IAAA,IAAA,EAAA,EAAA,EAAA;AAkBI,IAAA,OAAA,C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