Chore: Remove FolderId from DashboardMeta (#78501)

* Chore: Remove FolderId from DashboardMeta

* chore: replace FolderId with FolderUid

* chore: fix test by adding FolderUID
This commit is contained in:
Kat Yang 2023-12-07 09:59:51 -05:00 committed by GitHub
parent 7181811f96
commit 2d66d0de61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View File

@ -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)

View File

@ -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{