Folders: Do not allow modifying the folder UID via the API (#74684)

* Folders: Do not allow changing the folder UID via the API

* Update Swagger/OpenAPI docs

* Update HTTP API docs
This commit is contained in:
Sofia Papagiannaki
2023-09-12 14:28:33 +03:00
committed by GitHub
parent 2fac3bd41e
commit 376f9a75db
7 changed files with 162 additions and 76 deletions
-13
View File
@@ -373,18 +373,9 @@ func (s *Service) Update(ctx context.Context, cmd *folder.UpdateFolderCommand) (
return dashFolder, nil
}
if cmd.NewUID != nil && *cmd.NewUID != "" {
if !util.IsValidShortUID(*cmd.NewUID) {
return nil, dashboards.ErrDashboardInvalidUid
} else if util.IsShortUIDTooLong(*cmd.NewUID) {
return nil, dashboards.ErrDashboardUidTooLong
}
}
foldr, err := s.store.Update(ctx, folder.UpdateFolderCommand{
UID: cmd.UID,
OrgID: cmd.OrgID,
NewUID: cmd.NewUID,
NewTitle: cmd.NewTitle,
NewDescription: cmd.NewDescription,
SignedInUser: user,
@@ -471,10 +462,6 @@ func prepareForUpdate(dashFolder *dashboards.Dashboard, orgId int64, userId int6
dashFolder.Title = strings.TrimSpace(title)
dashFolder.Data.Set("title", dashFolder.Title)
if cmd.NewUID != nil && *cmd.NewUID != "" {
dashFolder.SetUID(*cmd.NewUID)
}
dashFolder.SetVersion(cmd.Version)
dashFolder.IsFolder = true