Nested folders: Refactor folder update (#60323)
* Nested folders: Refactor folder update * Apply suggestions from code review
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
@@ -47,27 +46,6 @@ func DashboardToFolder(dash *Dashboard) *Folder {
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateDashboardModel updates an existing model from command into model for update
|
||||
func (cmd *UpdateFolderCommand) UpdateDashboardModel(dashFolder *Dashboard, orgId int64, userId int64) {
|
||||
dashFolder.OrgId = orgId
|
||||
dashFolder.Title = strings.TrimSpace(cmd.Title)
|
||||
dashFolder.Data.Set("title", dashFolder.Title)
|
||||
|
||||
if cmd.Uid != "" {
|
||||
dashFolder.SetUid(cmd.Uid)
|
||||
}
|
||||
|
||||
dashFolder.SetVersion(cmd.Version)
|
||||
dashFolder.IsFolder = true
|
||||
|
||||
if userId == 0 {
|
||||
userId = -1
|
||||
}
|
||||
|
||||
dashFolder.UpdatedBy = userId
|
||||
dashFolder.UpdateSlug()
|
||||
}
|
||||
|
||||
//
|
||||
// COMMANDS
|
||||
//
|
||||
@@ -83,16 +61,6 @@ type MoveFolderCommand struct {
|
||||
ParentUID *string `json:"parentUid"`
|
||||
}
|
||||
|
||||
type UpdateFolderCommand struct {
|
||||
Uid string `json:"uid"`
|
||||
Title string `json:"title"`
|
||||
Version int `json:"version"`
|
||||
Description string `json:"description"`
|
||||
Overwrite bool `json:"overwrite"`
|
||||
|
||||
Result *Folder `json:"-"`
|
||||
}
|
||||
|
||||
//
|
||||
// QUERIES
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user