Commit 6d1e3613 by Carl Bergquist Committed by GitHub

Merge pull request #11246 from grafana/11227_import

dashboard: fix import dashboard with alert rule(s)
parents a8918047 87284d28
...@@ -80,7 +80,7 @@ func ImportDashboard(cmd *ImportDashboardCommand) error { ...@@ -80,7 +80,7 @@ func ImportDashboard(cmd *ImportDashboardCommand) error {
User: cmd.User, User: cmd.User,
} }
savedDash, err := dashboards.NewService().SaveDashboard(dto) savedDash, err := dashboards.NewService().ImportDashboard(dto)
if err != nil { if err != nil {
return err return err
......
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
// DashboardService service for operating on dashboards // DashboardService service for operating on dashboards
type DashboardService interface { type DashboardService interface {
SaveDashboard(dto *SaveDashboardDTO) (*models.Dashboard, error) SaveDashboard(dto *SaveDashboardDTO) (*models.Dashboard, error)
ImportDashboard(dto *SaveDashboardDTO) (*models.Dashboard, error)
} }
// DashboardProvisioningService service for operating on provisioned dashboards // DashboardProvisioningService service for operating on provisioned dashboards
...@@ -214,6 +215,20 @@ func (dr *dashboardServiceImpl) SaveDashboard(dto *SaveDashboardDTO) (*models.Da ...@@ -214,6 +215,20 @@ func (dr *dashboardServiceImpl) SaveDashboard(dto *SaveDashboardDTO) (*models.Da
return cmd.Result, nil return cmd.Result, nil
} }
func (dr *dashboardServiceImpl) ImportDashboard(dto *SaveDashboardDTO) (*models.Dashboard, error) {
cmd, err := dr.buildSaveDashboardCommand(dto, false)
if err != nil {
return nil, err
}
err = bus.Dispatch(cmd)
if err != nil {
return nil, err
}
return cmd.Result, nil
}
type FakeDashboardService struct { type FakeDashboardService struct {
SaveDashboardResult *models.Dashboard SaveDashboardResult *models.Dashboard
SaveDashboardError error SaveDashboardError error
...@@ -230,6 +245,10 @@ func (s *FakeDashboardService) SaveDashboard(dto *SaveDashboardDTO) (*models.Das ...@@ -230,6 +245,10 @@ func (s *FakeDashboardService) SaveDashboard(dto *SaveDashboardDTO) (*models.Das
return s.SaveDashboardResult, s.SaveDashboardError return s.SaveDashboardResult, s.SaveDashboardError
} }
func (s *FakeDashboardService) ImportDashboard(dto *SaveDashboardDTO) (*models.Dashboard, error) {
return s.SaveDashboard(dto)
}
func MockDashboardService(mock *FakeDashboardService) { func MockDashboardService(mock *FakeDashboardService) {
NewService = func() DashboardService { NewService = func() DashboardService {
return mock return mock
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment