@grafana/scenes 4.24.2--canary.755.9271425573.0 → 4.24.2--canary.757.9280867929.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +14 -0
- package/dist/esm/components/EmbeddedScene.js +1 -2
- package/dist/esm/components/EmbeddedScene.js.map +1 -1
- package/dist/esm/components/VizPanel/VizPanel.js +0 -3
- package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
- package/dist/esm/components/layout/grid/SceneGridLayout.js +15 -1
- package/dist/esm/components/layout/grid/SceneGridLayout.js.map +1 -1
- package/dist/esm/core/types.js.map +1 -1
- package/dist/esm/index.js +1 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
- package/dist/esm/services/UniqueUrlKeyMapper.js +1 -1
- package/dist/esm/services/UniqueUrlKeyMapper.js.map +1 -1
- package/dist/esm/services/UrlSyncManager.js +3 -11
- package/dist/esm/services/UrlSyncManager.js.map +1 -1
- package/dist/esm/utils/writeSceneLog.js +1 -5
- package/dist/esm/utils/writeSceneLog.js.map +1 -1
- package/dist/esm/variables/utils.js.map +1 -1
- package/dist/esm/variables/variants/MultiValueVariable.js +34 -17
- package/dist/esm/variables/variants/MultiValueVariable.js.map +1 -1
- package/dist/esm/variables/variants/query/QueryVariable.js.map +1 -1
- package/dist/index.d.ts +147 -245
- package/dist/index.js +55 -212
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/core/PanelBuilders/VizConfigBuilder.js +0 -78
- package/dist/esm/core/PanelBuilders/VizConfigBuilder.js.map +0 -1
- package/dist/esm/core/PanelBuilders/VizConfigBuilders.js +0 -114
- package/dist/esm/core/PanelBuilders/VizConfigBuilders.js.map +0 -1
package/dist/index.js
CHANGED
@@ -591,7 +591,7 @@ class UniqueUrlKeyMapper {
|
|
591
591
|
getUniqueKey(key, obj) {
|
592
592
|
const objectsWithKey = this.index.get(key);
|
593
593
|
if (!objectsWithKey) {
|
594
|
-
|
594
|
+
throw new Error("Cannot find any scene object that uses the key '" + key + "'");
|
595
595
|
}
|
596
596
|
const address = objectsWithKey.findIndex((o) => o.sceneObject === obj);
|
597
597
|
if (address > 0) {
|
@@ -2042,11 +2042,7 @@ async function getDataSource(datasource, scopedVars) {
|
|
2042
2042
|
}
|
2043
2043
|
|
2044
2044
|
function writeSceneLog(logger, message, ...rest) {
|
2045
|
-
|
2046
|
-
if (typeof window !== "undefined") {
|
2047
|
-
loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
|
2048
|
-
}
|
2049
|
-
if (loggingEnabled) {
|
2045
|
+
if (window.grafanaSceneLogging) {
|
2050
2046
|
console.log(`${logger}: `, message, ...rest);
|
2051
2047
|
}
|
2052
2048
|
}
|
@@ -2663,6 +2659,14 @@ class MultiValueVariable extends SceneObjectBase {
|
|
2663
2659
|
}
|
2664
2660
|
updateValueGivenNewOptions(options) {
|
2665
2661
|
const { value: currentValue, text: currentText } = this.state;
|
2662
|
+
const stateUpdate = this.getStateUpdateGivenNewOptions(options, currentValue, currentText);
|
2663
|
+
this.interceptStateUpdateAfterValidation(stateUpdate);
|
2664
|
+
this.setStateHelper(stateUpdate);
|
2665
|
+
if (stateUpdate.value !== currentValue || stateUpdate.text !== currentText || this.hasAllValue()) {
|
2666
|
+
this.publishEvent(new SceneVariableValueChangedEvent(this), true);
|
2667
|
+
}
|
2668
|
+
}
|
2669
|
+
getStateUpdateGivenNewOptions(options, currentValue, currentText) {
|
2666
2670
|
const stateUpdate = {
|
2667
2671
|
options,
|
2668
2672
|
loading: false,
|
@@ -2680,7 +2684,20 @@ class MultiValueVariable extends SceneObjectBase {
|
|
2680
2684
|
stateUpdate.value = "";
|
2681
2685
|
stateUpdate.text = "";
|
2682
2686
|
}
|
2683
|
-
|
2687
|
+
return stateUpdate;
|
2688
|
+
}
|
2689
|
+
if (this.hasAllValue()) {
|
2690
|
+
if (!this.state.includeAll) {
|
2691
|
+
stateUpdate.value = options[0].value;
|
2692
|
+
stateUpdate.text = options[0].label;
|
2693
|
+
if (this.state.isMulti) {
|
2694
|
+
stateUpdate.value = [stateUpdate.value];
|
2695
|
+
stateUpdate.text = [stateUpdate.text];
|
2696
|
+
}
|
2697
|
+
}
|
2698
|
+
return stateUpdate;
|
2699
|
+
}
|
2700
|
+
if (this.state.isMulti) {
|
2684
2701
|
const currentValues = Array.isArray(currentValue) ? currentValue : [currentValue];
|
2685
2702
|
const validValues = currentValues.filter((v) => options.find((o) => o.value === v));
|
2686
2703
|
const validTexts = validValues.map((v) => options.find((o) => o.value === v).label);
|
@@ -2696,26 +2713,22 @@ class MultiValueVariable extends SceneObjectBase {
|
|
2696
2713
|
stateUpdate.text = validTexts;
|
2697
2714
|
}
|
2698
2715
|
}
|
2716
|
+
return stateUpdate;
|
2717
|
+
}
|
2718
|
+
let matchingOption = findOptionMatchingCurrent(currentValue, currentText, options);
|
2719
|
+
if (matchingOption) {
|
2720
|
+
stateUpdate.text = matchingOption.label;
|
2721
|
+
stateUpdate.value = matchingOption.value;
|
2699
2722
|
} else {
|
2700
|
-
|
2701
|
-
|
2702
|
-
stateUpdate.text =
|
2703
|
-
stateUpdate.value = matchingOption.value;
|
2723
|
+
if (this.state.defaultToAll) {
|
2724
|
+
stateUpdate.value = ALL_VARIABLE_VALUE;
|
2725
|
+
stateUpdate.text = ALL_VARIABLE_TEXT;
|
2704
2726
|
} else {
|
2705
|
-
|
2706
|
-
|
2707
|
-
stateUpdate.text = ALL_VARIABLE_TEXT;
|
2708
|
-
} else {
|
2709
|
-
stateUpdate.value = options[0].value;
|
2710
|
-
stateUpdate.text = options[0].label;
|
2711
|
-
}
|
2727
|
+
stateUpdate.value = options[0].value;
|
2728
|
+
stateUpdate.text = options[0].label;
|
2712
2729
|
}
|
2713
2730
|
}
|
2714
|
-
|
2715
|
-
this.setStateHelper(stateUpdate);
|
2716
|
-
if (stateUpdate.value !== currentValue || stateUpdate.text !== currentText || this.hasAllValue()) {
|
2717
|
-
this.publishEvent(new SceneVariableValueChangedEvent(this), true);
|
2718
|
-
}
|
2731
|
+
return stateUpdate;
|
2719
2732
|
}
|
2720
2733
|
interceptStateUpdateAfterValidation(stateUpdate) {
|
2721
2734
|
const isAllValueFix = stateUpdate.value === ALL_VARIABLE_VALUE && this.state.text === ALL_VARIABLE_TEXT;
|
@@ -5233,9 +5246,6 @@ class VizPanel extends SceneObjectBase {
|
|
5233
5246
|
(_a = this._panelContext) != null ? _a : this._panelContext = this.buildPanelContext();
|
5234
5247
|
return this._panelContext;
|
5235
5248
|
}
|
5236
|
-
clearFieldConfigCache() {
|
5237
|
-
this._dataWithFieldConfig = void 0;
|
5238
|
-
}
|
5239
5249
|
applyFieldConfig(rawData) {
|
5240
5250
|
var _a, _b, _c, _d;
|
5241
5251
|
const plugin = this._plugin;
|
@@ -7739,7 +7749,6 @@ class UrlSyncManager {
|
|
7739
7749
|
this._locationSub = null;
|
7740
7750
|
this._ignoreNextLocationUpdate = false;
|
7741
7751
|
this._onLocationUpdate = (location) => {
|
7742
|
-
this._urlParams = new URLSearchParams(location.search);
|
7743
7752
|
if (this._ignoreNextLocationUpdate) {
|
7744
7753
|
this._ignoreNextLocationUpdate = false;
|
7745
7754
|
return;
|
@@ -7747,8 +7756,9 @@ class UrlSyncManager {
|
|
7747
7756
|
if (this._lastPath !== location.pathname) {
|
7748
7757
|
return;
|
7749
7758
|
}
|
7759
|
+
const urlParams = new URLSearchParams(location.search);
|
7750
7760
|
this._urlKeyMapper.rebuildIndex(this._sceneRoot);
|
7751
|
-
syncStateFromUrl(this._sceneRoot,
|
7761
|
+
syncStateFromUrl(this._sceneRoot, urlParams, this._urlKeyMapper);
|
7752
7762
|
this._lastPath = location.pathname;
|
7753
7763
|
};
|
7754
7764
|
this._onStateChanged = ({ payload }) => {
|
@@ -7781,10 +7791,8 @@ class UrlSyncManager {
|
|
7781
7791
|
writeSceneLog("UrlSyncManager", "Unregister previous scene state subscription", this._sceneRoot.state.key);
|
7782
7792
|
this._stateSub.unsubscribe();
|
7783
7793
|
}
|
7784
|
-
const location = runtime.locationService.getLocation();
|
7785
7794
|
this._sceneRoot = root;
|
7786
|
-
this._lastPath =
|
7787
|
-
this._urlParams = new URLSearchParams(location.search);
|
7795
|
+
this._lastPath = runtime.locationService.getLocation().pathname;
|
7788
7796
|
this._stateSub = root.subscribeToEvent(SceneObjectStateChangedEvent, this._onStateChanged);
|
7789
7797
|
this.syncFrom(this._sceneRoot);
|
7790
7798
|
}
|
@@ -7814,12 +7822,6 @@ class UrlSyncManager {
|
|
7814
7822
|
this._urlKeyMapper.rebuildIndex(this._sceneRoot);
|
7815
7823
|
syncStateFromUrl(sceneObj, urlParams, this._urlKeyMapper);
|
7816
7824
|
}
|
7817
|
-
syncNewObj(obj) {
|
7818
|
-
if (!this._urlParams) {
|
7819
|
-
throw new Error("UrlSyncManager not initialized");
|
7820
|
-
}
|
7821
|
-
syncStateFromUrl(obj, this._urlParams, this._urlKeyMapper);
|
7822
|
-
}
|
7823
7825
|
getUrlState(root) {
|
7824
7826
|
return getUrlState(root);
|
7825
7827
|
}
|
@@ -7863,7 +7865,7 @@ EmbeddedScene.Component = EmbeddedSceneRenderer;
|
|
7863
7865
|
function EmbeddedSceneRenderer({ model }) {
|
7864
7866
|
const { body, controls } = model.useState();
|
7865
7867
|
const styles = ui.useStyles2(getStyles$5);
|
7866
|
-
|
7868
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
7867
7869
|
className: styles.container
|
7868
7870
|
}, controls && /* @__PURE__ */ React__default["default"].createElement("div", {
|
7869
7871
|
className: styles.controls
|
@@ -7875,7 +7877,6 @@ function EmbeddedSceneRenderer({ model }) {
|
|
7875
7877
|
}, /* @__PURE__ */ React__default["default"].createElement(body.Component, {
|
7876
7878
|
model: body
|
7877
7879
|
})));
|
7878
|
-
return inner;
|
7879
7880
|
}
|
7880
7881
|
const getStyles$5 = (theme) => {
|
7881
7882
|
return {
|
@@ -8334,7 +8335,9 @@ const _SceneGridLayout = class extends SceneObjectBase {
|
|
8334
8335
|
let newParent = this.findGridItemSceneParent(gridLayout, indexOfUpdatedItem - 1);
|
8335
8336
|
let newChildren = this.state.children;
|
8336
8337
|
if (sceneChild instanceof SceneGridRow && newParent instanceof SceneGridRow) {
|
8337
|
-
this.
|
8338
|
+
if (!this.isRowDropValid(gridLayout, updatedItem, indexOfUpdatedItem)) {
|
8339
|
+
this._loadOldLayout = true;
|
8340
|
+
}
|
8338
8341
|
newParent = this;
|
8339
8342
|
}
|
8340
8343
|
if (newParent !== sceneChild.parent) {
|
@@ -8430,6 +8433,18 @@ const _SceneGridLayout = class extends SceneObjectBase {
|
|
8430
8433
|
}
|
8431
8434
|
return this;
|
8432
8435
|
}
|
8436
|
+
isRowDropValid(gridLayout, updatedItem, indexOfUpdatedItem) {
|
8437
|
+
if (gridLayout[gridLayout.length - 1].i === updatedItem.i) {
|
8438
|
+
return true;
|
8439
|
+
}
|
8440
|
+
const nextSceneChild = this.getSceneLayoutChild(gridLayout[indexOfUpdatedItem + 1].i);
|
8441
|
+
if (nextSceneChild instanceof SceneGridRow) {
|
8442
|
+
return true;
|
8443
|
+
} else if (nextSceneChild.parent instanceof _SceneGridLayout) {
|
8444
|
+
return true;
|
8445
|
+
}
|
8446
|
+
return false;
|
8447
|
+
}
|
8433
8448
|
moveChildTo(child, target) {
|
8434
8449
|
const currentParent = child.parent;
|
8435
8450
|
let rootChildren = this.state.children;
|
@@ -10920,174 +10935,6 @@ const PanelBuilders = {
|
|
10920
10935
|
}
|
10921
10936
|
};
|
10922
10937
|
|
10923
|
-
class VizConfigBuilder {
|
10924
|
-
constructor(pluginId, pluginVersion, defaultOptions, defaultFieldConfig) {
|
10925
|
-
this._pluginId = pluginId;
|
10926
|
-
this._pluginVersion = pluginVersion;
|
10927
|
-
this._fieldConfigBuilder = new FieldConfigBuilder(defaultFieldConfig);
|
10928
|
-
this._panelOptionsBuilder = new PanelOptionsBuilder(defaultOptions);
|
10929
|
-
}
|
10930
|
-
setColor(color) {
|
10931
|
-
this._fieldConfigBuilder.setColor(color);
|
10932
|
-
return this;
|
10933
|
-
}
|
10934
|
-
setDecimals(decimals) {
|
10935
|
-
this._fieldConfigBuilder.setDecimals(decimals);
|
10936
|
-
return this;
|
10937
|
-
}
|
10938
|
-
setDisplayName(displayName) {
|
10939
|
-
this._fieldConfigBuilder.setDisplayName(displayName);
|
10940
|
-
return this;
|
10941
|
-
}
|
10942
|
-
setFilterable(filterable) {
|
10943
|
-
this._fieldConfigBuilder.setFilterable(filterable);
|
10944
|
-
return this;
|
10945
|
-
}
|
10946
|
-
setLinks(links) {
|
10947
|
-
this._fieldConfigBuilder.setLinks(links);
|
10948
|
-
return this;
|
10949
|
-
}
|
10950
|
-
setMappings(mappings) {
|
10951
|
-
this._fieldConfigBuilder.setMappings(mappings);
|
10952
|
-
return this;
|
10953
|
-
}
|
10954
|
-
setMax(max) {
|
10955
|
-
this._fieldConfigBuilder.setMax(max);
|
10956
|
-
return this;
|
10957
|
-
}
|
10958
|
-
setMin(min) {
|
10959
|
-
this._fieldConfigBuilder.setMin(min);
|
10960
|
-
return this;
|
10961
|
-
}
|
10962
|
-
setNoValue(noValue) {
|
10963
|
-
this._fieldConfigBuilder.setNoValue(noValue);
|
10964
|
-
return this;
|
10965
|
-
}
|
10966
|
-
setThresholds(thresholds) {
|
10967
|
-
this._fieldConfigBuilder.setThresholds(thresholds);
|
10968
|
-
return this;
|
10969
|
-
}
|
10970
|
-
setUnit(unit) {
|
10971
|
-
this._fieldConfigBuilder.setUnit(unit);
|
10972
|
-
return this;
|
10973
|
-
}
|
10974
|
-
setCustomFieldConfig(id, value) {
|
10975
|
-
this._fieldConfigBuilder.setCustomFieldConfig(id, value);
|
10976
|
-
return this;
|
10977
|
-
}
|
10978
|
-
setOverrides(builder) {
|
10979
|
-
this._fieldConfigBuilder.setOverrides(builder);
|
10980
|
-
return this;
|
10981
|
-
}
|
10982
|
-
setOption(id, value) {
|
10983
|
-
this._panelOptionsBuilder.setOption(id, value);
|
10984
|
-
return this;
|
10985
|
-
}
|
10986
|
-
build() {
|
10987
|
-
return {
|
10988
|
-
pluginId: this._pluginId,
|
10989
|
-
pluginVersion: this._pluginVersion,
|
10990
|
-
options: this._panelOptionsBuilder.build(),
|
10991
|
-
fieldConfig: this._fieldConfigBuilder.build()
|
10992
|
-
};
|
10993
|
-
}
|
10994
|
-
}
|
10995
|
-
|
10996
|
-
const VizConfigBuilders = {
|
10997
|
-
barchart() {
|
10998
|
-
return new VizConfigBuilder(
|
10999
|
-
"barchart",
|
11000
|
-
"10.0.0",
|
11001
|
-
() => BarChartPanelCfg_types_gen.defaultOptions,
|
11002
|
-
() => BarChartPanelCfg_types_gen.defaultFieldConfig
|
11003
|
-
);
|
11004
|
-
},
|
11005
|
-
bargauge() {
|
11006
|
-
return new VizConfigBuilder("bargauge", "10.0.0", () => BarGaugePanelCfg_types_gen.defaultOptions);
|
11007
|
-
},
|
11008
|
-
datagrid() {
|
11009
|
-
return new VizConfigBuilder("datagrid", "10.0.0", () => DatagridPanelCfg_types_gen.defaultOptions);
|
11010
|
-
},
|
11011
|
-
flamegraph() {
|
11012
|
-
return new VizConfigBuilder("flamegraph", "10.0.0");
|
11013
|
-
},
|
11014
|
-
gauge() {
|
11015
|
-
return new VizConfigBuilder("gauge", "10.0.0", () => GaugePanelCfg_types_gen.defaultOptions);
|
11016
|
-
},
|
11017
|
-
geomap() {
|
11018
|
-
return new VizConfigBuilder("geomap", "10.0.0", () => GeomapPanelCfg_types_gen.defaultOptions);
|
11019
|
-
},
|
11020
|
-
heatmap() {
|
11021
|
-
return new VizConfigBuilder("heatmap", "10.0.0", () => HeatmapPanelCfg_types_gen.defaultOptions);
|
11022
|
-
},
|
11023
|
-
histogram() {
|
11024
|
-
return new VizConfigBuilder(
|
11025
|
-
"histogram",
|
11026
|
-
"10.0.0",
|
11027
|
-
() => HistogramPanelCfg_types_gen.defaultOptions,
|
11028
|
-
() => HistogramPanelCfg_types_gen.defaultFieldConfig
|
11029
|
-
);
|
11030
|
-
},
|
11031
|
-
logs() {
|
11032
|
-
return new VizConfigBuilder("logs", "10.0.0");
|
11033
|
-
},
|
11034
|
-
news() {
|
11035
|
-
return new VizConfigBuilder("news", "10.0.0", () => NewsPanelCfg_types_gen.defaultOptions);
|
11036
|
-
},
|
11037
|
-
nodegraph() {
|
11038
|
-
return new VizConfigBuilder("nodeGraph", "10.0.0");
|
11039
|
-
},
|
11040
|
-
piechart() {
|
11041
|
-
return new VizConfigBuilder(
|
11042
|
-
"piechart",
|
11043
|
-
"10.0.0",
|
11044
|
-
() => PieChartPanelCfg_types_gen.defaultOptions
|
11045
|
-
);
|
11046
|
-
},
|
11047
|
-
stat() {
|
11048
|
-
return new VizConfigBuilder("stat", "10.0.0", () => StatPanelCfg_types_gen.defaultOptions);
|
11049
|
-
},
|
11050
|
-
statetimeline() {
|
11051
|
-
return new VizConfigBuilder(
|
11052
|
-
"state-timeline",
|
11053
|
-
"10.0.0",
|
11054
|
-
() => StateTimelinePanelCfg_types_gen.defaultOptions,
|
11055
|
-
() => StateTimelinePanelCfg_types_gen.defaultFieldConfig
|
11056
|
-
);
|
11057
|
-
},
|
11058
|
-
statushistory() {
|
11059
|
-
return new VizConfigBuilder(
|
11060
|
-
"status-history",
|
11061
|
-
"10.0.0",
|
11062
|
-
() => StatusHistoryPanelCfg_types_gen.defaultOptions,
|
11063
|
-
() => StatusHistoryPanelCfg_types_gen.defaultFieldConfig
|
11064
|
-
);
|
11065
|
-
},
|
11066
|
-
table() {
|
11067
|
-
return new VizConfigBuilder("table", "10.0.0", () => TablePanelCfg_types_gen.defaultOptions);
|
11068
|
-
},
|
11069
|
-
text() {
|
11070
|
-
return new VizConfigBuilder("text", "10.0.0", () => TextPanelCfg_types_gen.defaultOptions);
|
11071
|
-
},
|
11072
|
-
timeseries() {
|
11073
|
-
return new VizConfigBuilder("timeseries", "10.0.0");
|
11074
|
-
},
|
11075
|
-
trend() {
|
11076
|
-
return new VizConfigBuilder("trend", "10.0.0");
|
11077
|
-
},
|
11078
|
-
traces() {
|
11079
|
-
return new VizConfigBuilder("traces", "10.0.0");
|
11080
|
-
},
|
11081
|
-
xychart() {
|
11082
|
-
return new VizConfigBuilder(
|
11083
|
-
"xychart",
|
11084
|
-
"10.0.0",
|
11085
|
-
() => XYChartPanelCfg_types_gen.defaultOptions,
|
11086
|
-
() => XYChartPanelCfg_types_gen.defaultFieldConfig
|
11087
|
-
);
|
11088
|
-
}
|
11089
|
-
};
|
11090
|
-
|
11091
10938
|
const sceneUtils = {
|
11092
10939
|
getUrlWithAppState,
|
11093
10940
|
registerRuntimePanelPlugin,
|
@@ -11112,7 +10959,6 @@ exports.ConstantVariable = ConstantVariable;
|
|
11112
10959
|
exports.CustomVariable = CustomVariable;
|
11113
10960
|
exports.DataSourceVariable = DataSourceVariable;
|
11114
10961
|
exports.EmbeddedScene = EmbeddedScene;
|
11115
|
-
exports.FieldConfigBuilder = FieldConfigBuilder;
|
11116
10962
|
exports.FieldConfigBuilders = FieldConfigBuilders;
|
11117
10963
|
exports.FieldConfigOverridesBuilder = FieldConfigOverridesBuilder;
|
11118
10964
|
exports.GroupByVariable = GroupByVariable;
|
@@ -11167,10 +11013,7 @@ exports.UrlSyncManager = UrlSyncManager;
|
|
11167
11013
|
exports.UserActionEvent = UserActionEvent;
|
11168
11014
|
exports.VariableDependencyConfig = VariableDependencyConfig;
|
11169
11015
|
exports.VariableValueControl = VariableValueControl;
|
11170
|
-
exports.VariableValueSelectWrapper = VariableValueSelectWrapper;
|
11171
11016
|
exports.VariableValueSelectors = VariableValueSelectors;
|
11172
|
-
exports.VizConfigBuilder = VizConfigBuilder;
|
11173
|
-
exports.VizConfigBuilders = VizConfigBuilders;
|
11174
11017
|
exports.VizPanel = VizPanel;
|
11175
11018
|
exports.VizPanelBuilder = VizPanelBuilder;
|
11176
11019
|
exports.VizPanelMenu = VizPanelMenu;
|