From 778963849e368b05702823b54543bd6f2e61de66 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Thu, 1 Jun 2023 14:35:05 +0200 Subject: [PATCH] News: Expose config option to disable News feed (#69365) * customize news feed * remove url customisation --- conf/defaults.ini | 5 +++++ conf/sample.ini | 5 +++++ docs/sources/setup-grafana/configure-grafana/_index.md | 6 ++++++ packages/grafana-data/src/types/config.ts | 1 + packages/grafana-runtime/src/config.ts | 1 + pkg/api/dtos/frontend_settings.go | 1 + pkg/api/dtos/index.go | 3 ++- pkg/api/frontendsettings.go | 1 + pkg/api/index.go | 1 + pkg/setting/setting.go | 6 ++++++ .../app/core/components/AppChrome/TopBar/TopSearchBar.tsx | 7 +------ 11 files changed, 30 insertions(+), 7 deletions(-) diff --git a/conf/defaults.ini b/conf/defaults.ini index 43aa0183205..fcfe41414a1 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -1241,6 +1241,11 @@ enabled = true # Enable the Profile section enabled = true +#################################### News ############################# +[news] +# Enable the news feed section +news_feed_enabled = true + #################################### Query History ############################# [query_history] # Enable the Query history diff --git a/conf/sample.ini b/conf/sample.ini index 98eb8ed3df2..5d4bee32590 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -1173,6 +1173,11 @@ # Enable the Profile section ;enabled = true +#################################### News ############################# +[news] +# Enable the news feed section +; news_feed_enabled = true + #################################### Query History ############################# [query_history] # Enable the Query history diff --git a/docs/sources/setup-grafana/configure-grafana/_index.md b/docs/sources/setup-grafana/configure-grafana/_index.md index 6d405e6d655..d0d94493a2c 100644 --- a/docs/sources/setup-grafana/configure-grafana/_index.md +++ b/docs/sources/setup-grafana/configure-grafana/_index.md @@ -1656,6 +1656,12 @@ Configures the Profile section. Enable or disable the Profile section. Default is `enabled`. +## [news] + +### news_feed_enabled + +Enables the news feed section. Default is `true` + ## [query_history] Configures Query history in Explore. diff --git a/packages/grafana-data/src/types/config.ts b/packages/grafana-data/src/types/config.ts index 2b55c23bed6..12ed9138ed8 100644 --- a/packages/grafana-data/src/types/config.ts +++ b/packages/grafana-data/src/types/config.ts @@ -173,6 +173,7 @@ export interface GrafanaConfig { queryHistoryEnabled: boolean; helpEnabled: boolean; profileEnabled: boolean; + newsFeedEnabled: boolean; ldapEnabled: boolean; sigV4AuthEnabled: boolean; azureAuthEnabled: boolean; diff --git a/packages/grafana-runtime/src/config.ts b/packages/grafana-runtime/src/config.ts index 4188c0a117c..5fefab38caf 100644 --- a/packages/grafana-runtime/src/config.ts +++ b/packages/grafana-runtime/src/config.ts @@ -62,6 +62,7 @@ export class GrafanaBootConfig implements GrafanaConfig { queryHistoryEnabled = false; helpEnabled = false; profileEnabled = false; + newsFeedEnabled = true; ldapEnabled = false; jwtHeaderName = ''; jwtUrlLogin = false; diff --git a/pkg/api/dtos/frontend_settings.go b/pkg/api/dtos/frontend_settings.go index 182cc7a8370..02bd8136c65 100644 --- a/pkg/api/dtos/frontend_settings.go +++ b/pkg/api/dtos/frontend_settings.go @@ -147,6 +147,7 @@ type FrontendSettingsDTO struct { ExploreEnabled bool `json:"exploreEnabled"` HelpEnabled bool `json:"helpEnabled"` ProfileEnabled bool `json:"profileEnabled"` + NewsFeedEnabled bool `json:"newsFeedEnabled"` QueryHistoryEnabled bool `json:"queryHistoryEnabled"` GoogleAnalyticsId string `json:"googleAnalyticsId"` diff --git a/pkg/api/dtos/index.go b/pkg/api/dtos/index.go index 55cd9fc0683..b8d769c0904 100644 --- a/pkg/api/dtos/index.go +++ b/pkg/api/dtos/index.go @@ -32,5 +32,6 @@ type IndexViewData struct { CSPEnabled bool IsDevelopmentEnv bool // Nonce is a cryptographic identifier for use with Content Security Policy. - Nonce string + Nonce string + NewsFeedEnabled bool } diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go index fdee1aad3ea..f8e661348b2 100644 --- a/pkg/api/frontendsettings.go +++ b/pkg/api/frontendsettings.go @@ -123,6 +123,7 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro ExploreEnabled: setting.ExploreEnabled, HelpEnabled: setting.HelpEnabled, ProfileEnabled: setting.ProfileEnabled, + NewsFeedEnabled: setting.NewsFeedEnabled, QueryHistoryEnabled: hs.Cfg.QueryHistoryEnabled, GoogleAnalyticsId: hs.Cfg.GoogleAnalyticsID, GoogleAnalytics4Id: hs.Cfg.GoogleAnalytics4ID, diff --git a/pkg/api/index.go b/pkg/api/index.go index f61bcde5b42..b04c2c214fa 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -110,6 +110,7 @@ func (hs *HTTPServer) setIndexViewData(c *contextmodel.ReqContext) (*dtos.IndexV ThemeType: theme.Type, AppUrl: appURL, AppSubUrl: appSubURL, + NewsFeedEnabled: setting.NewsFeedEnabled, GoogleAnalyticsId: settings.GoogleAnalyticsId, GoogleAnalytics4Id: settings.GoogleAnalytics4Id, GoogleAnalytics4SendManualPageViews: hs.Cfg.GoogleAnalytics4SendManualPageViews, diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index d6bd30ba4db..642e3295a93 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -135,6 +135,9 @@ var ( // Profile UI ProfileEnabled bool + // News Feed + NewsFeedEnabled bool + // Grafana.NET URL GrafanaComUrl string @@ -1104,6 +1107,9 @@ func (cfg *Cfg) Load(args CommandLineArgs) error { profile := iniFile.Section("profile") ProfileEnabled = profile.Key("enabled").MustBool(true) + news := iniFile.Section("news") + NewsFeedEnabled = news.Key("news_feed_enabled").MustBool(true) + queryHistory := iniFile.Section("query_history") cfg.QueryHistoryEnabled = queryHistory.Key("enabled").MustBool(true) diff --git a/public/app/core/components/AppChrome/TopBar/TopSearchBar.tsx b/public/app/core/components/AppChrome/TopBar/TopSearchBar.tsx index 7843299f910..ae1529db3b3 100644 --- a/public/app/core/components/AppChrome/TopBar/TopSearchBar.tsx +++ b/public/app/core/components/AppChrome/TopBar/TopSearchBar.tsx @@ -55,7 +55,7 @@ export const TopSearchBar = React.memo(function TopSearchBar() { )} - + {config.newsFeedEnabled && } {!contextSrv.user.isSignedIn && } {profileNode && ( } placement="bottom-end"> @@ -105,9 +105,4 @@ const getStyles = (theme: GrafanaTheme2) => ({ width: '24px', }, }), - newsButton: css({ - [theme.breakpoints.down('sm')]: { - display: 'none', - }, - }), });