mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Search: Fix empty folder details for nested folder items (#76504)
* Introduce dashboard.folder_uid column * Add data migration * Search: Fix empty folder details for nested folders * Set `dashboard.folder_uid` and update tests * Add unique index * lint Ignore cyclomatic complexity of func `(*DashboardServiceImpl).BuildSaveDashboardCommand * Fix search by folder UID
This commit is contained in:
committed by
GitHub
parent
442e533803
commit
03a626f1d6
@@ -37,7 +37,7 @@ func TestIntegrationDashboardFolderStore(t *testing.T) {
|
||||
sqlStore = db.InitTestDB(t)
|
||||
folderStore := ProvideDashboardFolderStore(sqlStore)
|
||||
folder2 = insertTestFolder(t, dashboardStore, "TEST", orgId, 0, "prod")
|
||||
_ = insertTestDashboard(t, dashboardStore, title, orgId, folder2.ID, "prod")
|
||||
_ = insertTestDashboard(t, dashboardStore, title, orgId, folder2.ID, folder2.UID, "prod")
|
||||
folder1 = insertTestFolder(t, dashboardStore, title, orgId, 0, "prod")
|
||||
|
||||
t.Run("GetFolderByTitle should find the folder", func(t *testing.T) {
|
||||
@@ -52,7 +52,7 @@ func TestIntegrationDashboardFolderStore(t *testing.T) {
|
||||
sqlStore := db.InitTestDB(t)
|
||||
folderStore := ProvideDashboardFolderStore(sqlStore)
|
||||
folder := insertTestFolder(t, dashboardStore, "TEST", orgId, 0, "prod")
|
||||
dash := insertTestDashboard(t, dashboardStore, "Very Unique Name", orgId, folder.ID, "prod")
|
||||
dash := insertTestDashboard(t, dashboardStore, "Very Unique Name", orgId, folder.ID, folder.UID, "prod")
|
||||
|
||||
t.Run("should return folder by UID", func(t *testing.T) {
|
||||
d, err := folderStore.GetFolderByUID(context.Background(), orgId, folder.UID)
|
||||
@@ -76,7 +76,7 @@ func TestIntegrationDashboardFolderStore(t *testing.T) {
|
||||
sqlStore := db.InitTestDB(t)
|
||||
folderStore := ProvideDashboardFolderStore(sqlStore)
|
||||
folder := insertTestFolder(t, dashboardStore, "TEST", orgId, 0, "prod")
|
||||
dash := insertTestDashboard(t, dashboardStore, "Very Unique Name", orgId, folder.ID, "prod")
|
||||
dash := insertTestDashboard(t, dashboardStore, "Very Unique Name", orgId, folder.ID, folder.UID, "prod")
|
||||
|
||||
t.Run("should return folder by ID", func(t *testing.T) {
|
||||
d, err := folderStore.GetFolderByID(context.Background(), orgId, folder.ID)
|
||||
@@ -96,12 +96,13 @@ func TestIntegrationDashboardFolderStore(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func insertTestDashboard(t *testing.T, dashboardStore dashboards.Store, title string, orgId int64, folderId int64, tags ...any) *dashboards.Dashboard {
|
||||
func insertTestDashboard(t *testing.T, dashboardStore dashboards.Store, title string, orgId int64, folderID int64, folderUID string, tags ...any) *dashboards.Dashboard {
|
||||
t.Helper()
|
||||
cmd := dashboards.SaveDashboardCommand{
|
||||
OrgID: orgId,
|
||||
FolderID: folderId,
|
||||
IsFolder: false,
|
||||
OrgID: orgId,
|
||||
FolderID: folderID,
|
||||
FolderUID: folderUID,
|
||||
IsFolder: false,
|
||||
Dashboard: simplejson.NewFromAny(map[string]any{
|
||||
"id": nil,
|
||||
"title": title,
|
||||
@@ -116,12 +117,13 @@ func insertTestDashboard(t *testing.T, dashboardStore dashboards.Store, title st
|
||||
return dash
|
||||
}
|
||||
|
||||
func insertTestFolder(t *testing.T, dashboardStore dashboards.Store, title string, orgId int64, folderId int64, tags ...any) *dashboards.Dashboard {
|
||||
func insertTestFolder(t *testing.T, dashboardStore dashboards.Store, title string, orgId int64, folderId int64, folderUID string, tags ...any) *dashboards.Dashboard {
|
||||
t.Helper()
|
||||
cmd := dashboards.SaveDashboardCommand{
|
||||
OrgID: orgId,
|
||||
FolderID: folderId,
|
||||
IsFolder: true,
|
||||
OrgID: orgId,
|
||||
FolderID: folderId,
|
||||
FolderUID: folderUID,
|
||||
IsFolder: true,
|
||||
Dashboard: simplejson.NewFromAny(map[string]any{
|
||||
"id": nil,
|
||||
"title": title,
|
||||
|
||||
Reference in New Issue
Block a user