浏览代码

[5443] Check if title is empty before save a new dashboard

Pavlos Daoglou 9 年之前
父节点
当前提交
7f7f080ad8
共有 2 个文件被更改,包括 5 次插入0 次删除
  1. 4 0
      pkg/api/dashboard.go
  2. 1 0
      pkg/models/dashboards.go

+ 4 - 0
pkg/api/dashboard.go

@@ -121,6 +121,10 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) Response {
 	}
 
 	dash := cmd.GetDashboardModel()
+	// Check if Title is empty
+	if dash.Title == "" {
+		return ApiError(400, m.ErrDashboardTitleEmpty.Error(), nil)
+	}
 	if dash.Id == 0 {
 		limitReached, err := middleware.QuotaReached(c, "dashboard")
 		if err != nil {

+ 1 - 0
pkg/models/dashboards.go

@@ -15,6 +15,7 @@ var (
 	ErrDashboardSnapshotNotFound   = errors.New("Dashboard snapshot not found")
 	ErrDashboardWithSameNameExists = errors.New("A dashboard with the same name already exists")
 	ErrDashboardVersionMismatch    = errors.New("The dashboard has been changed by someone else")
+	ErrDashboardTitleEmpty         = errors.New("Dashboard title cannot be empty")
 )
 
 type UpdatePluginDashboardError struct {