Nested folders: Allow creating folders with duplicate names in different locations (#77076)

* Add API test

* Add move tests

* Fix create folder

* Fix move

* Fix test

* Drop and re-create index so that allows a folder to contain a dashboard and a subfolder with same name

* Get folder by title defaults to root folder and optionally fetches folder by provided parent folder

* Apply suggestions from code review
This commit is contained in:
Sofia Papagiannaki
2024-01-25 11:29:56 +02:00
committed by GitHub
parent 030a68bbf7
commit 478d7d58fa
17 changed files with 330 additions and 53 deletions

View File

@@ -16,6 +16,8 @@ type Service interface {
// request. One of UID, ID or Title must be included. If multiple values
// are included in the request, Grafana will select one in order of
// specificity (UID, ID, Title).
// When fetching a folder by Title, callers can optionally define a ParentUID.
// If ParentUID is not set then the folder will be fetched from the root level.
Get(ctx context.Context, q *GetFolderQuery) (*Folder, error)
// Update is used to update a folder's UID, Title and Description. To change
@@ -39,7 +41,10 @@ type Service interface {
//go:generate mockery --name FolderStore --structname FakeFolderStore --outpkg foldertest --output foldertest --filename folder_store_mock.go
type FolderStore interface {
// GetFolderByTitle retrieves a folder by its title
GetFolderByTitle(ctx context.Context, orgID int64, title string) (*Folder, error)
// It expects a parentUID as last argument.
// If parentUID is empty then the folder will be fetched from the root level
// otherwise it will be fetched from the subfolder under the folder with the given UID.
GetFolderByTitle(ctx context.Context, orgID int64, title string, parentUID *string) (*Folder, error)
// GetFolderByUID retrieves a folder by its UID
GetFolderByUID(ctx context.Context, orgID int64, uid string) (*Folder, error)
// GetFolderByID retrieves a folder by its ID