diff --git a/pkg/services/navtree/navtreeimpl/applinks.go b/pkg/services/navtree/navtreeimpl/applinks.go index 0cc24694b96..e009b7bc196 100644 --- a/pkg/services/navtree/navtreeimpl/applinks.go +++ b/pkg/services/navtree/navtreeimpl/applinks.go @@ -75,6 +75,35 @@ func (s *ServiceImpl) addAppLinks(treeRoot *navtree.NavTreeRoot, c *contextmodel return nil } +// shouldIncludeInvestigations checks if the investigations feature should be included for the assistant app +// see https://github.com/grafana/grafana-assistant-app/issues/2007 for more details +func (s *ServiceImpl) shouldIncludeInvestigations(plugin pluginstore.Plugin, include *plugins.Includes, c *contextmodel.ReqContext) bool { + if plugin.ID != "grafana-assistant-app" || include.Name != "Investigations" { + return true + } + + ps, err := s.pluginSettings.GetPluginSettingByPluginID(c.Req.Context(), &pluginsettings.GetByPluginIDArgs{ + PluginID: plugin.ID, + OrgID: c.GetOrgID(), + }) + if err != nil { + return false + } + + loopData, exists := ps.JSONData["loop"] + if !exists { + return false + } + + loopConfig, ok := loopData.(map[string]any) + if !ok { + return false + } + + enabled, ok := loopConfig["enabled"].(bool) + return ok && enabled +} + func (s *ServiceImpl) processAppPlugin(plugin pluginstore.Plugin, c *contextmodel.ReqContext, treeRoot *navtree.NavTreeRoot) *navtree.NavLink { hasAccessToInclude := s.hasAccessToInclude(c, plugin.ID) appLink := &navtree.NavLink{ @@ -93,6 +122,10 @@ func (s *ServiceImpl) processAppPlugin(plugin pluginstore.Plugin, c *contextmode continue } + if !s.shouldIncludeInvestigations(plugin, include, c) { + continue + } + if include.Type == "page" { link := &navtree.NavLink{ Text: include.Name,