Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

News: Expose config option to disable News feed #69365

Merged
merged 2 commits into from Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions conf/defaults.ini
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions conf/sample.ini
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions docs/sources/setup-grafana/configure-grafana/_index.md
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions packages/grafana-data/src/types/config.ts
Expand Up @@ -173,6 +173,7 @@ export interface GrafanaConfig {
queryHistoryEnabled: boolean;
helpEnabled: boolean;
profileEnabled: boolean;
newsFeedEnabled: boolean;
ldapEnabled: boolean;
sigV4AuthEnabled: boolean;
azureAuthEnabled: boolean;
Expand Down
1 change: 1 addition & 0 deletions packages/grafana-runtime/src/config.ts
Expand Up @@ -62,6 +62,7 @@ export class GrafanaBootConfig implements GrafanaConfig {
queryHistoryEnabled = false;
helpEnabled = false;
profileEnabled = false;
newsFeedEnabled = true;
ldapEnabled = false;
jwtHeaderName = '';
jwtUrlLogin = false;
Expand Down
1 change: 1 addition & 0 deletions pkg/api/dtos/frontend_settings.go
Expand Up @@ -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"`
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/dtos/index.go
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions pkg/api/frontendsettings.go
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions pkg/api/index.go
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions pkg/setting/setting.go
Expand Up @@ -135,6 +135,9 @@ var (
// Profile UI
ProfileEnabled bool

// News Feed
NewsFeedEnabled bool

// Grafana.NET URL
GrafanaComUrl string

Expand Down Expand Up @@ -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)

Expand Down
Expand Up @@ -55,7 +55,7 @@ export const TopSearchBar = React.memo(function TopSearchBar() {
<ToolbarButton iconOnly icon="question-circle" aria-label="Help" />
</Dropdown>
)}
<NewsContainer className={styles.newsButton} />
{config.newsFeedEnabled && <NewsContainer />}
{!contextSrv.user.isSignedIn && <SignInLink />}
{profileNode && (
<Dropdown overlay={() => <TopNavBarMenu node={profileNode} />} placement="bottom-end">
Expand Down Expand Up @@ -105,9 +105,4 @@ const getStyles = (theme: GrafanaTheme2) => ({
width: '24px',
},
}),
newsButton: css({
[theme.breakpoints.down('sm')]: {
display: 'none',
},
}),
});