mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'dashboard_folders' of github.com:grafana/grafana into dashboard_folders
This commit is contained in:
commit
5b35a21d6f
@ -194,6 +194,10 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) Response {
|
|||||||
return ApiError(403, "Does not have permission to save this dashboard", nil)
|
return ApiError(403, "Does not have permission to save this dashboard", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if dash.IsFolder && dash.ParentId > 0 {
|
||||||
|
return ApiError(400, m.ErrDashboardFolderCannotHaveParent.Error(), nil)
|
||||||
|
}
|
||||||
|
|
||||||
// Check if Title is empty
|
// Check if Title is empty
|
||||||
if dash.Title == "" {
|
if dash.Title == "" {
|
||||||
return ApiError(400, m.ErrDashboardTitleEmpty.Error(), nil)
|
return ApiError(400, m.ErrDashboardTitleEmpty.Error(), nil)
|
||||||
|
@ -132,6 +132,26 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
|||||||
CallPostDashboard(sc)
|
CallPostDashboard(sc)
|
||||||
So(sc.resp.Code, ShouldEqual, 200)
|
So(sc.resp.Code, ShouldEqual, 200)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Convey("When saving a dashboard folder in another folder", func() {
|
||||||
|
bus.AddHandler("test", func(query *models.GetDashboardQuery) error {
|
||||||
|
query.Result = fakeDash
|
||||||
|
query.Result.IsFolder = true
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
invalidCmd := models.SaveDashboardCommand{
|
||||||
|
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
||||||
|
"parentId": fakeDash.ParentId,
|
||||||
|
"title": fakeDash.Title,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
Convey("Should return an error", func() {
|
||||||
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, invalidCmd, func(sc *scenarioContext) {
|
||||||
|
CallPostDashboard(sc)
|
||||||
|
So(sc.resp.Code, ShouldEqual, 400)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ var (
|
|||||||
ErrDashboardWithSameNameExists = errors.New("A dashboard with the same name already exists")
|
ErrDashboardWithSameNameExists = errors.New("A dashboard with the same name already exists")
|
||||||
ErrDashboardVersionMismatch = errors.New("The dashboard has been changed by someone else")
|
ErrDashboardVersionMismatch = errors.New("The dashboard has been changed by someone else")
|
||||||
ErrDashboardTitleEmpty = errors.New("Dashboard title cannot be empty")
|
ErrDashboardTitleEmpty = errors.New("Dashboard title cannot be empty")
|
||||||
|
ErrDashboardFolderCannotHaveParent = errors.New("A Dashboard Folder cannot be added to another folder")
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdatePluginDashboardError struct {
|
type UpdatePluginDashboardError struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user