From 2d66d0de6126b459c51184540f53fe46b486850b Mon Sep 17 00:00:00 2001 From: Kat Yang <69819079+yangkb09@users.noreply.github.com> Date: Thu, 7 Dec 2023 09:59:51 -0500 Subject: [PATCH] Chore: Remove FolderId from DashboardMeta (#78501) * Chore: Remove FolderId from DashboardMeta * chore: replace FolderId with FolderUid * chore: fix test by adding FolderUID --- pkg/services/publicdashboards/service/service.go | 1 + pkg/services/publicdashboards/service/service_test.go | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pkg/services/publicdashboards/service/service.go b/pkg/services/publicdashboards/service/service.go index 20dcc753286..8ac9a8b24d8 100644 --- a/pkg/services/publicdashboards/service/service.go +++ b/pkg/services/publicdashboards/service/service.go @@ -87,6 +87,7 @@ func (pd *PublicDashboardServiceImpl) GetPublicDashboardForView(ctx context.Cont Version: dash.Version, IsFolder: false, FolderId: dash.FolderID, // nolint:staticcheck + FolderUid: dash.FolderUID, 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 df432eb6c2d..fdd5f10d105 100644 --- a/pkg/services/publicdashboards/service/service_test.go +++ b/pkg/services/publicdashboards/service/service_test.go @@ -312,8 +312,7 @@ func TestGetPublicDashboardForView(t *testing.T) { // #nosec G101 -- This is dummy/test token accessToken := "c54b1c4dd2b143a1a7a43005264d256d" - // nolint:staticcheck - d := &dashboards.Dashboard{UID: "mydashboard", Data: data, Slug: "dashboardSlug", Created: now, Updated: now, Version: 1, FolderID: 1} + d := &dashboards.Dashboard{UID: "mydashboard", OrgID: 0, Data: data, Slug: "dashboardSlug", Created: now, Updated: now, Version: 1, FolderUID: "myFolder"} testCases := []struct { Name string @@ -345,7 +344,7 @@ func TestGetPublicDashboardForView(t *testing.T) { Updated: d.Updated, Version: d.Version, IsFolder: false, - FolderId: d.FolderID, // nolint:staticcheck + FolderUid: d.FolderUID, PublicDashboardEnabled: true, }, }, @@ -373,7 +372,7 @@ func TestGetPublicDashboardForView(t *testing.T) { Updated: d.Updated, Version: d.Version, IsFolder: false, - FolderId: d.FolderID, // nolint:staticcheck + FolderUid: d.FolderUID, PublicDashboardEnabled: true, }, }, @@ -414,8 +413,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.FolderUid, dashboardFullWithMeta.Meta.FolderUid) assert.Equal(t, test.DashResp.Meta.PublicDashboardEnabled, dashboardFullWithMeta.Meta.PublicDashboardEnabled) // hide the timepicker if the time selection is disabled @@ -1895,7 +1893,6 @@ func insertTestDashboard(t *testing.T, dashboardStore dashboards.Store, title st cmd := dashboards.SaveDashboardCommand{ OrgID: orgId, - FolderID: folderId, // nolint:staticcheck FolderUID: folderUID, IsFolder: isFolder, Dashboard: simplejson.NewFromAny(map[string]any{