mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix importing plugin dashboards (#21501)
#21350 introduced a bug regarding import of plugin dashboards. This should fix this and add custom validation if not importing plugin dashboard and dashboard property is missing. Ref #21350 Co-Authored-By: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
98bbdea69d
commit
54c9b11ae8
@ -56,7 +56,7 @@ type ImportDashboardCommand struct {
|
|||||||
PluginId string `json:"pluginId"`
|
PluginId string `json:"pluginId"`
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
Overwrite bool `json:"overwrite"`
|
Overwrite bool `json:"overwrite"`
|
||||||
Dashboard *simplejson.Json `json:"dashboard" binding:"Required"`
|
Dashboard *simplejson.Json `json:"dashboard"`
|
||||||
Inputs []plugins.ImportDashboardInput `json:"inputs"`
|
Inputs []plugins.ImportDashboardInput `json:"inputs"`
|
||||||
FolderId int64 `json:"folderId"`
|
FolderId int64 `json:"folderId"`
|
||||||
}
|
}
|
||||||
|
@ -179,6 +179,10 @@ func GetPluginMarkdown(c *m.ReqContext) Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ImportDashboard(c *m.ReqContext, apiCmd dtos.ImportDashboardCommand) Response {
|
func ImportDashboard(c *m.ReqContext, apiCmd dtos.ImportDashboardCommand) Response {
|
||||||
|
if apiCmd.PluginId == "" && apiCmd.Dashboard == nil {
|
||||||
|
return Error(422, "Dashboard must be set", nil)
|
||||||
|
}
|
||||||
|
|
||||||
cmd := plugins.ImportDashboardCommand{
|
cmd := plugins.ImportDashboardCommand{
|
||||||
OrgId: c.OrgId,
|
OrgId: c.OrgId,
|
||||||
User: c.SignedInUser,
|
User: c.SignedInUser,
|
||||||
|
Loading…
Reference in New Issue
Block a user