diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f706dba6b..3169a18c10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ 1. [#2953](https://github.com/influxdata/chronograf/pull/2953): Fix error reporting in DataExplorer 1. [#2947](https://github.com/influxdata/chronograf/pull/2947): Fix Okta oauth2 provider support 1. [#2866](https://github.com/influxdata/chronograf/pull/2866): Change hover text on delete mappings confirmation button to 'Delete' +1. [#2919](https://github.com/influxdata/chronograf/pull/2919): Automatically add graph type 'line' to any graph missing a type ## v1.4.2.3 [2018-03-08] diff --git a/bolt/internal/internal.go b/bolt/internal/internal.go index 729bb8627e..c51fe1d191 100644 --- a/bolt/internal/internal.go +++ b/bolt/internal/internal.go @@ -404,6 +404,13 @@ func UnmarshalDashboard(data []byte, d *chronograf.Dashboard) error { legend.Orientation = c.Legend.Orientation } + // FIXME: this is merely for legacy cells and + // should be removed as soon as possible + cellType := c.Type + if cellType == "" { + cellType = "line" + } + cells[i] = chronograf.DashboardCell{ ID: c.ID, X: c.X, @@ -412,7 +419,7 @@ func UnmarshalDashboard(data []byte, d *chronograf.Dashboard) error { H: c.H, Name: c.Name, Queries: queries, - Type: c.Type, + Type: cellType, Axes: axes, CellColors: colors, Legend: legend, diff --git a/bolt/internal/internal_test.go b/bolt/internal/internal_test.go index 47c7067b46..b7ca2c0f37 100644 --- a/bolt/internal/internal_test.go +++ b/bolt/internal/internal_test.go @@ -434,3 +434,37 @@ func Test_MarshalDashboard_WithEmptyLegacyBounds(t *testing.T) { t.Fatalf("Dashboard protobuf copy error: diff follows:\n%s", cmp.Diff(expected, actual)) } } + +func Test_MarshalDashboard_WithEmptyCellType(t *testing.T) { + dashboard := chronograf.Dashboard{ + ID: 1, + Cells: []chronograf.DashboardCell{ + { + ID: "9b5367de-c552-4322-a9e8-7f384cbd235c", + }, + }, + } + + expected := chronograf.Dashboard{ + ID: 1, + Cells: []chronograf.DashboardCell{ + { + ID: "9b5367de-c552-4322-a9e8-7f384cbd235c", + Type: "line", + Queries: []chronograf.DashboardQuery{}, + Axes: map[string]chronograf.Axis{}, + CellColors: []chronograf.CellColor{}, + }, + }, + Templates: []chronograf.Template{}, + } + + var actual chronograf.Dashboard + if buf, err := internal.MarshalDashboard(dashboard); err != nil { + t.Fatal("Error marshaling dashboard: err", err) + } else if err := internal.UnmarshalDashboard(buf, &actual); err != nil { + t.Fatal("Error unmarshaling dashboard: err:", err) + } else if !cmp.Equal(expected, actual) { + t.Fatalf("Dashboard protobuf copy error: diff follows:\n%s", cmp.Diff(expected, actual)) + } +}