Commit Graph

149 Commits

Author SHA1 Message Date
Yuri Tseretyan
47546a4c72
Alerting: Update API to use folders' full paths (#81214)
* update GetUserVisibleNamespaces to use FolderSeriver
* update GetNamespaceByUID to use FolderService.GetFolders
* update GetAlertRulesForScheduling to use FolderService.GetFolders 

* Update API and GetAlertRulesForScheduling to use the folder's full path
* get full path of folder in RouteTestGrafanaRuleConfig

* fix escaping of titles for MySQL
2024-02-06 17:12:13 -05:00
Yuri Tseretyan
15223a4b85
Folders: Set FullPath and FullPathUIDs when feature flag is off and query requests (#81896)
* set FullPath and FullPathUIDs if feature flag is off and query requests

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
2024-02-06 09:18:40 -05:00
Sofia Papagiannaki
ec5bc7c4ab
Folders: Fix failure to update folder in SQLite (#81795) 2024-02-05 10:06:11 +02:00
Alexander Zobnin
1bcd597bc0
Nested folders: Improve performance of shared with me dashboards listing (#81590)
* Nested folders: Improve performance of shared with me dashboards listing

* Fix tests

* Clean up guardian
2024-01-31 16:25:11 +01:00
Sofia Papagiannaki
89d3b55bec
Folders: Reduce DB queries when counting and deleting resources under folders (#81153)
* Add folder store method for fetching all folder descendants

* Modify GetDescendantCounts() to fetch folder descendants at once

* Reduce DB calls when counting library panels under dashboard

* Reduce DB calls when counting dashboards under folder

* Reduce DB calls during folder delete

* Modify folder registry to count/delete entities under multiple folders

* Reduce DB calls when counting

* Reduce DB calls when deleting
2024-01-30 18:26:34 +02:00
Yuri Tseretyan
a081abdd25
Folders: GetFolders to return empty respons if user does not have any permissions (#81304)
add check for list of permissions
2024-01-26 19:12:45 +02:00
idafurjes
f44592a97a
Remove folderID from service tests (#80615)
* Remove folderID from service tests

* Remove folderID from ngalert migration tests

* Remove tests related to folderIDs

* Roll back change

Before removing FolderID from this test, we need to adjust the code

* Remove FolderID from publicdashboard pkg

* Add back annotations test
2024-01-26 17:36:35 +02:00
Ieva
dc9e590b7b
RBAC: Return the underlying error instead of internal server or bad request for managed permission endpoints (#80974)
* return not found instead of an internal server error when listing/updating permissions

* openapi gen
2024-01-25 16:24:52 +00:00
Alexander Zobnin
3094531b63
Folders: Optimize shared folders listing (#81245)
* Folders: Expose function for getting all org folders with specific UIDs

* lint

* Fix test

* fixup

* Apply suggestion from code review

* Remove changes in alerting scheduler

* fixup

* fixup after merge with main

* Add batching

* Use strings.Builder

* Return all org folders if UIDs is empty

* Filter out not accessible folders by the user

* Remove comment

* Fix batching when count is zero

* Do not include dashboard permissions

* Add some tests

* fix test

* Use batch request for folders

* Use batch request to deduplicate folders

* Refactor

* Fix after merging main

* Refactor

---------

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
2024-01-25 13:02:32 +01:00
idafurjes
7e5544ab21
Add MFolderIDsServiceCount to count folderIDs in services pkg (#81237) 2024-01-25 11:10:35 +01:00
Sofia Papagiannaki
478d7d58fa
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
2024-01-25 11:29:56 +02:00
Sofia Papagiannaki
6e827889b4
Chore: Fix folders flaky test (#81234)
It used to wrongly assume slice ordering
2024-01-25 10:55:44 +02:00
Sofia Papagiannaki
5e88d29814
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.
2024-01-25 09:27:13 +02:00
Alexander Zobnin
7872a128a2
Folders: Add metric for listing subfolders duration (#81144) 2024-01-24 14:15:32 +01:00
Tania
07aa173939
Nested Folders: Add back syncing of folders between folder and dashboard tbls (#80972)
Add back syncing of folders between folder and dashboard tbls

This partially reverts commit 06d2ae3ada.
2024-01-22 17:04:18 +01:00
Sofia Papagiannaki
4243079cb5
Folders: Fix creating/updating a folder whose title has leading and trailing spaces (#80909)
* Add tests

* Folders: Fix creating folder whose title has leading and trailing spaces

* Fix folder update

* Remove redundant argument

* Fix test
2024-01-22 18:03:30 +02:00
Sofia Papagiannaki
bb2e0dad22
Chore: Rename folder service query variables for consistency (#80735)
Chore: Rename service query variables for consistency
2024-01-18 16:12:49 +02:00
idafurjes
cb419e799b
Remove folderid service test (#80433)
* Remove FolderID from service tests

* Add models

* Add folderID pack to publicdashboard tests

* Remove folderID from dashboard tests

* Remove folderID from folders

* Remove folderID from ngalert tests

* Remove nolint comment

* Add back some tests after rebase
2024-01-12 16:43:39 +01:00
Tania
744c1032ee
Provisioning: Fix dual write of folders (#80140)
* Provisioning: Store folders in folders table

* Solve linting issues

* Remove a comment
2024-01-10 16:48:28 +01:00
Ryan McKinley
1caaa56de0
FeatureFlags: Use interface rather than manager (#80000) 2024-01-09 10:38:06 -08:00
Tania
a62db1e24b
Nested Folders: Move SharedWithMe to the top of the folders list (#79875) 2023-12-29 11:35:15 +01:00
Sofia Papagiannaki
d89a8a3a82
Nested Folders: Fix /api/folders pagination (#79447)
* Nested Folders: Fix /api/folders pagination

We used to check access to the root folders after fetching them from the DB with pagination.
This fix splits logic for fetching folders in:
- fetching subfolders
- fetching root folders
and refactors the query for the latter so that is filters by folders with permissions

* Add tests

* Update benchmarks
2023-12-15 19:34:08 +02:00
Serge Zaitsev
06d2ae3ada
Chore: Move folder sync logic into one-shot migration (#78985)
Chore: move folder sync code into one-shot migration
2023-12-12 17:13:47 +01: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
Sofia Papagiannaki
6d4625ad52
Alerting: Fix deleting rules in a folder with matching UID in another organization (#78258)
* Remove usage of obsolete function for deleting alert rules under folder

* Apply suggestion from code review

* Update tests
2023-12-04 11:34:38 +02:00
Tania
39754ba2d6
Nested Folders: Wrap create/update operations with transactions (#78000)
* Nested Folders: Add transaction to create and update methods

* Update tests

* Make IncreaseVersionForAllRulesInNamespace synchronous

* Resolve merge conflicts
2023-11-21 23:06:20 +02: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
Tania
a9208f623a
Nested Folders: Refactor query for getting folders (#78286)
Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
2023-11-17 13:09:30 +01:00
Alexander Zobnin
5e50d9b178
Folders: Fix fetching empty folder (#78280) 2023-11-16 17:50:52 +01:00
Ieva
b0448b92e5
Dashboards: Allow updating a dashboard if the user doesn't have access to the parent folder (#78075)
* change where folder checks are done for dash creation/updates

* add test for folder not being found

* test fixes

* more test fixes

* add nlint directive to where folder IDs are used

* fix bad merge

* fix test
2023-11-16 11:11:35 +00:00
Kat Yang
d090dab138
Chore: Deprecate FolderID from SaveDashboardCommand (#77813) 2023-11-15 11:21:02 -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
Tania
1d1d42c984
Nested Folders: Decrease max nested folders depth (#78133)
* Nested Folders: Decrease allowed nested folders depth

* Fix folder height check in Move
2023-11-15 10:25:40 +01: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
Tania
6b4337a842
Nested folders: Write to folders table even if the feature toggle is off (#77788)
* Update folders table even if the feature toggle is off

* Fix failing test

* Apply review feedback

* Revert test changes
2023-11-10 13:03:00 +01:00
Alexander Zobnin
a39242890e
Folders: Able to fetch folders available for user as "shared" folder (#77774)
* 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

* Only left the base part

* Apply suggestions from code review

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

* Add tests

* Fix linter errors

---------

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
2023-11-08 15:28:49 +01:00
Yuri Tseretyan
a2629f3dd3
Alerting: Remove unused Accesscontrol dependency from DbStore (#77479) 2023-11-02 15:54:30 -04:00
Sofia Papagiannaki
dfc33a70b7
Dashboards: Fix creating dashboard under folder using deprecated API (#77501)
* Dashboards: Add integration tests for creating a dashboard

* Fix creating dashboard under folder using deprecated API

* Update swagger response

* Fix comments
2023-11-01 17:01:54 +02: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
87717849da
Chore: Deprecate FolderID in GetLibraryElementCommand (#77404) 2023-10-31 11:46:48 -04:00
Sofia Papagiannaki
03a626f1d6
Search: Fix empty folder details for nested folder items (#76504)
* Introduce dashboard.folder_uid column

* Add data migration

* Search: Fix empty folder details for nested folders

* Set `dashboard.folder_uid` and update tests

* Add unique index

* lint

Ignore cyclomatic complexity of func
`(*DashboardServiceImpl).BuildSaveDashboardCommand

* Fix search by folder UID
2023-10-24 10:04:45 +03:00
Serge Zaitsev
1d19dcd009
Chore: Update data migration to update rows that have changes (#76545)
* update data migration to update rows that have changes

* fix migration for sqlite

* remove id; fix postgres

* Fix for MySQL

* delete old items from folder table

* change integer to boolean

---------

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
2023-10-13 18:58:36 +02:00
Sofia Papagiannaki
bdeb829cf6
Revert "Nested Folders: Fix fetching a folder by title" (#76469)
Revert "Nested Folders: Fix fetching a folder by title (#74725)"

This reverts commit 0eac9aff7f.
2023-10-12 18:31:49 +03:00
kay delaney
a12cb8cbf3
LibraryPanels: Add RBAC support (#73475) 2023-10-12 00:30:50 +01:00
Jo
41bcb5e07f
Identity: Port folder library to identity.Requester (#76105)
Port folders to identity.Requester
2023-10-06 15:02:34 +02:00
Sofia Papagiannaki
0eac9aff7f
Nested Folders: Fix fetching a folder by title (#74725)
Modify folder store Get() to consider folder parent
2023-10-04 11:19:22 +03:00
Sofia Papagiannaki
376f9a75db
Folders: Do not allow modifying the folder UID via the API (#74684)
* Folders: Do not allow changing the folder UID via the API

* Update Swagger/OpenAPI docs

* Update HTTP API docs
2023-09-12 14:28:33 +03:00
linoman
0e8f19ca6a
Auth: Reduce restriction with non-user accounts (#74397)
* Reduce restrictions with non-user accounts

* Revert restrictions on anonymous accounts

* Change log level from warning to debug

* Change log messages to upper case
2023-09-06 13:37:54 +02:00