From 9862c9ff40a345c687b7fc8bcf30e54fcac56bc0 Mon Sep 17 00:00:00 2001 From: smalik Date: Fri, 20 Jan 2017 10:43:29 -0500 Subject: [PATCH] feat(alerting): Show/hide alerting UI using configuration variable Use configuration variable "show_alerting_ui" to show/hide alerting UI --- conf/defaults.ini | 1 + pkg/api/frontendsettings.go | 1 + pkg/api/index.go | 2 +- pkg/setting/setting.go | 4 +++- public/app/plugins/panel/graph/module.ts | 4 +++- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/conf/defaults.ini b/conf/defaults.ini index 81d6c8d8050..5bceb0a651e 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -397,6 +397,7 @@ global_session = -1 [alerting] # Makes it possible to turn off alert rule execution. execute_alerts = true +show_alerting_ui = true #################################### Internal Grafana Metrics ############ # Metrics available at HTTP API Url /api/metrics diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go index 1fd4cd347e7..c4b15ac54b6 100644 --- a/pkg/api/frontendsettings.go +++ b/pkg/api/frontendsettings.go @@ -140,6 +140,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro "allowOrgCreate": (setting.AllowUserOrgCreate && c.IsSignedIn) || c.IsGrafanaAdmin, "authProxyEnabled": setting.AuthProxyEnabled, "ldapEnabled": setting.LdapEnabled, + "showAlertingUI": setting.ShowAlertingUI, "buildInfo": map[string]interface{}{ "version": setting.BuildVersion, "commit": setting.BuildCommit, diff --git a/pkg/api/index.go b/pkg/api/index.go index 715baefae78..172f98d4fb2 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -103,7 +103,7 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { Children: dashboardChildNavs, }) - if c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR { + if setting.ShowAlertingUI && (c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR) { alertChildNavs := []*dtos.NavLink{ {Text: "Alert List", Url: setting.AppSubUrl + "/alerting/list"}, {Text: "Notification channels", Url: setting.AppSubUrl + "/alerting/notifications"}, diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 5189d28b445..16cfb48dcd1 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -149,7 +149,8 @@ var ( Quota QuotaSettings // Alerting - ExecuteAlerts bool + ExecuteAlerts bool + ShowAlertingUI bool // logger logger log.Logger @@ -573,6 +574,7 @@ func NewConfigContext(args *CommandLineArgs) error { alerting := Cfg.Section("alerting") ExecuteAlerts = alerting.Key("execute_alerts").MustBool(true) + ShowAlertingUI = alerting.Key("show_alerting_ui").MustBool(true) readSessionConfig() readSmtpSettings() diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index d86212d33e6..99476598bf4 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -132,7 +132,9 @@ class GraphCtrl extends MetricsPanelCtrl { this.addEditorTab('Axes', axesEditorComponent, 2); this.addEditorTab('Legend', 'public/app/plugins/panel/graph/tab_legend.html', 3); this.addEditorTab('Display', 'public/app/plugins/panel/graph/tab_display.html', 4); - this.addEditorTab('Alert', alertTab, 5); + if (config.showAlertingUI) { + this.addEditorTab('Alert', alertTab, 5); + } this.subTabIndex = 0; }