Skip to content

Commit ca3cc1a

Browse files
authored
clean: conditional valueMaps in overrides in signals lib
1 parent 767befa commit ca3cc1a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

common-lib/common/signal/base.libsonnet

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,19 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet';
119119
g.panel.timeSeries.fieldOverride.byQuery.new(name)
120120
+ g.panel.timeSeries.fieldOverride.byQuery.withPropertiesFromOptions(
121121
g.panel.timeSeries.standardOptions.withUnit(self.unit)
122-
+ g.panel.timeSeries.standardOptions.withMappings(this.getValueMappings(sourceMaps))
122+
+
123+
(if std.length(this.getValueMappings(sourceMaps)) > 0 then
124+
g.panel.timeSeries.standardOptions.withMappings(this.getValueMappings(sourceMaps))
125+
else {})
123126
)
124127
else if override == 'byName' then
125128
g.panel.timeSeries.fieldOverride.byName.new(name)
126129
+ g.panel.timeSeries.fieldOverride.byName.withPropertiesFromOptions(
127130
g.panel.timeSeries.standardOptions.withUnit(self.unit)
128-
+ g.panel.timeSeries.standardOptions.withMappings(this.getValueMappings(sourceMaps))
131+
+
132+
(if std.length(this.getValueMappings(sourceMaps)) > 0 then
133+
g.panel.timeSeries.standardOptions.withMappings(this.getValueMappings(sourceMaps))
134+
else {})
129135
)
130136
else error 'Unknown override type, only "byName", "byQuery" are supported.',
131137
],

0 commit comments

Comments
 (0)