@grafana/scenes 6.9.1 → 6.9.2--canary.1109.14625976750.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/esm/core/SceneObjectBase.js +4 -15
- package/dist/esm/core/SceneObjectBase.js.map +1 -1
- package/dist/esm/core/SceneTimeRange.js +20 -4
- package/dist/esm/core/SceneTimeRange.js.map +1 -1
- package/dist/esm/core/constants.js +4 -0
- package/dist/esm/core/constants.js.map +1 -0
- package/dist/esm/variables/sets/SceneVariableSet.js +23 -23
- package/dist/esm/variables/sets/SceneVariableSet.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +49 -42
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var rxjs = require('rxjs');
|
|
|
10
10
|
var uuid = require('uuid');
|
|
11
11
|
var lodash = require('lodash');
|
|
12
12
|
var schema = require('@grafana/schema');
|
|
13
|
+
var moment = require('moment-timezone');
|
|
13
14
|
var ui = require('@grafana/ui');
|
|
14
15
|
var e2eSelectors = require('@grafana/e2e-selectors');
|
|
15
16
|
var css = require('@emotion/css');
|
|
@@ -38,6 +39,7 @@ var XYChartPanelCfg_types_gen = require('@grafana/schema/dist/esm/raw/composable
|
|
|
38
39
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
39
40
|
|
|
40
41
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
42
|
+
var moment__default = /*#__PURE__*/_interopDefaultCompat(moment);
|
|
41
43
|
var uFuzzy__default = /*#__PURE__*/_interopDefaultCompat(uFuzzy);
|
|
42
44
|
var ReactGridLayout__default = /*#__PURE__*/_interopDefaultCompat(ReactGridLayout);
|
|
43
45
|
|
|
@@ -461,29 +463,18 @@ function useSceneObjectState(model, options) {
|
|
|
461
463
|
return model.state;
|
|
462
464
|
}
|
|
463
465
|
function forEachChild(state, callback) {
|
|
464
|
-
|
|
465
|
-
state.$behaviors.forEach((behavior) => {
|
|
466
|
-
if (behavior instanceof SceneObjectBase) {
|
|
467
|
-
callback(behavior);
|
|
468
|
-
}
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
Object.keys(state).forEach((key) => {
|
|
472
|
-
if (key === "$behaviors") {
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
const propValue = state[key];
|
|
466
|
+
for (const propValue of Object.values(state)) {
|
|
476
467
|
if (propValue instanceof SceneObjectBase) {
|
|
477
468
|
callback(propValue);
|
|
478
469
|
}
|
|
479
470
|
if (Array.isArray(propValue)) {
|
|
480
|
-
|
|
471
|
+
for (const child of propValue) {
|
|
481
472
|
if (child instanceof SceneObjectBase) {
|
|
482
473
|
callback(child);
|
|
483
474
|
}
|
|
484
|
-
}
|
|
475
|
+
}
|
|
485
476
|
}
|
|
486
|
-
}
|
|
477
|
+
}
|
|
487
478
|
}
|
|
488
479
|
|
|
489
480
|
function cloneSceneObject(sceneObject, withState) {
|
|
@@ -996,12 +987,14 @@ function isValid$1(value, roundUp, timeZone) {
|
|
|
996
987
|
return parsed.isValid();
|
|
997
988
|
}
|
|
998
989
|
|
|
990
|
+
const BROWSER = "browser";
|
|
991
|
+
|
|
999
992
|
class SceneTimeRange extends SceneObjectBase {
|
|
1000
993
|
constructor(state = {}) {
|
|
1001
994
|
var _a;
|
|
1002
995
|
const from = state.from && isValid$1(state.from) ? state.from : "now-6h";
|
|
1003
996
|
const to = state.to && isValid$1(state.to) ? state.to : "now";
|
|
1004
|
-
const timeZone = state.timeZone;
|
|
997
|
+
const timeZone = getValidTimeZone(state.timeZone);
|
|
1005
998
|
const value = evaluateTimeRange(
|
|
1006
999
|
from,
|
|
1007
1000
|
to,
|
|
@@ -1043,7 +1036,8 @@ class SceneTimeRange extends SceneObjectBase {
|
|
|
1043
1036
|
};
|
|
1044
1037
|
this.onTimeZoneChange = (timeZone) => {
|
|
1045
1038
|
this._urlSync.performBrowserHistoryAction(() => {
|
|
1046
|
-
|
|
1039
|
+
var _a;
|
|
1040
|
+
this.setState({ timeZone: (_a = getValidTimeZone(timeZone)) != null ? _a : BROWSER });
|
|
1047
1041
|
});
|
|
1048
1042
|
};
|
|
1049
1043
|
this.onRefresh = () => {
|
|
@@ -1130,11 +1124,11 @@ class SceneTimeRange extends SceneObjectBase {
|
|
|
1130
1124
|
return Math.ceil(intervalMs / percent);
|
|
1131
1125
|
}
|
|
1132
1126
|
getTimeZone() {
|
|
1133
|
-
if (this.state.timeZone) {
|
|
1127
|
+
if (this.state.timeZone && getValidTimeZone(this.state.timeZone)) {
|
|
1134
1128
|
return this.state.timeZone;
|
|
1135
1129
|
}
|
|
1136
1130
|
const timeZoneSource = this.getTimeZoneSource();
|
|
1137
|
-
if (timeZoneSource !== this) {
|
|
1131
|
+
if (timeZoneSource !== this && getValidTimeZone(timeZoneSource.state.timeZone)) {
|
|
1138
1132
|
return timeZoneSource.state.timeZone;
|
|
1139
1133
|
}
|
|
1140
1134
|
return data.getTimeZone();
|
|
@@ -1200,6 +1194,19 @@ function getTimeWindow(time, timeWindow) {
|
|
|
1200
1194
|
to: data.toUtc(valueTime + timeWindowMs / 2).toISOString()
|
|
1201
1195
|
};
|
|
1202
1196
|
}
|
|
1197
|
+
function getValidTimeZone(timeZone) {
|
|
1198
|
+
if (timeZone === void 0) {
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
if (timeZone === BROWSER) {
|
|
1202
|
+
return timeZone;
|
|
1203
|
+
}
|
|
1204
|
+
if (moment__default.default.tz.zone(timeZone)) {
|
|
1205
|
+
return timeZone;
|
|
1206
|
+
}
|
|
1207
|
+
console.warn(`Invalid timeZone "${timeZone}" provided.`);
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1203
1210
|
|
|
1204
1211
|
const EmptyDataNode = new SceneDataNode();
|
|
1205
1212
|
const DefaultTimeRange = new SceneTimeRange();
|
|
@@ -9614,31 +9621,31 @@ class SceneVariableSet extends SceneObjectBase {
|
|
|
9614
9621
|
if (!this.parent) {
|
|
9615
9622
|
return;
|
|
9616
9623
|
}
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
|
|
9636
|
-
if (node.variableDependency) {
|
|
9637
|
-
node.variableDependency.variableUpdateCompleted(variableThatChanged, hasChanged);
|
|
9624
|
+
this._traverseSceneAndNotify(this.parent, variable, this._variablesThatHaveChanged.has(variable));
|
|
9625
|
+
this._variablesThatHaveChanged.delete(variable);
|
|
9626
|
+
}
|
|
9627
|
+
/**
|
|
9628
|
+
* Recursivly walk the full scene object graph and notify all objects with dependencies that include any of changed variables
|
|
9629
|
+
*/
|
|
9630
|
+
_traverseSceneAndNotify(sceneObject, variable, hasChanged) {
|
|
9631
|
+
if (this === sceneObject) {
|
|
9632
|
+
return;
|
|
9633
|
+
}
|
|
9634
|
+
if (!sceneObject.isActive) {
|
|
9635
|
+
return;
|
|
9636
|
+
}
|
|
9637
|
+
if (sceneObject.state.$variables && sceneObject.state.$variables !== this) {
|
|
9638
|
+
const localVar = sceneObject.state.$variables.getByName(variable.state.name);
|
|
9639
|
+
if (localVar == null ? void 0 : localVar.isAncestorLoading) {
|
|
9640
|
+
variable = localVar;
|
|
9641
|
+
} else if (localVar) {
|
|
9642
|
+
return;
|
|
9638
9643
|
}
|
|
9639
|
-
node.forEachChild((child) => nodeQueue.push(child));
|
|
9640
9644
|
}
|
|
9641
|
-
|
|
9645
|
+
if (sceneObject.variableDependency) {
|
|
9646
|
+
sceneObject.variableDependency.variableUpdateCompleted(variable, hasChanged);
|
|
9647
|
+
}
|
|
9648
|
+
sceneObject.forEachChild((child) => this._traverseSceneAndNotify(child, variable, hasChanged));
|
|
9642
9649
|
}
|
|
9643
9650
|
/**
|
|
9644
9651
|
* Return true if variable is waiting to update or currently updating.
|