Commit Graph

2649 Commits

Author SHA1 Message Date
Will Browne
f7cce28cdf
Plugins: Separate manager read/write components (#50313)
* separate manager read/write

* guarantee consistency in test
2022-06-07 17:51:00 +02:00
Dan Cech
9350ab781c
clean up duplicated user creation code (#50178)
* clean up duplicated user creation code

* remove unused duplicate getOrCreateOrg function

* fix up tests
2022-06-07 09:49:18 -04:00
Karl Persson
c4a75f9eb3
RBAC: Add scope resolvers for dashboards (#50110)
* Inject access control into dashboard service

* Add function to parse id scopes

* Add dashboard as return value

* Update mock

* Return only err to keep service interface

* Add scope resolvers for dashboard id scopes

* Add function to parse uid scopes

* Add dashboard uid scope resolver

* Register scope resolvers for dashboards

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2022-06-07 11:02:20 +02:00
sam boyer
8876d56495
schema: Migrate from scuemata to thema (#49805)
* Remove crufty scuemata bits

Buhbye to: cue/ dir with old definitions, CI steps for checking unnecessary
things, and the original dashboard scuemata file.

* Remove grafana-cli cue subcommand

* Remove old testdata

* Don't swallow errors from codegen

* Small nits and tweaks to cuectx package

* WIP - refactor pluggen to use Thema

Also consolidate the embed.FS in the repo root.

* Finish halfway rename

* Convert all panel models.cue to thema

* Rewrite pluggen to use Thema

* Remove pkg/schema, and trim command

* Remove schemaloader service and usages

Will be replaced by coremodel-centric hydrate/dehydrate system Soon™.

* Remove schemaloader from wire

* Remove hangover field on histogram models.cue

* Fix lint errors, some vestiges of trim service

* Remove unused cuetsify cli command
2022-06-06 17:52:44 -07:00
owensmallwood
e7d6a58037
Owensmallwood/pubdash get public dashboard definition (#50269)
* When getting a public dashboard, backend returns a response structured the same as when you get a regular dashboard

* Updates backend tests for getting public dashboard

* Frontend can load the public dashboard based on the pubdash uid provided

* adds frontend test to make sure public dashboard doesnt render toolbar and submenu

* sorts imports
2022-06-06 16:19:34 -06:00
Kat Yang
31630edf0c
Chore: Remove Wrapf (#50128)
* Chore: Remove Wrapf

* Remove all Wrapf refs

* Remove last Wrapf ref

* Fix lint errors

* Remove Wrap and Wrapf definitions

* Remove unnecessary colon
2022-06-06 22:30:31 +02:00
Alexander Emelin
d2868a1ce7
SearchV2: instant local updates, folder events (#50001) 2022-06-03 13:11:32 -07:00
Marcus Efraimsson
36c3398c6d
Datasource: Remove support for unencrypted passwords (#49987)
* Datasource: Remove support for unencrypted passwords

* regenerate swagger

* [WIP] Remove references to datasource password and basic auth password fields (#50015)

* try delete moar tings

* delete provisioning stuff

* remove from yaml

* update snapshots

* remove lingering snapshot fields

* fix ds http settings

* Re-generate swagger and fix swagger-api-spec make target

Co-authored-by: Will Browne <will.browne@grafana.com>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2022-06-03 17:38:22 +02:00
Alex Khomenko
d3adc42e6e
Service accounts: Use new icon (#50140) 2022-06-03 11:23:19 +03:00
Kat Yang
3c3039f5b3
Chore: Remove Wrap (#50048)
* Chore: Remove Wrap and Wrapf

* Fix: Add error check
2022-06-03 09:24:24 +02:00
Jeff Levin
52ed651958
public dashboards: insert default public dashboard config into database on save (#49131)
This PR adds endpoints for saving and retrieving a public dashboard configuration and and api endpoint to retrieve the public dashboard.

All of this is highly experimental and APIs will change. Notably, we will be removing isPublic from the dashboard model and moving it over to the public dashboard table in the next release.

Further context can be found here: https://github.com/grafana/grafana/pull/49131#issuecomment-1145456952
2022-06-02 18:27:23 -08:00
owensmallwood
cfdea1ee30
PublicDashboards: Frontend routing for public dashboards (#48834)
* add isPublic to dashboard

* refactor routes to use route group and add placeholder method for sharing apii

* add sharing pane and utils for public dashboard config to sharing modal

* Sharing modal now persists data through the api

* moves ShareDashboard endpoint to new file and starts adding tests

* generates mocks. Adds tests for public dashboard feature flag

* Adds ability to pass in array of features to enable for the test

* test to update public flag on dashboard WIP

* Adds mock for SaveDashboardSharingConfig

* Fixes tests. Had to use FakeDashboardService

* Adds React tests for public dashboards toggle

* removes semicolons

* refactors SharePublic component to use hooks

* rename from `share publicly` to `public dashboard config`

* checkpoint. debugging tests. need to verify name changes

* checkpoint. test bugs fixed. need to finish returning proper response codes

* finish renaming. fix test

* Update pkg/api/api.go

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>

* update backend url

* rename internal objects and commands. fix configuration modal labels

* add endpoint for retrieving public dashboard configuration and populate the frontend state from it

* add test for dashboardCanBePublic

* adds backend routes

* copy DashboardPage component into component for public dashboards. WIP

* adds react routes, and doesnt render main nav bar when viewing a public route

* removes extra react route from testing

* updates component name

* Wrap the original dashboard component so we can pass props relevant to public dashboards, turn kiosk mode on/off, etc

* Wraps DashboardPage in PublicDashboardPage component. DashboardPage gets rendered in kiosk mode when public prop is passed.

* removes commented out code from exploratory work

* Makes public dashboard routes require no auth

* extracts helper to own util file to check if were viewing a public page

* Hides panel dropdown when its being viewed publicly

* formatting

* use function from utils file for determining if publicly viewed. If public, hides app notifications, searchwrapper, and commandpalette.

* adds unit tests for util function used to see if page is being viewed publicly

* cant added annotations to panel when being publicly viewed

* removes useless comment

* hides backend and frontend pubdash routes behind feature flag

* consider feature flag when checking url path to see if on public dashboard

* renames function

* still render app notifications when in public view

* Extract pubdash route logic into own file

* fixes failing tests

* Determines path using location locationUtils. This covers the case when grafana is being hosted on a subpath. Updates tests.

* renames pubdash web route to be more understandable

* rename route

* fixes failing test

* fixes failing test. Needed to update pubdash urls

* sets flag on grafana boot config for if viewing public dashboard. Removes hacky check that looks at the url

* fixes failing tests. Uses config to determine if viewing public dashboard

* renders the blue panel timeInfo on public dashboard panel

* Extracts conditional logic for rendering components out into their own functions

* removes publicDashboardView check, and uses dashboard meta instead

* the timeInfo is always displayed on the panel

* After fetch of public dashboard dto, the meta isPublic flag gets set and used to determine if viewing public dashboard for child components. Fixes tests for PanelHeader.

* Fixes failing test. Needed to add isPublic flag to dashboard meta.

Co-authored-by: Jeff Levin <jeff@levinology.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2022-06-02 14:57:55 -06:00
Ryan McKinley
d452322aa8
Search (SQL): support dashboardUID query parameter (#50121) 2022-06-02 12:56:01 -07:00
Kristin Laemmert
0e991461b0
backend/sqlstore: move GetDashboardTags to dashboard service (#50091)
+ removing some functions that were already copied to the dashboard service in a previous pr.
2022-06-02 10:00:47 -04:00
idafurjes
bdf50f3dd2
Dashboards: Split GetDashboardVersions method (#49967)
* Split GetDashboarVersions method

* Add sqlstore dialect and tests

* Fix signature of PAtchPreference

* Add GetDialect to sqlstore and remove GetDashboardVersions

* Add GetDialect to db interface

* Implement List

* add deleted test function

* Remove GetDialect from sqlstore interface

* Remove deleted method from mock

* Refactor test
2022-06-02 15:59:05 +02:00
Emil Tullstedt
3e81fa0716
API: Migrate CSRF to service and support additional options (#48120)
* API: Migrate CSRF to service and support additional options

* minor

* public Csrf service to use in tests

* WIP

* remove fmt

* comment

* WIP

* remove fmt prints

* todo add prefix slash

* remove fmt prints

* linting fix

* remove trimPrefix

Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>
Co-authored-by: IevaVasiljeva <ieva.vasiljeva@grafana.com>
2022-06-02 15:52:30 +02:00
Ieva
5dbea9996b
RBAC: Make RBAC action names more consistent (#49730)
* update action names

* correctly retrieve teams for signed in user

* remove test

* undo swagger changes

* undo swagger changes pt2

* add migration from old action names to the new ones

* rename from list to read

* linting

* also update alertign actions

* fix migration
2022-06-02 13:14:48 +01:00
Sofia Papagiannaki
6112bd0c63
API: Fix swagger specification (#50034)
* API: Fix swagger specification

* Validate specification after generation
2022-06-02 10:49:52 +03:00
Kristin Laemmert
2edfbb7767
sqlstore split: dashboard permissions (#49962)
* backend/sqlstore split: remove unused GetDashboardPermissionsForUser from sqlstore
* remove debugging line
* backend/sqlstore: move dashboard permission related functions to dashboard service
2022-06-01 14:16:26 -04:00
Will Browne
abfc711c53
Plugins: Remove deprecated /api/tsdb/query metrics endpoint (#49916)
* remove /api/tsdb/query

* revert changes to alert rules

* regenerate spec based on 9.0.x
2022-06-01 13:05:15 +02:00
Alexander Zobnin
50538d5309
ServiceAccounts: refactor UI (#49508)
* ServiceAccounts: refactor ServiceAccountRoleRow

* Refactor ServiceAccountRoleRow

* Refactor ServiceAccountProfile

* Refactor components

* Change service accounts icon

* Refine service accounts page header

* Improve service accounts filtering

* Change delete button style

* Tweak account id

* Auto focus name field when create service account

* Add disable/enable button

* Enable/disable service accounts

* Optimize updating service account (do not fetch all)

* Remove status column (replace by enable/disable button)

* Add banner with service accounts description

* Add tokens from main page

* Update tokens count when add token from main page

* Fix action buttons column

* Fix tokens count when change role

* Refine table row classes

* Fix buttons

* Simplify working with state

* Show message when service account updated

* Able to filter disabled accounts

* Mark disabled accounts in a table

* Refine disabled account view

* Move non-critical components to separate folder

* Remove confusing focusing

* Fix date picker position when creating new token

* DatePicker: able to set minimum date that can be selected

* Don't allow to select expiration dates prior today

* Set tomorrow as a default token expiration date

* Fix displaying expiration period

* Rename Add token button

* Refine page styles

* Show modal when disabling SA from main page

* Arrange role picker

* Refine SA page styles

* Generate default token name

* More smooth navigation between SA pages

* Stop loading indicator in case of error

* Remove legacy styles usage

* Tweaks after code review

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>

* Get rid of useDisapatch in favor of mapDispatchToProps

* Tests for ServiceAccountsListPage

* Tests for service account page

* Show new role picker only with license

* Get rid of deprecated css classes

* Apply suggestion from code review

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>

* Fix service accounts icon

* Tests for service account create page

* Return service account info when update

* Add behaviour tests for ServiceAccountsListPage

* Fix disabled cursor on confirm button

* More behavior tests for service account page

* Temporary disable service account migration banner

* Use safe where condition

Co-authored-by: Jguer <joao.guerreiro@grafana.com>

* Apply review suggestions

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>

* Remove autofocus from search

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-06-01 09:35:16 +02:00
Marcus Efraimsson
a7813275a5
Plugins: Support headers field for check health (#49930) 2022-05-31 17:58:06 +02:00
Marcus Efraimsson
1196b4a609
Datasource: Fix allowed cookies to be forwarded as header to backend datasources (#49541)
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2022-05-31 17:02:58 +02:00
Ivana Huckova
e25a49ff49
Preferences: Fix updating of preferences for Navbar and Query History (#49677)
* Preferences: Fix PUT for Navbar and Query History

* Update linting

* Fix linting

* Use models defined in preference package in preferences

* Remove white space

* Revert "Use models defined in preference package in preferences"

This reverts commit 6f7aa9f8d3.
2022-05-26 14:39:57 +02:00
Vardan Torosyan
93f9792199
Quick Ugly Fix for Oauth not to make web_hack.go panic (#49653) 2022-05-26 14:34:04 +02:00
Ashley Harrison
8b509eb6dd
Notification history: Enable by default (#49502)
* remove persistNotifications feature flag

* remove unused imports
2022-05-26 12:03:04 +01:00
Alexander Zobnin
9b61d9eb1c
Fix wrap_handler() panic during OAuth login (#49671) 2022-05-26 12:18:18 +02:00
Maria Alexandra
7ed368ecc6
SearchV2 - Fix starred dashboards for new organizations error (#49645)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2022-05-25 20:57:18 +02:00
Karl Persson
5caf97be40
AccessControl: Replace IsEnterprise checks with license checks (#49572) 2022-05-25 20:40:41 +02:00
Yuriy Tseretyan
307c207a24
show notification tab only to editor (#49624) 2022-05-25 12:13:49 -04:00
Peter Holmberg
e3a51a4aa8
Alerting: Add legacy indicator to navbar (#49511)
* update id and add translation key

* remove logs
2022-05-25 15:30:37 +02:00
Karl Persson
1796a1d277
AccessControl: Grant data source reader to all users when running oss (#49514)
* grant data source reader to all users when running oss or enterprise
without license

* fix asserts in alerting tests

* add oss licensing service for test setup

* fix tests to pass in enterprise

* lint

* fix tests

* set setting.IsEnterprise flag for tests

Co-authored-by: Yuriy Tseretyan <yuriy.tseretyan@grafana.com>
2022-05-25 13:43:58 +02:00
idafurjes
b07904fe56
Add store split for Get Dashboard version method (#49138)
* Add store split for Get Dashboard version method

* Implement dashboard version service

* Fix api tests

* Remove GetDashboarVersion from sqlstore

* Add fakes for Get dashboard version

* Fix sqlstore test

* Add Get Dashboard store test

* Add dashver service test

* Remove useless comments
2022-05-25 10:41:51 +02:00
sh0rez
3ca3a59079
pkg/web: remove dependency injection (#49123)
* pkg/web: store http.Handler internally

* pkg/web: remove injection

Removes any injection code from pkg/web.

It already was no longer functional, as we already only injected into
`http.Handler`, meaning we only inject ctx.Req and ctx.Resp.

Any other types (*Context, *ReqContext) were already accessed using the
http.Request.Context.Value() method.

* *: remove type mappings

Removes any call to the previously removed TypeMapper, as those were
non-functional already.

* pkg/web: remove Context.Invoke

was no longer used outside of pkg/web and also no longer functional
2022-05-24 15:35:08 -04:00
Ashley Harrison
ce86b4ebe7
Navigation: Show starred items in the NavBar (#49219)
* switch saved items to starred items

* hook up redux properly

* Better query + hook up DashList

* update initial state so it's never undefined

* update GetDashboard call

* use new star service

* add scroll + maxwidth to navbar hover menu, sort starred items alphabetically

* increase height, revert changes to CustomScrollbar

* ellipsis!

* update starred dashboard name in navtree

* sort after renaming

* limit to first 50 starred dashboards found
2022-05-23 16:45:46 +01:00
Kristin Laemmert
8c753999df
chore: replace artisanal FakeDashboardService with generated mock (#49276)
* chore: replace handmade FakeDashboardService with generated mock

Maintaining a handcrafted FakeDashboardService is not sustainable now that we are in the process of moving the dashboard-related functions out of sqlstore.

* remove dialect global variable
2022-05-23 11:14:27 -04:00
Sofia Papagiannaki
060af782df
Docs: Add deprecation notices for datasource endpoints (#49411)
* Update markdown

* Update swagger
2022-05-23 16:11:47 +02:00
Sofia Papagiannaki
be0d043673
API: Add endpoint for updating a data source by its UID (#49396)
* API: Add endpoint for updating a data source by UID

* Update docs markdown

* Update swagger

* Apply suggestions from code review

Co-authored-by: Selene <selenepinillos@gmail.com>
2022-05-23 15:13:13 +02:00
Joan López de la Franca Beltran
e43879e55d
Encryption: Add support for multiple data keys per day (#47765)
* Add database migrations

* Use short uids as data key ids

* Add support for manual data key rotation

* Fix duplicated mutex unlocks

* Fix migration

* Manage current data keys per name

* Adjust key re-encryption and test

* Modify rename column migration for MySQL compatibility

* Refactor secrets manager and data keys cache

* Multiple o11y adjustments

* Fix stats query

* Apply suggestions from code review

Co-authored-by: Tania <yalyna.ts@gmail.com>

* Fix linter

* Docs: Rotate data encryption keys API endpoint

Co-authored-by: Tania <yalyna.ts@gmail.com>
2022-05-23 13:13:55 +02:00
Ashley Harrison
ae8c11bfa4
Tweak name + add description (#49387) 2022-05-23 10:52:52 +01:00
idafurjes
cc0448927a
Add TraceID to data proxy logs (#49302) 2022-05-23 10:38:05 +02:00
sam boyer
a3402641d6
api: Validate dashboards on save via coremodels, behind feature toggle (#48252)
* Add coremodelValidation feature flag

* coremodels: use stubs when feature flag is off

* api: validate dashboards on save

* Need pointer receiver for FeatureManager

* Update dashboard Go model

* Align doc comments

* Include CoremodelRegistry in test

* Wedge coremodel in on all test cases, ugh

* Ugh fix comment again

* Update pkg/framework/coremodel/staticregistry/provide.go

Co-authored-by: Artur Wierzbicki <wierzbicki.artur.94@gmail.com>

* Update Thema (and its deps) for better errs

* omg whitespace

Co-authored-by: Artur Wierzbicki <wierzbicki.artur.94@gmail.com>
2022-05-22 02:44:12 +02:00
sh0rez
3d5d8c785b
pkg/web: restrict handler types (#48495)
Makes `pkg/web` only accept handles from the following set:

```go
	handlerStd       = func(http.ResponseWriter, *http.Request)
	handlerStdCtx    = func(http.ResponseWriter, *http.Request, *web.Context)
	handlerStdReqCtx = func(http.ResponseWriter, *http.Request, *models.ReqContext)
	handlerReqCtx    = func(*models.ReqContext)
	handlerReqCtxRes = func(*models.ReqContext) Response
	handlerCtx       = func(*web.Context)
```

This is a first step to reducing above set to only `http.Handler`.

---

Due to a cyclic import situation between `pkg/models` and `pkg/web`, parts of this PR were put into `pkg/api/response`, even though they definitely do not belong there. This however is _temporary_ until we untangle `models.ReqContext`.
2022-05-20 12:45:18 -04:00
Karl Persson
f5ec4bcbd2
remove action to manage plugin that is not used or documented (#49309) 2022-05-20 11:52:29 +02:00
Gabriel MABILLE
689f51599a
AccessControl: Use RBACBuiltInRoleAssignmentEnabled in the frontend instead of FeatureToggle (#49261)
* AccessControl: Frontend changes to basic role enablement
2022-05-20 06:53:28 +00:00
Sofia Papagiannaki
6bb843bd0e
API: Introduce health and resources data source endpoints using the data source UID (#48676)
* API: introduce health and resources datasource endpoints with UID

* Document endpoints

* Update swagger
2022-05-19 19:27:59 +03:00
Kristin Laemmert
33359aee6c
backend/sqlstore: move GetDashboards to Dashboard Service (#49175)
I also did some mild file renaming to try and get the dashboards package closer in line with the sqlstore split design doc.
2022-05-19 10:59:12 -04:00
Kristin Laemmert
2b8909a9c6
move GetDashboardUIDById out of sqlstore and into dashboard service (#49170)
* sqlstore: move GetDashboardUIDById to dashboard service
* winding change through the rest of the codebase
2022-05-19 10:13:02 -04:00
Yuriy Tseretyan
f7f2253072
Alerting: Fix anonymous access to alerting (#49203)
* introduce a fallback handler that checks that role is Viewer.
* update UI nav links to allow alerting tabs for anonymous user
* update rule api to check for Viewer role instead of SignedIn when RBAC is disabled
2022-05-19 09:22:26 -04:00
ying-jeanne
e2ea064584
integrat star service into APIs (#49220) 2022-05-19 14:32:10 +02:00