diff --git a/packages/grafana-data/src/types/config.ts b/packages/grafana-data/src/types/config.ts index b27a887cd73..b1d519c8b12 100644 --- a/packages/grafana-data/src/types/config.ts +++ b/packages/grafana-data/src/types/config.ts @@ -4,6 +4,7 @@ import { GrafanaTheme } from './theme'; import { SystemDateFormatSettings } from '../datetime'; import { GrafanaTheme2 } from '../themes'; import { MapLayerOptions } from '../geo/layer'; +import { FeatureToggles } from './featureToggles.gen'; /** * Describes the build information that will be available via the Grafana configuration. @@ -29,28 +30,6 @@ export enum GrafanaEdition { Enterprise = 'Enterprise', } -/** - * Describes available feature toggles in Grafana. These can be configured via the - * `conf/custom.ini` to enable features under development or not yet available in - * stable version. - * - * @public - */ -export interface FeatureToggles { - [name: string]: boolean; - - trimDefaults: boolean; - accesscontrol: boolean; - tempoServiceGraph: boolean; - tempoSearch: boolean; - tempoBackendSearch: boolean; - recordedQueries: boolean; - newNavigation: boolean; - fullRangeLogsVolume: boolean; - queryOverLive: boolean; - dashboardPreviews: boolean; -} - /** * Describes the license information about the current running instance of Grafana. * diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts new file mode 100644 index 00000000000..94d9a8b6eb3 --- /dev/null +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -0,0 +1,39 @@ +/** + * Describes available feature toggles in Grafana. These can be configured via + * conf/custom.ini to enable features under development or not yet available in + * stable version. + * + * Only enabled values will be returned in this interface + * + * @public + */ +export interface FeatureToggles { + [name: string]: boolean | undefined; // support any string value + + recordedQueries?: boolean; + teamsync?: boolean; + ldapsync?: boolean; + caching?: boolean; + dspermissions?: boolean; + analytics?: boolean; + ['enterprise.plugins']?: boolean; + trimDefaults?: boolean; + envelopeEncryption?: boolean; + httpclientprovider_azure_auth?: boolean; + ['service-accounts']?: boolean; + database_metrics?: boolean; + dashboardPreviews?: boolean; + ['live-config']?: boolean; + ['live-pipeline']?: boolean; + ['live-service-web-worker']?: boolean; + queryOverLive?: boolean; + tempoSearch?: boolean; + tempoBackendSearch?: boolean; + tempoServiceGraph?: boolean; + fullRangeLogsVolume?: boolean; + accesscontrol?: boolean; + prometheus_azure_auth?: boolean; + newNavigation?: boolean; + showFeatureFlagsInUI?: boolean; + disable_http_request_histogram?: boolean; +} diff --git a/packages/grafana-data/src/types/index.ts b/packages/grafana-data/src/types/index.ts index 3a8729798b2..05287ffa6bd 100644 --- a/packages/grafana-data/src/types/index.ts +++ b/packages/grafana-data/src/types/index.ts @@ -36,7 +36,8 @@ export * from './live'; export * from './variables'; export * from './geometry'; export { isUnsignedPluginSignature } from './pluginSignature'; -export { GrafanaConfig, BuildInfo, FeatureToggles, LicenseInfo, PreloadPlugin } from './config'; +export { GrafanaConfig, BuildInfo, LicenseInfo, PreloadPlugin } from './config'; +export { FeatureToggles } from './featureToggles.gen'; export * from './alerts'; export * from './slider'; export * from './accesscontrol'; diff --git a/packages/grafana-runtime/src/config.ts b/packages/grafana-runtime/src/config.ts index d97b894539e..4d2585cbb03 100644 --- a/packages/grafana-runtime/src/config.ts +++ b/packages/grafana-runtime/src/config.ts @@ -61,18 +61,7 @@ export class GrafanaBootConfig implements GrafanaConfig { theme: GrafanaTheme; theme2: GrafanaTheme2; pluginsToPreload: PreloadPlugin[] = []; - featureToggles: FeatureToggles = { - accesscontrol: false, - trimDefaults: false, - tempoServiceGraph: false, - tempoSearch: false, - tempoBackendSearch: false, - recordedQueries: false, - newNavigation: false, - fullRangeLogsVolume: false, - queryOverLive: false, - dashboardPreviews: false, - }; + featureToggles: FeatureToggles = {}; licenseInfo: LicenseInfo = {} as LicenseInfo; rendererAvailable = false; rendererVersion = ''; diff --git a/public/app/AppWrapper.tsx b/public/app/AppWrapper.tsx index ec533127fdd..d3234f35a37 100644 --- a/public/app/AppWrapper.tsx +++ b/public/app/AppWrapper.tsx @@ -92,7 +92,7 @@ export class AppWrapper extends React.Component diff --git a/public/app/core/components/NavBar/NavBarSection.tsx b/public/app/core/components/NavBar/NavBarSection.tsx index 9f11a7ef6c5..6b9c6ae88fc 100644 --- a/public/app/core/components/NavBar/NavBarSection.tsx +++ b/public/app/core/components/NavBar/NavBarSection.tsx @@ -2,7 +2,7 @@ import React, { ReactNode } from 'react'; import { css, cx } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { useTheme2 } from '@grafana/ui'; -import config from '../../config'; +import { config } from '@grafana/runtime'; export interface Props { children: ReactNode; @@ -10,7 +10,7 @@ export interface Props { } export function NavBarSection({ children, className }: Props) { - const newNavigationEnabled = config.featureToggles.newNavigation; + const newNavigationEnabled = Boolean(config.featureToggles.newNavigation); const theme = useTheme2(); const styles = getStyles(theme, newNavigationEnabled); diff --git a/public/app/core/services/context_srv.ts b/public/app/core/services/context_srv.ts index f44889156d0..262ac14abd4 100644 --- a/public/app/core/services/context_srv.ts +++ b/public/app/core/services/context_srv.ts @@ -83,7 +83,7 @@ export class ContextSrv { } accessControlEnabled(): boolean { - return featureEnabled('accesscontrol') && config.featureToggles['accesscontrol']; + return featureEnabled('accesscontrol') && Boolean(config.featureToggles['accesscontrol']); } // Checks whether user has required permission