Folders: Show dashboards and folders with directly assigned permissions in "Shared" folder (#78465)

* Folders: Show folders user has access to at the root level

* Refactor

* Refactor

* Hide parent folders user has no access to

* Skip expensive computation if possible

* Fix tests

* Fix potential nil access

* Fix duplicated folders

* Fix linter error

* Fix querying folders if no managed permissions set

* Update benchmark

* Add special shared with me folder and fetch available non-root folders on demand

* Fix parents query

* Improve db query for folders

* Reset benchmark changes

* Fix permissions for shared with me folder

* Simplify dedup

* Add option to include shared folder permission to user's permissions

* Fix nil UID

* Remove duplicated folders from shared list

* Folders: Fix fetching empty folder

* Nested folders: Show dashboards with directly assigned permissions

* Fix slow dashboards fetch

* Refactor

* Fix cycle dependencies

* Move shared folder to models

* Fix shared folder links

* Refactor

* Use feature flag for permissions

* Use feature flag

* Review comments

* Expose shared folder UID through frontend settings

* Add frontend type for sharedWithMeFolderUID option

* Refactor: apply review suggestions

* Fix parent uid for shared folder

* Fix listing shared dashboards for users with access to all folders

* Prevent creating folder with "shared" UID

* Add tests for shared folders

* Add test for shared dashboards

* Fix linter

* Add metrics for shared with me folder

* Add metrics for shared with me dashboards

* Fix tests

* Tests: add metrics as a dependency

* Fix access control metadata for shared with me folder

* Use constant for shared with me

* Optimize parent folders access check, fetch all folders in one query.

* Use labels for metrics
This commit is contained in:
Alexander Zobnin
2023-12-05 16:13:31 +01:00
committed by GitHub
parent 647f576359
commit 959ebf82da
25 changed files with 471 additions and 32 deletions
+12 -3
View File
@@ -19,9 +19,10 @@ var ErrTargetRegistrySrvConflict = errutil.Internal("folder.target-registry-srv-
var ErrFolderNotEmpty = errutil.BadRequest("folder.not-empty", errutil.WithPublicMessage("Folder cannot be deleted: folder is not empty"))
const (
GeneralFolderUID = "general"
RootFolderUID = ""
MaxNestedFolderDepth = 4
GeneralFolderUID = "general"
RootFolderUID = ""
MaxNestedFolderDepth = 4
SharedWithMeFolderUID = "sharedwithme"
)
var ErrFolderNotFound = errutil.NotFound("folder.notFound")
@@ -49,6 +50,14 @@ type Folder struct {
var GeneralFolder = Folder{ID: 0, Title: "General"}
var SharedWithMeFolder = Folder{
Title: "Shared with me",
Description: "Dashboards and folders shared with me",
UID: SharedWithMeFolderUID,
ParentUID: "",
ID: -1,
}
func (f *Folder) IsGeneral() bool {
// nolint:staticcheck
return f.ID == GeneralFolder.ID && f.Title == GeneralFolder.Title