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:
Sofia Papagiannaki
2023-10-24 10:04:45 +03:00
committed by GitHub
parent 442e533803
commit 03a626f1d6
28 changed files with 706 additions and 236 deletions
+10 -3
View File
@@ -412,10 +412,13 @@ func (hs *HTTPServer) postDashboard(c *contextmodel.ReqContext, cmd dashboards.S
cmd.OrgID = c.SignedInUser.GetOrgID()
cmd.UserID = userID
if cmd.FolderUID != "" {
// nolint:staticcheck
if cmd.FolderUID != "" || cmd.FolderID != 0 {
folder, err := hs.folderService.Get(ctx, &folder.GetFolderQuery{
OrgID: c.SignedInUser.GetOrgID(),
UID: &cmd.FolderUID,
OrgID: c.SignedInUser.GetOrgID(),
UID: &cmd.FolderUID,
// nolint:staticcheck
ID: &cmd.FolderID,
SignedInUser: c.SignedInUser,
})
if err != nil {
@@ -424,7 +427,9 @@ func (hs *HTTPServer) postDashboard(c *contextmodel.ReqContext, cmd dashboards.S
}
return response.Error(http.StatusInternalServerError, "Error while checking folder ID", err)
}
// nolint:staticcheck
cmd.FolderID = folder.ID
cmd.FolderUID = folder.UID
}
dash := cmd.GetDashboardModel()
@@ -1073,7 +1078,9 @@ func (hs *HTTPServer) RestoreDashboardVersion(c *contextmodel.ReqContext) respon
saveCmd.Dashboard.Set("version", dash.Version)
saveCmd.Dashboard.Set("uid", dash.UID)
saveCmd.Message = fmt.Sprintf("Restored from version %d", version.Version)
// nolint:staticcheck
saveCmd.FolderID = dash.FolderID
saveCmd.FolderUID = dash.FolderUID
return hs.postDashboard(c, saveCmd)
}