From 5f2fecfda7f658acdef0a8b084032b325c7d36b8 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Wed, 8 Mar 2023 08:26:38 -0800 Subject: [PATCH] Dashboards: Avoid adding unused revision property (#64362) --- devenv/dev-dashboards-without-uid/panel_tests_graph.json | 1 - devenv/dev-dashboards/panel-graph/graph_tests.json | 1 - devenv/dev-dashboards/panel-heatmap/heatmap-x.json | 1 - devenv/dev-dashboards/panel-histogram/histogram_tests.json | 1 - devenv/dev-dashboards/panel-table/table_tests.json | 1 - .../panel-timeline/timeline-thresholds-mappings.json | 1 - .../panel-timeseries/timeseries-yaxis-ticks.json | 1 - pkg/services/dashboardimport/dashboardimport.go | 4 ++-- pkg/services/dashboardimport/service/service.go | 5 +++-- public/app/features/dashboard/state/DashboardModel.ts | 4 ++-- .../dashboard/state/__fixtures__/dashboardFixtures.ts | 1 - 11 files changed, 7 insertions(+), 14 deletions(-) diff --git a/devenv/dev-dashboards-without-uid/panel_tests_graph.json b/devenv/dev-dashboards-without-uid/panel_tests_graph.json index 6612f9b80f3..2ddb8683484 100644 --- a/devenv/dev-dashboards-without-uid/panel_tests_graph.json +++ b/devenv/dev-dashboards-without-uid/panel_tests_graph.json @@ -1629,7 +1629,6 @@ } ], "refresh": false, - "revision": 8, "schemaVersion": 16, "style": "dark", "tags": ["gdev", "panel-tests"], diff --git a/devenv/dev-dashboards/panel-graph/graph_tests.json b/devenv/dev-dashboards/panel-graph/graph_tests.json index e0e31323052..68475600f11 100644 --- a/devenv/dev-dashboards/panel-graph/graph_tests.json +++ b/devenv/dev-dashboards/panel-graph/graph_tests.json @@ -1629,7 +1629,6 @@ } ], "refresh": false, - "revision": 8, "schemaVersion": 16, "style": "dark", "tags": ["gdev", "panel-tests", "graph"], diff --git a/devenv/dev-dashboards/panel-heatmap/heatmap-x.json b/devenv/dev-dashboards/panel-heatmap/heatmap-x.json index 7c9260f0017..95c413f0fa3 100644 --- a/devenv/dev-dashboards/panel-heatmap/heatmap-x.json +++ b/devenv/dev-dashboards/panel-heatmap/heatmap-x.json @@ -305,7 +305,6 @@ "type": "heatmap" } ], - "revision": 1, "schemaVersion": 37, "style": "dark", "tags": [], diff --git a/devenv/dev-dashboards/panel-histogram/histogram_tests.json b/devenv/dev-dashboards/panel-histogram/histogram_tests.json index 1bb343f7088..cb50285c29e 100644 --- a/devenv/dev-dashboards/panel-histogram/histogram_tests.json +++ b/devenv/dev-dashboards/panel-histogram/histogram_tests.json @@ -748,7 +748,6 @@ "type": "histogram" } ], - "revision": 1, "schemaVersion": 37, "style": "dark", "tags": [ diff --git a/devenv/dev-dashboards/panel-table/table_tests.json b/devenv/dev-dashboards/panel-table/table_tests.json index c301dd23b6a..8aee9afeda7 100644 --- a/devenv/dev-dashboards/panel-table/table_tests.json +++ b/devenv/dev-dashboards/panel-table/table_tests.json @@ -430,7 +430,6 @@ } ], "refresh": false, - "revision": 8, "schemaVersion": 16, "style": "dark", "tags": ["gdev", "panel-tests"], diff --git a/devenv/dev-dashboards/panel-timeline/timeline-thresholds-mappings.json b/devenv/dev-dashboards/panel-timeline/timeline-thresholds-mappings.json index be7a3567bfa..9d15ac1d64c 100644 --- a/devenv/dev-dashboards/panel-timeline/timeline-thresholds-mappings.json +++ b/devenv/dev-dashboards/panel-timeline/timeline-thresholds-mappings.json @@ -736,7 +736,6 @@ } ], "refresh": false, - "revision": 1, "schemaVersion": 38, "style": "dark", "tags": [ diff --git a/devenv/dev-dashboards/panel-timeseries/timeseries-yaxis-ticks.json b/devenv/dev-dashboards/panel-timeseries/timeseries-yaxis-ticks.json index 7650a8aab56..6de22c2b6ed 100644 --- a/devenv/dev-dashboards/panel-timeseries/timeseries-yaxis-ticks.json +++ b/devenv/dev-dashboards/panel-timeseries/timeseries-yaxis-ticks.json @@ -1343,7 +1343,6 @@ } ], "refresh": "", - "revision": 1, "schemaVersion": 38, "style": "dark", "tags": [ diff --git a/pkg/services/dashboardimport/dashboardimport.go b/pkg/services/dashboardimport/dashboardimport.go index e3fccb093ef..cafa322845d 100644 --- a/pkg/services/dashboardimport/dashboardimport.go +++ b/pkg/services/dashboardimport/dashboardimport.go @@ -40,8 +40,8 @@ type ImportDashboardResponse struct { DashboardId int64 `json:"dashboardId"` FolderId int64 `json:"folderId"` FolderUID string `json:"folderUid"` - ImportedRevision int64 `json:"importedRevision"` - Revision int64 `json:"revision"` + ImportedRevision int64 `json:"importedRevision,omitempty"` // Only used for plugin imports + Revision int64 `json:"revision,omitempty"` // Only used for plugin imports Description string `json:"description"` Path string `json:"path"` Removed bool `json:"removed"` diff --git a/pkg/services/dashboardimport/service/service.go b/pkg/services/dashboardimport/service/service.go index bad30433a76..3851dca86a9 100644 --- a/pkg/services/dashboardimport/service/service.go +++ b/pkg/services/dashboardimport/service/service.go @@ -136,17 +136,18 @@ func (s *ImportDashboardService) ImportDashboard(ctx context.Context, req *dashb return nil, err } + revision := savedDashboard.Data.Get("revision").MustInt64(0) return &dashboardimport.ImportDashboardResponse{ UID: savedDashboard.UID, PluginId: req.PluginId, Title: savedDashboard.Title, Path: req.Path, - Revision: savedDashboard.Data.Get("revision").MustInt64(1), + Revision: revision, // only used for plugin version tracking FolderId: savedDashboard.FolderID, FolderUID: req.FolderUid, ImportedUri: "db/" + savedDashboard.Slug, ImportedUrl: savedDashboard.GetURL(), - ImportedRevision: savedDashboard.Data.Get("revision").MustInt64(1), + ImportedRevision: revision, Imported: true, DashboardId: savedDashboard.ID, Slug: savedDashboard.Slug, diff --git a/public/app/features/dashboard/state/DashboardModel.ts b/public/app/features/dashboard/state/DashboardModel.ts index bcbdf6e7aa0..a88c02a66fe 100644 --- a/public/app/features/dashboard/state/DashboardModel.ts +++ b/public/app/features/dashboard/state/DashboardModel.ts @@ -90,7 +90,7 @@ export class DashboardModel implements TimeModel { snapshot: any; schemaVersion: number; version: number; - revision: number; + revision?: number; // Only used for dashboards managed by plugins links: DashboardLink[]; gnetId: any; panels: PanelModel[]; @@ -131,7 +131,7 @@ export class DashboardModel implements TimeModel { this.id = data.id || null; // UID is not there for newly created dashboards this.uid = data.uid || null; - this.revision = data.revision || 1; + this.revision = data.revision ?? undefined; this.title = data.title ?? 'No Title'; this.description = data.description; this.tags = data.tags ?? []; diff --git a/public/app/features/dashboard/state/__fixtures__/dashboardFixtures.ts b/public/app/features/dashboard/state/__fixtures__/dashboardFixtures.ts index 20cc4af46e1..4741059fa22 100644 --- a/public/app/features/dashboard/state/__fixtures__/dashboardFixtures.ts +++ b/public/app/features/dashboard/state/__fixtures__/dashboardFixtures.ts @@ -22,7 +22,6 @@ export function createDashboardModelFixture( editable: true, graphTooltip: defaultDashboardCursorSync, schemaVersion: 1, - revision: 1, style: 'dark', timezone: '', ...dashboardInput,