Commit Graph

138 Commits

Author SHA1 Message Date
owensmallwood
0dfdb2ae47
Revert "Add FolderUID for library elements" (#83776)
Revert "Add FolderUID for library elements (#79572)"

This reverts commit 2532047e7a.
2024-03-01 18:16:43 +02:00
idafurjes
2532047e7a
Add FolderUID for library elements (#79572)
* Add FolderUID in missing places for libraryelements

* Add migration for FolderUID in library elements table

* Add Folder UIDs tolibrary panels

* Adjust dashboard import with folder uid

* Fix lint

* Rename back FolderUID to UID

* Remove default

* Check if folderUID is nil

* Add unique indes on org_id,folder_uid,name and kind

* Update pkg/services/libraryelements/database.go

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>

* Fix folder integration test, with unique index on library elements

* Make folder uids nullable and rewrite migration query

* Use dashboard uid instead of folder_uid

* Adjust test

---------

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
2024-03-01 10:16:33 +01:00
김은빈
96dfb385ca
Grafana: Replace magic number with a constant variable in response status (#80132)
* Chore: Replace response status with const var

* Apply suggestions from code review

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>

* Add net/http import

---------

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
2024-02-27 18:39:51 +02:00
Serge Zaitsev
d0679f0993
Chore: Add support bundle for folders (#83360)
* add support bundle for folders

* fix ProvideService in tests

* add a test for collector
2024-02-26 11:27:22 +01:00
kay delaney
82e3e2e558
LibraryPanels/RBAC: Fix issue where folder scopes weren't being correctly inherited (#82700) 2024-02-16 14:17:41 +00:00
Dan Cech
790e1feb93
Chore: Update test database initialization (#81673)
* streamline initialization of test databases, support on-disk sqlite test db

* clean up test databases

* introduce testsuite helper

* use testsuite everywhere we use a test db

* update documentation

* improve error handling

* disable entity integration test until we can figure out locking error
2024-02-09 09:35:39 -05:00
idafurjes
7e5544ab21
Add MFolderIDsServiceCount to count folderIDs in services pkg (#81237) 2024-01-25 11:10:35 +01:00
Marcus Efraimsson
6768c6c059
Chore: Remove public vars in setting package (#81018)
Removes the public variable setting.SecretKey plus some other ones. 
Introduces some new functions for creating setting.Cfg.
2024-01-23 12:36:22 +01:00
Dan Cech
d76defe517
K8s: Move GrafanaMetaAccessor into grafana-apiserver and remove usage of kinds metadata (#79602)
* move GrafanaMetaAccessor into pkg/apis, add support for Spec.Title & Spec.Name

* K8s: Move GrafanaMetaAccessor (PR into another) (#79728)

* access titles

* remove title

* remove title

* remove kinds metadata accessor

* remove kinds metadata accessor

* fixes

* error handling

* fix tests

---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2024-01-12 16:18:14 -05:00
Alexander Zobnin
959ebf82da
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
2023-12-05 16:13:31 +01:00
Julien Duchesne
cd584e9261
Swagger: Fix getLibraryElementByName response (#78221)
It returns an array of library elements, not a single one. This has been tested by generating the OpenAPI client and using it in Terraform
2023-12-04 11:20:13 -05:00
Jo
0de66a8099
Authz: Remove use of SignedInUser copy for permission evaluation (#78448)
* remove use of SignedInUserCopies

* add extra safety to not cross assign permissions

unwind circular dependency

dashboardacl->dashboardaccess

fix missing import

* correctly set teams for permissions

* fix missing inits

* nit: check err

* exit early for api keys
2023-11-22 14:20:22 +01:00
Kat Yang
2f2ce3edbb
Chore: Deprecate ID from Folder (#78281)
* Chore: Deprecate ID from Folder

* chore: add more linter comments

* chore: add missing lint comment
2023-11-20 15:44:51 -05:00
Kat Yang
8d581b8358
Chore: Deprecate ID in GetFolderQuery (#77647) 2023-11-15 10:30:00 -05:00
Kat Yang
3a2e96b0db
Chore: Deprecate FolderID from Dashboard (#77823)
* Chore: Deprecate FolderID from Dashboard

* chore: add two missing nolint comments
2023-11-15 10:28:50 -05:00
Ryan McKinley
f69fd3726b
FeatureToggles: Add context and and an explicit global check (#78081) 2023-11-14 12:50:27 -08:00
Ryan McKinley
3509a5abb9
FeatureFlags: Cleanup usage of cfg.IsFeatureToggleEnabled (#78014) 2023-11-13 07:55:15 -08:00
Kat Yang
911ffed45b
Chore: Deprecate FolderID in libraryElement struct in tests (#77473)
* Chore: Deprecate FolderID in LibraryElement struct in tests

* chore: revert formatting for deprecation comment
2023-11-06 11:31:15 -05:00
Kat Yang
2c7f364067
Chore: Deprecate FolderID in PatchLibraryElementCommand (#77472)
* Chore: Deprecate FolderID in PatchLibraryElementCommand

* chore: regen specs
2023-11-06 11:31:01 -05:00
Kat Yang
dd5314c6a8
Chore: Deprecate FolderID in LibraryElementDTO (#77471)
* Chore: Deprecate FolderID in LibraryElementDTO

* chore: fix formatting of deprecation comment

* chore: revert deprecation comment formatting

* chore: regen specs
2023-11-06 11:30:32 -05:00
Kat Yang
f40de8b613
Chore: Deprecate folderIDs in FolderFilter (#77590)
Chore: Deprecate FolderID in FolderFilter
2023-11-03 10:12:40 -04:00
Kat Yang
254648b96b
Chore: Deprecate FolderID in CreateLibraryElementComand (#77403)
* Chore: Deprecate FolderID in CreateLibraryElementComand

* chore: add remaining nolint comments

* chore: regen specs to include deprecation notice
2023-10-31 13:24:16 -04:00
Kat Yang
f9b21083c6
Chore: Deprecate FolderID in LibraryElement struct (#77377)
* Chore: Deprecate FolderID in LibraryElement struct

* chore: format deprecated comment

* chore: add remaining nolint comments
2023-10-31 13:02:53 -04:00
Kat Yang
f7ce6f8b41
Chore: Deprecate FolderID in LibraryElementWithMeta (#77406) 2023-10-31 11:50:02 -04:00
Kat Yang
87717849da
Chore: Deprecate FolderID in GetLibraryElementCommand (#77404) 2023-10-31 11:46:48 -04:00
Dan Cech
db6035a843
Chore: update kind annotation names to grafana.app/* (#77401)
* update kind annotation names to grafana.app/*
2023-10-30 17:08:31 -04:00
kay delaney
b215d2f0fb
Library Panels: Fix library panel creation with RBAC enabled (#76553) 2023-10-25 16:29:57 +03:00
Sofia Papagiannaki
b04a014341
Chore: Fix failure when importing dashboard (#76947) 2023-10-23 18:16:46 +03:00
kay delaney
a12cb8cbf3
LibraryPanels: Add RBAC support (#73475) 2023-10-12 00:30:50 +01:00
Jo
dcd0c6b11e
Identity: Unfurl OrgID in pkg/services to allow using identity.Requester interface (#76113)
Unfurl OrgID in pkg/services to allow using identity.Requester interface
2023-10-09 10:40:19 +02:00
Jo
342af2d078
Identity: Port Annotations and Analytics to Identity.Requester (#76104)
* Port analytics to requester

* Port annotations to identity.Request
2023-10-06 11:38:20 +02:00
linoman
13f4382214
Auth: Implement requester interface in access control module (#74289)
* Implement requester interface in the access control module
2023-09-06 11:16:10 +02:00
Ryan McKinley
025b2f3011
Chore: use any rather than interface{} (#74066) 2023-08-30 18:46:47 +03:00
Karl Persson
01d98114b9
Authz: fix snapshot tests legacy guardian (#73823)
* Guardian: remove unused dependencies

* API: rewrite tests to use access control guardian
2023-08-28 09:49:10 +02:00
Serge Zaitsev
7767ab6f43
Chore: Add folder data migration, fix unique index (#72602)
* add folder data migration, fix unique index

* fix unique index

* pass a fake store in tests

* pass store into other providers in tests

* and now with alerting!
2023-08-01 09:36:37 +02:00
Juan Cabanas
427714f8d0
Export: Remove DS input when dashboard is imported with a lib panel that already exists (#69412) 2023-07-27 13:11:15 -03:00
Arati R
20ffbbc41e
NestedFolders: Add library panels counting and deletion to folder registry (#69149)
* Expose library element service's folder service
* Register library panels, add count implementation
* Expand folder counts test
* Update registry deletion method interface
* Allow getting library elements from any folder
* Add test for library panel deletion
* Add test for library panel counting
2023-07-25 13:05:53 +02:00
Ryan McKinley
10ea92fa09
Schemas: minor updates from the k8s branch (#71688)
Co-authored-by: sam boyer <sdboyer@grafana.com>
2023-07-21 19:17:11 +03:00
Juan Cabanas
ee73d41d24
PublicDashboards: Audit table pagination (#69823) 2023-06-21 10:48:09 -03:00
Ryan McKinley
c66d5721f7
Kinds: Use apimachinery ObjectMeta for metadata (#68668) 2023-05-24 09:13:44 -07:00
Ieva
a37bf1ac2a
RBAC: Update library element tests to use RBAC (#66782)
* update library element tests to use RBAC

* update bits of code to use RBAC

* update library panel tests

* linting

* more linting

* and more linting

* PR feedback
2023-04-20 12:24:41 +03:00
Arati R
cab3ba519a
NestedFolders: Add folder service registry with dashboard service implementation (#65033)
* Delete folders, dashboards with registry service
Co-authored-by: Serge Zaitsev <hello@zserge.com>
* Update signature of ProvideDashboardServiceImpl
* Regenerate mockery file
* Add test for DeleteInFolder
* Add test for DeleteDashboardsInFolder
* Delete child dashboard associations via registry
* Add validation of folder uid and org id

---------

Co-authored-by: Serge Zaitsev <hello@zserge.com>
2023-04-14 11:17:23 +02:00
Ashley Harrison
fda38de293
Library panels: Ensure pagination controls are always correctly displayed (#65283)
correctly count library panels in the general folder
2023-04-11 14:16:20 +01:00
Sofia Papagiannaki
988a120d6d
Search v1: Add support for inherited folder permissions if nested folders are enabled (#63275)
* Add features dependency to SQLBuilder

* Add features dependency to AccessControlDashboardPermissionFilter

* Add test for folder inheritance

* Dashboard permissions: Return recursive query

* Recursive query for inherited folders

* Modify search builder

* Adjust db.SQLBuilder

* Pass flag to SQLbuilder if CTEs are supported

* Add support for mysql < 8.0

* Add benchmarking for search with nested folders

* Set features to AlertStore

* Update pkg/infra/db/sqlbuilder.go

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>

* Set features to LibraryElementService

* SQLBuilder tests with nested folder flag set

* Apply suggestion from code review

Co-authored-by: IevaVasiljeva <ieva.vasiljeva@grafana.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2023-04-06 11:16:15 +03:00
Jo
6b6cf5f4b7
Cfg: Move ViewersCanEdit into cfg (#64876)
move ViewersCanEdit into cfg
2023-03-16 10:54:01 +01:00
Ryan McKinley
42e7ec9fe4
Chore: cleanup dashboard service names (#64442) 2023-03-08 14:37:45 -05:00
Ieva
a52999a886
Access Control: revert to using folder store from the scope resolvers (#64132)
* revert to using folder store from the resolvers

* fixing tests after revert

* api test fixes

---------

Co-authored-by: Kristin Laemmert <mildwonkey@users.noreply.github.com>
2023-03-03 10:56:33 -05:00
Kristin Laemmert
bb798e24f3
chore(services): replace dependencies on dashboard store with dashboard service (#63937)
* chore(services): replace dependencies on dashboard store with dashboard service

This continues the backend service/store split by replacing dashboard store dependencies with service dependencies. the folder service remains the single exception for now; otherwise we'd have a dependency cycle between the folder and dashboard services. I have some ideas for that, but I'll take care of all the easy parts first.

While doing this, I identified and removed a number of unused arguments from the following functions:

NewFolderNameScopeResolver
NewFolderIDScopeResolver
NewFolderUIDScopeResolver
NewDashboardIDScopeResolver
NewDashboardUIDScopeResolver
resolveDashboardScope

I have a small enterprise PR to support this commit.

* lingering fmt
2023-03-02 08:09:57 -05:00
Ryan McKinley
22aa09d392
DashboardStore: Provide an interface directly rather than pointer receiver (#63910) 2023-03-01 07:52:16 -08:00
Jo
f9163351fd
Support bundles: Refactor registry into separate service (#62945)
* add bundle registry service to avoid dependency cycles

* move user support bundle collector to user service

* move usage stat bundle implementation to usage stats

* add info for background service

* fix remaining imports

* whitespace
2023-02-06 17:50:03 +01:00