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:
+10
-3
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user