Use OpenFeature provider (#102116)
* Migrate pinNavItems to open feature * Use Boolean method instead of BooleanValue
This commit is contained in:
@@ -23,6 +23,8 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/star"
|
||||
"github.com/grafana/grafana/pkg/services/supportbundles/supportbundlesimpl"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
|
||||
"github.com/open-feature/go-sdk/openfeature"
|
||||
)
|
||||
|
||||
type ServiceImpl struct {
|
||||
@@ -34,6 +36,7 @@ type ServiceImpl struct {
|
||||
pluginSettings pluginsettings.Service
|
||||
starService star.Service
|
||||
features featuremgmt.FeatureToggles
|
||||
openFeature *featuremgmt.OpenFeatureService
|
||||
dashboardService dashboards.DashboardService
|
||||
accesscontrolService ac.Service
|
||||
kvStore kvstore.KVStore
|
||||
@@ -54,7 +57,7 @@ type NavigationAppConfig struct {
|
||||
|
||||
func ProvideService(cfg *setting.Cfg, accessControl ac.AccessControl, pluginStore pluginstore.Store, pluginSettings pluginsettings.Service, starService star.Service,
|
||||
features featuremgmt.FeatureToggles, dashboardService dashboards.DashboardService, accesscontrolService ac.Service, kvStore kvstore.KVStore, apiKeyService apikey.Service,
|
||||
license licensing.Licensing, authnService authn.Service) navtree.Service {
|
||||
license licensing.Licensing, authnService authn.Service, openFeature *featuremgmt.OpenFeatureService) navtree.Service {
|
||||
service := &ServiceImpl{
|
||||
cfg: cfg,
|
||||
log: log.New("navtree service"),
|
||||
@@ -64,6 +67,7 @@ func ProvideService(cfg *setting.Cfg, accessControl ac.AccessControl, pluginStor
|
||||
pluginSettings: pluginSettings,
|
||||
starService: starService,
|
||||
features: features,
|
||||
openFeature: openFeature,
|
||||
dashboardService: dashboardService,
|
||||
accesscontrolService: accesscontrolService,
|
||||
kvStore: kvStore,
|
||||
@@ -80,6 +84,7 @@ func ProvideService(cfg *setting.Cfg, accessControl ac.AccessControl, pluginStor
|
||||
func (s *ServiceImpl) GetNavTree(c *contextmodel.ReqContext, prefs *pref.Preference) (*navtree.NavTreeRoot, error) {
|
||||
hasAccess := ac.HasAccess(s.accessControl, c)
|
||||
treeRoot := &navtree.NavTreeRoot{}
|
||||
ctx := c.Req.Context()
|
||||
|
||||
treeRoot.AddSection(s.getHomeNode(c, prefs))
|
||||
|
||||
@@ -184,7 +189,8 @@ func (s *ServiceImpl) GetNavTree(c *contextmodel.ReqContext, prefs *pref.Prefere
|
||||
treeRoot.RemoveSectionByID(navtree.NavIDCfg)
|
||||
}
|
||||
|
||||
if s.features.IsEnabled(c.Req.Context(), featuremgmt.FlagPinNavItems) && c.IsSignedIn {
|
||||
enabled := s.openFeature.Client.Boolean(ctx, featuremgmt.FlagPinNavItems, true, openfeature.TransactionContext(ctx))
|
||||
if enabled && c.IsSignedIn {
|
||||
treeRoot.AddSection(&navtree.NavLink{
|
||||
Text: "Bookmarks",
|
||||
Id: navtree.NavIDBookmarks,
|
||||
|
||||
Reference in New Issue
Block a user