From 354c385ee775af30b1b0b817d8e21e72fa8730bb Mon Sep 17 00:00:00 2001 From: Timmy Luong Date: Thu, 10 Jun 2021 09:20:59 -0700 Subject: [PATCH] fix: change static legend's hide property to show (#21648) --- CHANGELOG.md | 1 + dashboard.go | 2 +- pkger/clone_resource.go | 4 ++-- pkger/parser.go | 2 +- pkger/parser_models.go | 6 +++--- pkger/parser_test.go | 6 +++--- pkger/service_test.go | 6 +++--- pkger/testdata/dashboard_band.yml | 2 +- pkger/testdata/dashboard_single_stat_plus_line.json | 2 +- pkger/testdata/dashboard_single_stat_plus_line.yml | 2 +- pkger/testdata/dashboard_xy.json | 2 +- pkger/testdata/dashboard_xy.yml | 2 +- 12 files changed, 19 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91e014561e..07a4d1ce66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ This release adds an embedded SQLite database for storing metadata required by t ### Bug Fixes 1. [21610](https://github.com/influxdata/influxdb/pull/21610): Avoid rewriting `fields.idx` unnecessarily. +1. [21648](https://github.com/influxdata/influxdb/pull/21648): Change static legend's `hide` to `show` to let users decide if they want it. ## v2.0.7 [2021-06-04] diff --git a/dashboard.go b/dashboard.go index 550f9634ee..77dd4fd5e4 100644 --- a/dashboard.go +++ b/dashboard.go @@ -1186,7 +1186,7 @@ type ViewColor struct { type StaticLegend struct { ColorizeRows bool `json:"colorizeRows,omitempty"` HeightRatio float64 `json:"heightRatio,omitempty"` - Hide bool `json:"hide,omitempty"` + Show bool `json:"show,omitempty"` Opacity float64 `json:"opacity,omitempty"` OrientationThreshold int `json:"orientationThreshold,omitempty"` ValueAxis string `json:"valueAxis,omitempty"` diff --git a/pkger/clone_resource.go b/pkger/clone_resource.go index 59fd93f641..e84a9b0d4f 100644 --- a/pkger/clone_resource.go +++ b/pkger/clone_resource.go @@ -742,7 +742,7 @@ func convertCellView(cell influxdb.Cell) chart { setStaticLegend := func(sl influxdb.StaticLegend) { ch.StaticLegend.ColorizeRows = sl.ColorizeRows ch.StaticLegend.HeightRatio = sl.HeightRatio - ch.StaticLegend.Hide = sl.Hide + ch.StaticLegend.Show = sl.Show ch.StaticLegend.Opacity = sl.Opacity ch.StaticLegend.OrientationThreshold = sl.OrientationThreshold ch.StaticLegend.ValueAxis = sl.ValueAxis @@ -1090,7 +1090,7 @@ func convertChartToResource(ch chart) Resource { fieldChartLegendColorizeRows: ch.LegendColorizeRows, fieldChartLegendHide: ch.LegendHide, fieldChartStaticLegendColorizeRows: ch.StaticLegend.ColorizeRows, - fieldChartStaticLegendHide: ch.StaticLegend.Hide, + fieldChartStaticLegendShow: ch.StaticLegend.Show, fieldChartGeoAllowPanAndZoom: ch.AllowPanAndZoom, fieldChartGeoDetectCoordinateFields: ch.DetectCoordinateFields, }) diff --git a/pkger/parser.go b/pkger/parser.go index f34dc3d7ef..4359fb88d7 100644 --- a/pkger/parser.go +++ b/pkger/parser.go @@ -1536,7 +1536,7 @@ func (p *Template) parseChart(dashMetaName string, chartIdx int, r Resource) (*c if staticLeg, ok := ifaceToResource(r[fieldChartStaticLegend]); ok { c.StaticLegend.ColorizeRows = staticLeg.boolShort(fieldChartStaticLegendColorizeRows) c.StaticLegend.HeightRatio = staticLeg.float64Short(fieldChartStaticLegendHeightRatio) - c.StaticLegend.Hide = staticLeg.boolShort(fieldChartStaticLegendHide) + c.StaticLegend.Show = staticLeg.boolShort(fieldChartStaticLegendShow) c.StaticLegend.Opacity = staticLeg.float64Short(fieldChartStaticLegendOpacity) c.StaticLegend.OrientationThreshold = staticLeg.intShort(fieldChartStaticLegendOrientationThreshold) c.StaticLegend.ValueAxis = staticLeg.stringShort(fieldChartStaticLegendValueAxis) diff --git a/pkger/parser_models.go b/pkger/parser_models.go index e37b195b4d..292ada656d 100644 --- a/pkger/parser_models.go +++ b/pkger/parser_models.go @@ -1400,7 +1400,7 @@ func (a axes) hasAxes(expectedAxes ...string) []validationErr { type StaticLegend struct { ColorizeRows bool `json:"colorizeRows,omitempty" yaml:"colorizeRows,omitempty"` HeightRatio float64 `json:"heightRatio,omitempty" yaml:"heightRatio,omitempty"` - Hide bool `json:"hide,omitempty" yaml:"hide,omitempty"` + Show bool `json:"show,omitempty" yaml:"show,omitempty"` Opacity float64 `json:"opacity,omitempty" yaml:"opacity,omitempty"` OrientationThreshold int `json:"orientationThreshold,omitempty" yaml:"orientationThreshold,omitempty"` ValueAxis string `json:"valueAxis,omitempty" yaml:"valueAxis,omitempty"` @@ -1410,7 +1410,7 @@ type StaticLegend struct { const ( fieldChartStaticLegendColorizeRows = "colorizeRows" fieldChartStaticLegendHeightRatio = "heightRatio" - fieldChartStaticLegendHide = "hide" + fieldChartStaticLegendShow = "show" fieldChartStaticLegendOpacity = "opacity" fieldChartStaticLegendOrientationThreshold = "orientationThreshold" fieldChartStaticLegendValueAxis = "valueAxis" @@ -1421,7 +1421,7 @@ func (sl StaticLegend) influxStaticLegend() influxdb.StaticLegend { return influxdb.StaticLegend{ ColorizeRows: sl.ColorizeRows, HeightRatio: sl.HeightRatio, - Hide: sl.Hide, + Show: sl.Show, Opacity: sl.Opacity, OrientationThreshold: sl.OrientationThreshold, ValueAxis: sl.ValueAxis, diff --git a/pkger/parser_test.go b/pkger/parser_test.go index f5963a2913..5782806aa5 100644 --- a/pkger/parser_test.go +++ b/pkger/parser_test.go @@ -1455,7 +1455,7 @@ spec: assert.Equal(t, 5, props.LegendOrientationThreshold) assert.Equal(t, true, props.StaticLegend.ColorizeRows) assert.Equal(t, 0.2, props.StaticLegend.HeightRatio) - assert.Equal(t, false, props.StaticLegend.Hide) + assert.Equal(t, true, props.StaticLegend.Show) assert.Equal(t, 1.0, props.StaticLegend.Opacity) assert.Equal(t, 5, props.StaticLegend.OrientationThreshold) assert.Equal(t, "y", props.StaticLegend.ValueAxis) @@ -1985,7 +1985,7 @@ spec: assert.Equal(t, 5, props.LegendOrientationThreshold) assert.Equal(t, true, props.StaticLegend.ColorizeRows) assert.Equal(t, 0.2, props.StaticLegend.HeightRatio) - assert.Equal(t, false, props.StaticLegend.Hide) + assert.Equal(t, true, props.StaticLegend.Show) assert.Equal(t, 1.0, props.StaticLegend.Opacity) assert.Equal(t, 5, props.StaticLegend.OrientationThreshold) assert.Equal(t, "y", props.StaticLegend.ValueAxis) @@ -2460,7 +2460,7 @@ spec: assert.Equal(t, 5, props.LegendOrientationThreshold) assert.Equal(t, true, props.StaticLegend.ColorizeRows) assert.Equal(t, 0.2, props.StaticLegend.HeightRatio) - assert.Equal(t, false, props.StaticLegend.Hide) + assert.Equal(t, true, props.StaticLegend.Show) assert.Equal(t, 1.0, props.StaticLegend.Opacity) assert.Equal(t, 5, props.StaticLegend.OrientationThreshold) assert.Equal(t, "y", props.StaticLegend.ValueAxis) diff --git a/pkger/service_test.go b/pkger/service_test.go index dccb698484..76876b309a 100644 --- a/pkger/service_test.go +++ b/pkger/service_test.go @@ -2577,7 +2577,7 @@ func TestService(t *testing.T) { Type: influxdb.ViewPropertyTypeSingleStatPlusLine, Axes: newAxes(), DecimalPlaces: influxdb.DecimalPlaces{IsEnforced: true, Digits: 1}, - StaticLegend: influxdb.StaticLegend{ColorizeRows: true, HeightRatio: 0.2, Hide: false, Opacity: 1.0, OrientationThreshold: 5, ValueAxis: "y", WidthRatio: 1.0}, + StaticLegend: influxdb.StaticLegend{ColorizeRows: true, HeightRatio: 0.2, Show: true, Opacity: 1.0, OrientationThreshold: 5, ValueAxis: "y", WidthRatio: 1.0}, Note: "a note", Prefix: "pre", Suffix: "suf", @@ -2615,7 +2615,7 @@ func TestService(t *testing.T) { Type: influxdb.ViewPropertyTypeXY, Axes: newAxes(), Geom: "step", - StaticLegend: influxdb.StaticLegend{ColorizeRows: true, HeightRatio: 0.2, Hide: false, Opacity: 1.0, OrientationThreshold: 5, ValueAxis: "y", WidthRatio: 1.0}, + StaticLegend: influxdb.StaticLegend{ColorizeRows: true, HeightRatio: 0.2, Show: true, Opacity: 1.0, OrientationThreshold: 5, ValueAxis: "y", WidthRatio: 1.0}, Note: "a note", Queries: []influxdb.DashboardQuery{newQuery()}, ShadeBelow: true, @@ -2652,7 +2652,7 @@ func TestService(t *testing.T) { Type: influxdb.ViewPropertyTypeBand, Axes: newAxes(), Geom: "step", - StaticLegend: influxdb.StaticLegend{ColorizeRows: true, HeightRatio: 0.2, Hide: false, Opacity: 1.0, OrientationThreshold: 5, ValueAxis: "y", WidthRatio: 1.0}, + StaticLegend: influxdb.StaticLegend{ColorizeRows: true, HeightRatio: 0.2, Show: true, Opacity: 1.0, OrientationThreshold: 5, ValueAxis: "y", WidthRatio: 1.0}, Note: "a note", Queries: []influxdb.DashboardQuery{newQuery()}, HoverDimension: "y", diff --git a/pkger/testdata/dashboard_band.yml b/pkger/testdata/dashboard_band.yml index 5d0792ec62..fe13758ed2 100644 --- a/pkger/testdata/dashboard_band.yml +++ b/pkger/testdata/dashboard_band.yml @@ -43,7 +43,7 @@ spec: staticLegend: colorizeRows: true heightRatio: 0.2 - hide: false + show: true opacity: 1.0 orientationThreshold: 5 valueAxis: "y" diff --git a/pkger/testdata/dashboard_single_stat_plus_line.json b/pkger/testdata/dashboard_single_stat_plus_line.json index 1f7acc9bcf..113d68a034 100644 --- a/pkger/testdata/dashboard_single_stat_plus_line.json +++ b/pkger/testdata/dashboard_single_stat_plus_line.json @@ -40,7 +40,7 @@ "staticLegend": { "colorizeRows": true, "heightRatio": 0.2, - "hide": false, + "show": true, "opacity": 1.0, "orientationThreshold": 5, "valueAxis": "y", diff --git a/pkger/testdata/dashboard_single_stat_plus_line.yml b/pkger/testdata/dashboard_single_stat_plus_line.yml index 20ea04e79c..1f8edb6ee8 100644 --- a/pkger/testdata/dashboard_single_stat_plus_line.yml +++ b/pkger/testdata/dashboard_single_stat_plus_line.yml @@ -40,7 +40,7 @@ spec: staticLegend: colorizeRows: true heightRatio: 0.2 - hide: false + show: true opacity: 1.0 orientationThreshold: 5 valueAxis: "y" diff --git a/pkger/testdata/dashboard_xy.json b/pkger/testdata/dashboard_xy.json index f4fa74497a..80c84d723c 100644 --- a/pkger/testdata/dashboard_xy.json +++ b/pkger/testdata/dashboard_xy.json @@ -39,7 +39,7 @@ "staticLegend": { "colorizeRows": true, "heightRatio": 0.2, - "hide": false, + "show": true, "opacity": 1.0, "orientationThreshold": 5, "valueAxis": "y", diff --git a/pkger/testdata/dashboard_xy.yml b/pkger/testdata/dashboard_xy.yml index a1acc66f40..0cb05845cb 100644 --- a/pkger/testdata/dashboard_xy.yml +++ b/pkger/testdata/dashboard_xy.yml @@ -38,7 +38,7 @@ spec: staticLegend: colorizeRows: true heightRatio: 0.2 - hide: false + show: true opacity: 1.0 orientationThreshold: 5 valueAxis: "y"