Chore: GetDashboardQuery should be dispatched using DispatchCtx (#36877)

* Chore: GetDashboardQuery should be dispatched using DispatchCtx

* Fix after merge

* Changes after review

* Various fixes

* Use GetDashboardCtx function instead of GetDashboard
This commit is contained in:
Marcus Efraimsson
2021-09-14 16:08:04 +02:00
committed by GitHub
parent 2b1d3d27e4
commit fa9857499b
28 changed files with 149 additions and 135 deletions
+7 -7
View File
@@ -17,7 +17,7 @@ import (
func (hs *HTTPServer) GetFolders(c *models.ReqContext) response.Response {
s := dashboards.NewFolderService(c.OrgId, c.SignedInUser, hs.SQLStore)
folders, err := s.GetFolders(c.QueryInt64("limit"), c.QueryInt64("page"))
folders, err := s.GetFolders(c.Req.Context(), c.QueryInt64("limit"), c.QueryInt64("page"))
if err != nil {
return apierrors.ToFolderErrorResponse(err)
@@ -38,7 +38,7 @@ func (hs *HTTPServer) GetFolders(c *models.ReqContext) response.Response {
func (hs *HTTPServer) GetFolderByUID(c *models.ReqContext) response.Response {
s := dashboards.NewFolderService(c.OrgId, c.SignedInUser, hs.SQLStore)
folder, err := s.GetFolderByUID(c.Params(":uid"))
folder, err := s.GetFolderByUID(c.Req.Context(), c.Params(":uid"))
if err != nil {
return apierrors.ToFolderErrorResponse(err)
}
@@ -49,7 +49,7 @@ func (hs *HTTPServer) GetFolderByUID(c *models.ReqContext) response.Response {
func (hs *HTTPServer) GetFolderByID(c *models.ReqContext) response.Response {
s := dashboards.NewFolderService(c.OrgId, c.SignedInUser, hs.SQLStore)
folder, err := s.GetFolderByID(c.ParamsInt64(":id"))
folder, err := s.GetFolderByID(c.Req.Context(), c.ParamsInt64(":id"))
if err != nil {
return apierrors.ToFolderErrorResponse(err)
}
@@ -60,13 +60,13 @@ func (hs *HTTPServer) GetFolderByID(c *models.ReqContext) response.Response {
func (hs *HTTPServer) CreateFolder(c *models.ReqContext, cmd models.CreateFolderCommand) response.Response {
s := dashboards.NewFolderService(c.OrgId, c.SignedInUser, hs.SQLStore)
folder, err := s.CreateFolder(cmd.Title, cmd.Uid)
folder, err := s.CreateFolder(c.Req.Context(), cmd.Title, cmd.Uid)
if err != nil {
return apierrors.ToFolderErrorResponse(err)
}
if hs.Cfg.EditorsCanAdmin {
if err := s.MakeUserAdmin(c.OrgId, c.SignedInUser.UserId, folder.Id, true); err != nil {
if err := s.MakeUserAdmin(c.Req.Context(), c.OrgId, c.SignedInUser.UserId, folder.Id, true); err != nil {
hs.log.Error("Could not make user admin", "folder", folder.Title, "user",
c.SignedInUser.UserId, "error", err)
}
@@ -78,7 +78,7 @@ func (hs *HTTPServer) CreateFolder(c *models.ReqContext, cmd models.CreateFolder
func (hs *HTTPServer) UpdateFolder(c *models.ReqContext, cmd models.UpdateFolderCommand) response.Response {
s := dashboards.NewFolderService(c.OrgId, c.SignedInUser, hs.SQLStore)
err := s.UpdateFolder(c.Params(":uid"), &cmd)
err := s.UpdateFolder(c.Req.Context(), c.Params(":uid"), &cmd)
if err != nil {
return apierrors.ToFolderErrorResponse(err)
}
@@ -97,7 +97,7 @@ func (hs *HTTPServer) DeleteFolder(c *models.ReqContext) response.Response { //
return apierrors.ToFolderErrorResponse(err)
}
f, err := s.DeleteFolder(c.Params(":uid"), c.QueryBool("forceDeleteRules"))
f, err := s.DeleteFolder(c.Req.Context(), c.Params(":uid"), c.QueryBool("forceDeleteRules"))
if err != nil {
return apierrors.ToFolderErrorResponse(err)
}