LibraryPanels: Disconnect before connect during dashboard save (#31235)

* LibraryPanels: Disconnect before connect during dashboard save

* Tests: fixed test

* Chore: updates after PR comments

* Chore: changes from context.Background() to c.Context.Req.Context()

* Chore: fixes lint issue
This commit is contained in:
Hugo Häggmark
2021-02-16 13:00:56 +01:00
committed by GitHub
parent 884a99e375
commit 06e6bcf091
4 changed files with 111 additions and 26 deletions
+2 -2
View File
@@ -149,7 +149,7 @@ func (hs *HTTPServer) GetDashboard(c *models.ReqContext) response.Response {
if hs.Cfg.IsPanelLibraryEnabled() {
// load library panels JSON for this dashboard
err = hs.LibraryPanelService.LoadLibraryPanelsForDashboard(dash)
err = hs.LibraryPanelService.LoadLibraryPanelsForDashboard(c, dash)
if err != nil {
return response.Error(500, "Error while loading library panels", err)
}
@@ -220,7 +220,7 @@ func (hs *HTTPServer) deleteDashboard(c *models.ReqContext) response.Response {
if hs.Cfg.IsPanelLibraryEnabled() {
// disconnect all library panels for this dashboard
err := hs.LibraryPanelService.DisconnectLibraryPanelsForDashboard(dash)
err := hs.LibraryPanelService.DisconnectLibraryPanelsForDashboard(c, dash)
if err != nil {
hs.log.Error("Failed to disconnect library panels", "dashboard", dash.Id, "user", c.SignedInUser.UserId, "error", err)
}