mirror of https://github.com/grafana/grafana.git
				
				
				
			fix(alerting): check if dashboard is saved before testing alert rule, fixes #6549
This commit is contained in:
		
							parent
							
								
									c365d52a80
								
							
						
					
					
						commit
						773fb5d1ae
					
				|  | @ -103,6 +103,10 @@ func GetAlerts(c *middleware.Context) Response { | ||||||
| 
 | 
 | ||||||
| // POST /api/alerts/test
 | // POST /api/alerts/test
 | ||||||
| func AlertTest(c *middleware.Context, dto dtos.AlertTestCommand) Response { | func AlertTest(c *middleware.Context, dto dtos.AlertTestCommand) Response { | ||||||
|  | 	if _, idErr := dto.Dashboard.Get("id").Int64(); idErr != nil { | ||||||
|  | 		return ApiError(400, "The dashboard needs to be saved at least once before you can test an alert rule", nil) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	backendCmd := alerting.AlertTestCommand{ | 	backendCmd := alerting.AlertTestCommand{ | ||||||
| 		OrgId:     c.OrgId, | 		OrgId:     c.OrgId, | ||||||
| 		Dashboard: dto.Dashboard, | 		Dashboard: dto.Dashboard, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue