|
|
|
|
@ -239,8 +239,10 @@ func (hs *HTTPServer) getNavTree(c *models.ReqContext, hasEditPerm bool) ([]*dto |
|
|
|
|
_, uaIsDisabledForOrg := hs.Cfg.UnifiedAlerting.DisabledOrgs[c.OrgId] |
|
|
|
|
uaVisibleForOrg := hs.Cfg.UnifiedAlerting.IsEnabled() && !uaIsDisabledForOrg |
|
|
|
|
|
|
|
|
|
if setting.AlertingEnabled != nil && *setting.AlertingEnabled || uaVisibleForOrg { |
|
|
|
|
navTree = append(navTree, hs.buildAlertNavLinks(c, uaVisibleForOrg, hasEditPerm)...) |
|
|
|
|
if setting.AlertingEnabled != nil && *setting.AlertingEnabled { |
|
|
|
|
navTree = append(navTree, hs.buildLegacyAlertNavLinks()...) |
|
|
|
|
} else if uaVisibleForOrg { |
|
|
|
|
navTree = append(navTree, hs.buildAlertNavLinks(c)...) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
appLinks, err := hs.getAppLinks(c) |
|
|
|
|
@ -486,7 +488,31 @@ func (hs *HTTPServer) buildDashboardNavLinks(c *models.ReqContext, hasEditPerm b |
|
|
|
|
return dashboardChildNavs |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (hs *HTTPServer) buildAlertNavLinks(c *models.ReqContext, uaVisibleForOrg bool, hasEditPerm bool) []*dtos.NavLink { |
|
|
|
|
func (hs *HTTPServer) buildLegacyAlertNavLinks() []*dtos.NavLink { |
|
|
|
|
var alertChildNavs []*dtos.NavLink |
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{ |
|
|
|
|
Text: "Alert rules", Id: "alert-list", Url: hs.Cfg.AppSubURL + "/alerting/list", Icon: "list-ul", |
|
|
|
|
}) |
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{ |
|
|
|
|
Text: "Notification channels", Id: "channels", Url: hs.Cfg.AppSubURL + "/alerting/notifications", |
|
|
|
|
Icon: "comment-alt-share", |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
return []*dtos.NavLink{ |
|
|
|
|
{ |
|
|
|
|
Text: "Alerting", |
|
|
|
|
SubTitle: "Alert rules and notifications", |
|
|
|
|
Id: "alerting", |
|
|
|
|
Icon: "bell", |
|
|
|
|
Url: hs.Cfg.AppSubURL + "/alerting/list", |
|
|
|
|
Children: alertChildNavs, |
|
|
|
|
Section: dtos.NavSectionCore, |
|
|
|
|
SortWeight: dtos.WeightAlerting, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (hs *HTTPServer) buildAlertNavLinks(c *models.ReqContext) []*dtos.NavLink { |
|
|
|
|
hasAccess := ac.HasAccess(hs.AccessControl, c) |
|
|
|
|
var alertChildNavs []*dtos.NavLink |
|
|
|
|
|
|
|
|
|
@ -497,43 +523,35 @@ func (hs *HTTPServer) buildAlertNavLinks(c *models.ReqContext, uaVisibleForOrg b |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if hasAccess(ac.ReqOrgAdminOrEditor, ac.EvalAny(ac.EvalPermission(ac.ActionAlertingNotificationsRead), ac.EvalPermission(ac.ActionAlertingNotificationsExternalRead))) { |
|
|
|
|
if uaVisibleForOrg { |
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{ |
|
|
|
|
Text: "Contact points", Id: "receivers", Url: hs.Cfg.AppSubURL + "/alerting/notifications", |
|
|
|
|
Icon: "comment-alt-share", |
|
|
|
|
}) |
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{Text: "Notification policies", Id: "am-routes", Url: hs.Cfg.AppSubURL + "/alerting/routes", Icon: "sitemap"}) |
|
|
|
|
} else { |
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{ |
|
|
|
|
Text: "Notification channels", Id: "channels", Url: hs.Cfg.AppSubURL + "/alerting/notifications", |
|
|
|
|
Icon: "comment-alt-share", |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{ |
|
|
|
|
Text: "Contact points", Id: "receivers", Url: hs.Cfg.AppSubURL + "/alerting/notifications", |
|
|
|
|
Icon: "comment-alt-share", |
|
|
|
|
}) |
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{Text: "Notification policies", Id: "am-routes", Url: hs.Cfg.AppSubURL + "/alerting/routes", Icon: "sitemap"}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if uaVisibleForOrg && hasAccess(ac.ReqSignedIn, ac.EvalAny(ac.EvalPermission(ac.ActionAlertingInstanceRead), ac.EvalPermission(ac.ActionAlertingInstancesExternalRead))) { |
|
|
|
|
if hasAccess(ac.ReqSignedIn, ac.EvalAny(ac.EvalPermission(ac.ActionAlertingInstanceRead), ac.EvalPermission(ac.ActionAlertingInstancesExternalRead))) { |
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{Text: "Silences", Id: "silences", Url: hs.Cfg.AppSubURL + "/alerting/silences", Icon: "bell-slash"}) |
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{Text: "Alert groups", Id: "groups", Url: hs.Cfg.AppSubURL + "/alerting/groups", Icon: "layer-group"}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if c.OrgRole == models.ROLE_ADMIN && uaVisibleForOrg { |
|
|
|
|
if c.OrgRole == models.ROLE_ADMIN { |
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{ |
|
|
|
|
Text: "Admin", Id: "alerting-admin", Url: hs.Cfg.AppSubURL + "/alerting/admin", |
|
|
|
|
Icon: "cog", |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if hs.Features.IsEnabled(featuremgmt.FlagNewNavigation) { |
|
|
|
|
if uaVisibleForOrg && hasEditPerm && hasAccess(ac.ReqSignedIn, ac.EvalPermission(ac.ActionAlertingRuleCreate)) { |
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{ |
|
|
|
|
Text: "Divider", Divider: true, Id: "divider", HideFromTabs: true, |
|
|
|
|
}) |
|
|
|
|
if hs.Features.IsEnabled(featuremgmt.FlagNewNavigation) && |
|
|
|
|
hasAccess(hs.editorInAnyFolder, ac.EvalAny(ac.EvalPermission(ac.ActionAlertingRuleCreate), ac.EvalPermission(ac.ActionAlertingRuleExternalWrite))) { |
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{ |
|
|
|
|
Text: "Divider", Divider: true, Id: "divider", HideFromTabs: true, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{ |
|
|
|
|
Text: "Alert rule", SubTitle: "Create an alert rule", Id: "alert", |
|
|
|
|
Icon: "plus", Url: hs.Cfg.AppSubURL + "/alerting/new", HideFromTabs: true, ShowIconInNavbar: true, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
alertChildNavs = append(alertChildNavs, &dtos.NavLink{ |
|
|
|
|
Text: "Alert rule", SubTitle: "Create an alert rule", Id: "alert", |
|
|
|
|
Icon: "plus", Url: hs.Cfg.AppSubURL + "/alerting/new", HideFromTabs: true, ShowIconInNavbar: true, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if len(alertChildNavs) > 0 { |
|
|
|
|
@ -626,15 +644,17 @@ func (hs *HTTPServer) buildAdminNavLinks(c *models.ReqContext) []*dtos.NavLink { |
|
|
|
|
return adminNavLinks |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (hs *HTTPServer) editorInAnyFolder(c *models.ReqContext) bool { |
|
|
|
|
hasEditPermissionInFoldersQuery := models.HasEditPermissionInFoldersQuery{SignedInUser: c.SignedInUser} |
|
|
|
|
if err := hs.SQLStore.HasEditPermissionInFolders(c.Req.Context(), &hasEditPermissionInFoldersQuery); err != nil { |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
return hasEditPermissionInFoldersQuery.Result |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (hs *HTTPServer) setIndexViewData(c *models.ReqContext) (*dtos.IndexViewData, error) { |
|
|
|
|
hasAccess := ac.HasAccess(hs.AccessControl, c) |
|
|
|
|
hasEditPerm := hasAccess(func(context *models.ReqContext) bool { |
|
|
|
|
hasEditPermissionInFoldersQuery := models.HasEditPermissionInFoldersQuery{SignedInUser: c.SignedInUser} |
|
|
|
|
if err := hs.SQLStore.HasEditPermissionInFolders(c.Req.Context(), &hasEditPermissionInFoldersQuery); err != nil { |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
return hasEditPermissionInFoldersQuery.Result |
|
|
|
|
}, ac.EvalAny(ac.EvalPermission(ac.ActionDashboardsCreate), ac.EvalPermission(dashboards.ActionFoldersCreate))) |
|
|
|
|
hasEditPerm := hasAccess(hs.editorInAnyFolder, ac.EvalAny(ac.EvalPermission(ac.ActionDashboardsCreate), ac.EvalPermission(dashboards.ActionFoldersCreate))) |
|
|
|
|
|
|
|
|
|
settings, err := hs.getFrontendSettingsMap(c) |
|
|
|
|
if err != nil { |
|
|
|
|
|