mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Nested Folders: Decrease max nested folders depth (#78133)
* Nested Folders: Decrease allowed nested folders depth * Fix folder height check in Move
This commit is contained in:
parent
20f541d7e7
commit
1d1d42c984
@ -698,8 +698,8 @@ func (s *Service) Move(ctx context.Context, cmd *folder.MoveFolderCommand) (*fol
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// current folder height + current folder + parent folder + parent folder depth should be less than or equal 8
|
||||
if folderHeight+len(parents)+2 > folder.MaxNestedFolderDepth {
|
||||
// height of the folder that is being moved + this current folder itself + depth of the NewParent folder should be less than or equal MaxNestedFolderDepth
|
||||
if folderHeight+len(parents)+1 > folder.MaxNestedFolderDepth {
|
||||
return nil, folder.ErrMaximumDepthReached.Errorf("failed to move folder")
|
||||
}
|
||||
|
||||
@ -961,7 +961,7 @@ func (s *Service) validateParent(ctx context.Context, orgID int64, parentUID str
|
||||
return fmt.Errorf("failed to get parents: %w", err)
|
||||
}
|
||||
|
||||
if len(ancestors) == folder.MaxNestedFolderDepth {
|
||||
if len(ancestors) >= folder.MaxNestedFolderDepth {
|
||||
return folder.ErrMaximumDepthReached.Errorf("failed to validate parent folder")
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ var ErrTargetRegistrySrvConflict = errutil.Internal("folder.target-registry-srv-
|
||||
const (
|
||||
GeneralFolderUID = "general"
|
||||
RootFolderUID = ""
|
||||
MaxNestedFolderDepth = 8
|
||||
MaxNestedFolderDepth = 4
|
||||
)
|
||||
|
||||
var ErrFolderNotFound = errutil.NotFound("folder.notFound")
|
||||
|
Loading…
Reference in New Issue
Block a user