From 6ed09de47d2c3b494488ce0f135b35cfdda744ec Mon Sep 17 00:00:00 2001 From: Kat Yang <69819079+yangkb09@users.noreply.github.com> Date: Mon, 6 Nov 2023 11:31:44 -0500 Subject: [PATCH] Chore: Deprecate FolderId in DashboardMeta (#77626) * Chore: Deprecate FolderId in DashboardMeta * chore: regen specs --- pkg/api/dashboard.go | 2 +- pkg/api/dtos/dashboard.go | 37 ++++++++++--------- .../publicdashboards/service/service.go | 2 +- .../publicdashboards/service/service_test.go | 5 ++- public/api-merged.json | 1 + public/openapi3.json | 1 + 6 files changed, 26 insertions(+), 22 deletions(-) diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go index dd70a773dd3..783d8a24b63 100644 --- a/pkg/api/dashboard.go +++ b/pkg/api/dashboard.go @@ -164,7 +164,7 @@ func (hs *HTTPServer) GetDashboard(c *contextmodel.ReqContext) response.Response Version: dash.Version, HasACL: dash.HasACL, IsFolder: dash.IsFolder, - FolderId: dash.FolderID, + FolderId: dash.FolderID, // nolint:staticcheck Url: dash.GetURL(), FolderTitle: "General", AnnotationsPermissions: annotationPermissions, diff --git a/pkg/api/dtos/dashboard.go b/pkg/api/dtos/dashboard.go index ef4d34864dc..a00b08bce5b 100644 --- a/pkg/api/dtos/dashboard.go +++ b/pkg/api/dtos/dashboard.go @@ -7,24 +7,25 @@ import ( ) type DashboardMeta struct { - IsStarred bool `json:"isStarred,omitempty"` - IsSnapshot bool `json:"isSnapshot,omitempty"` - Type string `json:"type,omitempty"` - CanSave bool `json:"canSave"` - CanEdit bool `json:"canEdit"` - CanAdmin bool `json:"canAdmin"` - CanStar bool `json:"canStar"` - CanDelete bool `json:"canDelete"` - Slug string `json:"slug"` - Url string `json:"url"` - Expires time.Time `json:"expires"` - Created time.Time `json:"created"` - Updated time.Time `json:"updated"` - UpdatedBy string `json:"updatedBy"` - CreatedBy string `json:"createdBy"` - Version int `json:"version"` - HasACL bool `json:"hasAcl" xorm:"has_acl"` - IsFolder bool `json:"isFolder"` + IsStarred bool `json:"isStarred,omitempty"` + IsSnapshot bool `json:"isSnapshot,omitempty"` + Type string `json:"type,omitempty"` + CanSave bool `json:"canSave"` + CanEdit bool `json:"canEdit"` + CanAdmin bool `json:"canAdmin"` + CanStar bool `json:"canStar"` + CanDelete bool `json:"canDelete"` + Slug string `json:"slug"` + Url string `json:"url"` + Expires time.Time `json:"expires"` + Created time.Time `json:"created"` + Updated time.Time `json:"updated"` + UpdatedBy string `json:"updatedBy"` + CreatedBy string `json:"createdBy"` + Version int `json:"version"` + HasACL bool `json:"hasAcl" xorm:"has_acl"` + IsFolder bool `json:"isFolder"` + // Deprecated: use FolderUID instead FolderId int64 `json:"folderId"` FolderUid string `json:"folderUid"` FolderTitle string `json:"folderTitle"` diff --git a/pkg/services/publicdashboards/service/service.go b/pkg/services/publicdashboards/service/service.go index b67c9b2a2cc..5b054a1b6a9 100644 --- a/pkg/services/publicdashboards/service/service.go +++ b/pkg/services/publicdashboards/service/service.go @@ -83,7 +83,7 @@ func (pd *PublicDashboardServiceImpl) GetPublicDashboardForView(ctx context.Cont Updated: dash.Updated, Version: dash.Version, IsFolder: false, - FolderId: dash.FolderID, + FolderId: dash.FolderID, // nolint:staticcheck PublicDashboardEnabled: pubdash.IsEnabled, } dash.Data.Get("timepicker").Set("hidden", !pubdash.TimeSelectionEnabled) diff --git a/pkg/services/publicdashboards/service/service_test.go b/pkg/services/publicdashboards/service/service_test.go index 2643d3aca93..1258692ea80 100644 --- a/pkg/services/publicdashboards/service/service_test.go +++ b/pkg/services/publicdashboards/service/service_test.go @@ -344,7 +344,7 @@ func TestGetPublicDashboardForView(t *testing.T) { Updated: d.Updated, Version: d.Version, IsFolder: false, - FolderId: d.FolderID, + FolderId: d.FolderID, // nolint:staticcheck PublicDashboardEnabled: true, }, }, @@ -372,7 +372,7 @@ func TestGetPublicDashboardForView(t *testing.T) { Updated: d.Updated, Version: d.Version, IsFolder: false, - FolderId: d.FolderID, + FolderId: d.FolderID, // nolint:staticcheck PublicDashboardEnabled: true, }, }, @@ -411,6 +411,7 @@ func TestGetPublicDashboardForView(t *testing.T) { assert.Equal(t, test.DashResp.Meta.Updated, dashboardFullWithMeta.Meta.Updated) assert.Equal(t, test.DashResp.Meta.Version, dashboardFullWithMeta.Meta.Version) assert.Equal(t, false, dashboardFullWithMeta.Meta.IsFolder) + // nolint:staticcheck assert.Equal(t, test.DashResp.Meta.FolderId, dashboardFullWithMeta.Meta.FolderId) assert.Equal(t, test.DashResp.Meta.PublicDashboardEnabled, dashboardFullWithMeta.Meta.PublicDashboardEnabled) diff --git a/public/api-merged.json b/public/api-merged.json index 0d285367524..0ae7107941d 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -13530,6 +13530,7 @@ "format": "date-time" }, "folderId": { + "description": "Deprecated: use FolderUID instead", "type": "integer", "format": "int64" }, diff --git a/public/openapi3.json b/public/openapi3.json index 3581fd150c7..003f35f6bb5 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -4443,6 +4443,7 @@ "type": "string" }, "folderId": { + "description": "Deprecated: use FolderUID instead", "format": "int64", "type": "integer" },