[release-12.0.5] Page limit config for dashboards with visible annotations (#111377)
* Page limit config for dashboards with visible annotations (#110911)
* Page limit config for dashboards with visible annotations
Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
---------
Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
(cherry picked from commit 77fa3333e4)
* Add missing parameter to TestIntegrationAuthorize
Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
---------
Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
Co-authored-by: maicon <maiconscosta@gmail.com>
This commit is contained in:
committed by
GitHub
parent
3c845fd337
commit
da3717b315
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/permissions"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/searchstore"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -28,16 +29,21 @@ var (
|
||||
)
|
||||
|
||||
type AuthService struct {
|
||||
db db.DB
|
||||
features featuremgmt.FeatureToggles
|
||||
dashSvc dashboards.DashboardService
|
||||
db db.DB
|
||||
features featuremgmt.FeatureToggles
|
||||
dashSvc dashboards.DashboardService
|
||||
searchDashboardsPageLimit int64
|
||||
}
|
||||
|
||||
func NewAuthService(db db.DB, features featuremgmt.FeatureToggles, dashSvc dashboards.DashboardService) *AuthService {
|
||||
func NewAuthService(db db.DB, features featuremgmt.FeatureToggles, dashSvc dashboards.DashboardService, cfg *setting.Cfg) *AuthService {
|
||||
section := cfg.Raw.Section("annotations")
|
||||
searchDashboardsPageLimit := section.Key("search_dashboards_page_limit").MustInt64(1000)
|
||||
|
||||
return &AuthService{
|
||||
db: db,
|
||||
features: features,
|
||||
dashSvc: dashSvc,
|
||||
db: db,
|
||||
features: features,
|
||||
dashSvc: dashSvc,
|
||||
searchDashboardsPageLimit: searchDashboardsPageLimit,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +148,7 @@ func (authz *AuthService) dashboardsWithVisibleAnnotations(ctx context.Context,
|
||||
SignedInUser: query.SignedInUser,
|
||||
Page: query.Page,
|
||||
Type: filterType,
|
||||
Limit: 1000,
|
||||
Limit: authz.searchDashboardsPageLimit,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -207,7 +207,7 @@ func TestIntegrationAuthorize(t *testing.T) {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
u.Permissions = map[int64]map[string][]string{1: tc.permissions}
|
||||
testutil.SetupRBACPermission(t, sql, role, u)
|
||||
authz := NewAuthService(sql, featuremgmt.WithFeatures(tc.featureToggle), dashSvc)
|
||||
authz := NewAuthService(sql, featuremgmt.WithFeatures(tc.featureToggle), dashSvc, cfg)
|
||||
|
||||
query := annotations.ItemQuery{SignedInUser: u, OrgID: 1}
|
||||
resources, err := authz.Authorize(context.Background(), query)
|
||||
|
||||
Reference in New Issue
Block a user