From a79c048344bddff7a868b040d9a08953917480f9 Mon Sep 17 00:00:00 2001 From: Alex Khomenko Date: Thu, 3 Feb 2022 13:53:23 +0200 Subject: [PATCH] Feature Highlights: move setting to a feature toggle (#44780) * Add toggle * Use the toggle * Cleanup --- docs/sources/enterprise/enterprise-configuration.md | 6 ------ packages/grafana-data/src/types/featureToggles.gen.ts | 1 + pkg/api/frontendsettings.go | 3 --- pkg/services/featuremgmt/registry.go | 5 +++++ pkg/services/featuremgmt/toggles_gen.go | 4 ++++ public/app/features/datasources/state/navModel.ts | 8 ++++---- public/app/features/teams/TeamPages.tsx | 2 +- public/app/features/teams/state/navModel.ts | 2 +- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/docs/sources/enterprise/enterprise-configuration.md b/docs/sources/enterprise/enterprise-configuration.md index ebee7b16687..1639e9e2abf 100644 --- a/docs/sources/enterprise/enterprise-configuration.md +++ b/docs/sources/enterprise/enterprise-configuration.md @@ -501,9 +501,3 @@ The org id of the datasource where the query data will be written. If all `default_remote_write_*` properties are set, this information will be populated at startup. If a remote write target has already been configured, nothing will happen. - -## [feature_highlights] - -### enabled - -Whether the feature highlights feature is enabled diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index 971014422c9..a3f86909bee 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -36,4 +36,5 @@ export interface FeatureToggles { showFeatureFlagsInUI?: boolean; disable_http_request_histogram?: boolean; validatedQueries?: boolean; + featureHighlights?: boolean; } diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go index 0e45d41c620..43d38af0b77 100644 --- a/pkg/api/frontendsettings.go +++ b/pkg/api/frontendsettings.go @@ -273,9 +273,6 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i "enabled": hs.Cfg.SectionWithEnvOverrides("recorded_queries").Key("enabled").MustBool(true), }, "unifiedAlertingEnabled": hs.Cfg.UnifiedAlerting.Enabled, - "featureHighlights": map[string]bool{ - "enabled": hs.SettingsProvider.Section("feature_highlights").KeyValue("enabled").MustBool(false), - }, } if hs.Cfg.GeomapDefaultBaseLayerConfig != nil { diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index 3763a03f094..9a5a487cbf7 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -110,5 +110,10 @@ var ( State: FeatureStateAlpha, RequiresDevMode: true, }, + { + Name: "featureHighlights", + Description: "Highlight Enterprise features", + State: FeatureStateStable, + }, } ) diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index 430b9fbda56..49faad2bd17 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -82,4 +82,8 @@ const ( // FlagValidatedQueries // only execute the query saved in a panel FlagValidatedQueries = "validatedQueries" + + // FlagFeatureHighlights + // Highlight Enterprise features + FlagFeatureHighlights = "featureHighlights" ) diff --git a/public/app/features/datasources/state/navModel.ts b/public/app/features/datasources/state/navModel.ts index 25c88ae6935..4b6e635ed6e 100644 --- a/public/app/features/datasources/state/navModel.ts +++ b/public/app/features/datasources/state/navModel.ts @@ -8,7 +8,7 @@ import { GenericDataSourcePlugin } from '../settings/PluginSettings'; export function buildNavModel(dataSource: DataSourceSettings, plugin: GenericDataSourcePlugin): NavModelItem { const pluginMeta = plugin.meta; - + const highlightsEnabled = config.featureToggles.featureHighlights; const navModel: NavModelItem = { img: pluginMeta.info.logos.large, id: 'datasource-' + dataSource.uid, @@ -61,7 +61,7 @@ export function buildNavModel(dataSource: DataSourceSettings, plugin: GenericDat if (contextSrv.hasPermission(AccessControlAction.DataSourcesPermissionsRead)) { navModel.children!.push(dsPermissions); } - } else if (config.featureHighlights.enabled) { + } else if (highlightsEnabled) { navModel.children!.push({ ...dsPermissions, url: dsPermissions.url + '/upgrade', @@ -79,7 +79,7 @@ export function buildNavModel(dataSource: DataSourceSettings, plugin: GenericDat if (featureEnabled('analytics')) { navModel.children!.push(analytics); - } else if (config.featureHighlights.enabled) { + } else if (highlightsEnabled) { navModel.children!.push({ ...analytics, url: analytics.url + '/upgrade', @@ -98,7 +98,7 @@ export function buildNavModel(dataSource: DataSourceSettings, plugin: GenericDat if (featureEnabled('caching')) { navModel.children!.push(caching); - } else if (config.featureHighlights.enabled) { + } else if (highlightsEnabled) { navModel.children!.push({ ...caching, url: caching.url + '/upgrade', diff --git a/public/app/features/teams/TeamPages.tsx b/public/app/features/teams/TeamPages.tsx index 400dc0079c5..9817ddefe5b 100644 --- a/public/app/features/teams/TeamPages.tsx +++ b/public/app/features/teams/TeamPages.tsx @@ -130,7 +130,7 @@ export class TeamPages extends PureComponent { case PageTypes.GroupSync: if (isSignedInUserTeamAdmin && isSyncEnabled) { return ; - } else if (config.featureHighlights.enabled) { + } else if (config.featureToggles.featureHighlights) { return (