Chore: Move ReqContext to contexthandler service (#62102)
* Chore: Move ReqContext to contexthandler service * Rename package to contextmodel * Generate ngalert files * Remove unused imports
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
@@ -22,9 +22,9 @@ var (
|
||||
AdminAccessEvaluator = ac.EvalAny(ac.EvalPermission(ActionWrite), ac.EvalPermission(ActionInstall))
|
||||
)
|
||||
|
||||
func ReqCanAdminPlugins(cfg *setting.Cfg) func(rc *models.ReqContext) bool {
|
||||
func ReqCanAdminPlugins(cfg *setting.Cfg) func(rc *contextmodel.ReqContext) bool {
|
||||
// Legacy handler that protects access to the Configuration > Plugins page
|
||||
return func(rc *models.ReqContext) bool {
|
||||
return func(rc *contextmodel.ReqContext) bool {
|
||||
return rc.OrgRole == org.RoleAdmin || cfg.PluginAdminEnabled && rc.IsGrafanaAdmin
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,10 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/plugins/manager/client"
|
||||
"github.com/grafana/grafana/pkg/services/contexthandler/ctxkey"
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -130,7 +130,7 @@ type ClientDecoratorTest struct {
|
||||
TestClient *TestClient
|
||||
Middlewares []plugins.ClientMiddleware
|
||||
Decorator *client.Decorator
|
||||
ReqContext *models.ReqContext
|
||||
ReqContext *contextmodel.ReqContext
|
||||
QueryDataReq *backend.QueryDataRequest
|
||||
QueryDataCtx context.Context
|
||||
CallResourceReq *backend.CallResourceRequest
|
||||
@@ -181,7 +181,7 @@ func NewClientDecoratorTest(t *testing.T, opts ...ClientDecoratorTestOption) *Cl
|
||||
func WithReqContext(req *http.Request, user *user.SignedInUser) ClientDecoratorTestOption {
|
||||
return ClientDecoratorTestOption(func(cdt *ClientDecoratorTest) {
|
||||
if cdt.ReqContext == nil {
|
||||
cdt.ReqContext = &models.ReqContext{
|
||||
cdt.ReqContext = &contextmodel.ReqContext{
|
||||
Context: &web.Context{},
|
||||
SignedInUser: user,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user