Folders: Introduce folder service function for fetching folders by org and UIDs that contain optionally the folder full path (#80716)

* Folders: Expose function for getting all org folders with specific UIDs

* Return all org folders if UIDs is empty

* Filter out not accessible folders by the user

* Modify query to optionally returning a string that contains the UIDs of all parent folders separated by slash.
This commit is contained in:
Sofia Papagiannaki
2024-01-25 09:27:13 +02:00
committed by GitHub
parent f154b2b855
commit 5e88d29814
11 changed files with 579 additions and 83 deletions
+13 -1
View File
@@ -6,6 +6,18 @@ import (
"github.com/grafana/grafana/pkg/services/folder"
)
type getFoldersQuery struct {
folder.GetFoldersQuery
ancestorUIDs []string
}
func NewGetFoldersQuery(q folder.GetFoldersQuery) getFoldersQuery {
return getFoldersQuery{
GetFoldersQuery: q,
ancestorUIDs: []string{},
}
}
// store is the interface which a folder store must implement.
type store interface {
// Create creates a folder and returns the newly-created folder.
@@ -35,5 +47,5 @@ type store interface {
GetHeight(ctx context.Context, foldrUID string, orgID int64, parentUID *string) (int, error)
// GetFolders returns folders with given uids
GetFolders(ctx context.Context, orgID int64, uids []string) ([]*folder.Folder, error)
GetFolders(ctx context.Context, q getFoldersQuery) ([]*folder.Folder, error)
}