feat(investigations): add "Investigations" menu if loop enabled (#111462)
* feat(investigations): add "Investigations" menu if loop enabled * feat(investigations): move to `shouldIncludeInvestigations` * feat(investigations): add issue link
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user