mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 10:12:11 +08:00
FeatureToggles: typed as optional booleans (#43925)
This commit is contained in:
@ -4,6 +4,7 @@ import { GrafanaTheme } from './theme';
|
|||||||
import { SystemDateFormatSettings } from '../datetime';
|
import { SystemDateFormatSettings } from '../datetime';
|
||||||
import { GrafanaTheme2 } from '../themes';
|
import { GrafanaTheme2 } from '../themes';
|
||||||
import { MapLayerOptions } from '../geo/layer';
|
import { MapLayerOptions } from '../geo/layer';
|
||||||
|
import { FeatureToggles } from './featureToggles.gen';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes the build information that will be available via the Grafana configuration.
|
* Describes the build information that will be available via the Grafana configuration.
|
||||||
@ -29,28 +30,6 @@ export enum GrafanaEdition {
|
|||||||
Enterprise = 'Enterprise',
|
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.
|
* Describes the license information about the current running instance of Grafana.
|
||||||
*
|
*
|
||||||
|
39
packages/grafana-data/src/types/featureToggles.gen.ts
Normal file
39
packages/grafana-data/src/types/featureToggles.gen.ts
Normal file
@ -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;
|
||||||
|
}
|
@ -36,7 +36,8 @@ export * from './live';
|
|||||||
export * from './variables';
|
export * from './variables';
|
||||||
export * from './geometry';
|
export * from './geometry';
|
||||||
export { isUnsignedPluginSignature } from './pluginSignature';
|
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 './alerts';
|
||||||
export * from './slider';
|
export * from './slider';
|
||||||
export * from './accesscontrol';
|
export * from './accesscontrol';
|
||||||
|
@ -61,18 +61,7 @@ export class GrafanaBootConfig implements GrafanaConfig {
|
|||||||
theme: GrafanaTheme;
|
theme: GrafanaTheme;
|
||||||
theme2: GrafanaTheme2;
|
theme2: GrafanaTheme2;
|
||||||
pluginsToPreload: PreloadPlugin[] = [];
|
pluginsToPreload: PreloadPlugin[] = [];
|
||||||
featureToggles: FeatureToggles = {
|
featureToggles: FeatureToggles = {};
|
||||||
accesscontrol: false,
|
|
||||||
trimDefaults: false,
|
|
||||||
tempoServiceGraph: false,
|
|
||||||
tempoSearch: false,
|
|
||||||
tempoBackendSearch: false,
|
|
||||||
recordedQueries: false,
|
|
||||||
newNavigation: false,
|
|
||||||
fullRangeLogsVolume: false,
|
|
||||||
queryOverLive: false,
|
|
||||||
dashboardPreviews: false,
|
|
||||||
};
|
|
||||||
licenseInfo: LicenseInfo = {} as LicenseInfo;
|
licenseInfo: LicenseInfo = {} as LicenseInfo;
|
||||||
rendererAvailable = false;
|
rendererAvailable = false;
|
||||||
rendererVersion = '';
|
rendererVersion = '';
|
||||||
|
@ -92,7 +92,7 @@ export class AppWrapper extends React.Component<AppWrapperProps, AppWrapperState
|
|||||||
render() {
|
render() {
|
||||||
navigationLogger('AppWrapper', false, 'rendering');
|
navigationLogger('AppWrapper', false, 'rendering');
|
||||||
|
|
||||||
const newNavigationEnabled = config.featureToggles.newNavigation;
|
const newNavigationEnabled = Boolean(config.featureToggles.newNavigation);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
|
@ -2,7 +2,7 @@ import React, { ReactNode } from 'react';
|
|||||||
import { css, cx } from '@emotion/css';
|
import { css, cx } from '@emotion/css';
|
||||||
import { GrafanaTheme2 } from '@grafana/data';
|
import { GrafanaTheme2 } from '@grafana/data';
|
||||||
import { useTheme2 } from '@grafana/ui';
|
import { useTheme2 } from '@grafana/ui';
|
||||||
import config from '../../config';
|
import { config } from '@grafana/runtime';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
@ -10,7 +10,7 @@ export interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function NavBarSection({ children, className }: Props) {
|
export function NavBarSection({ children, className }: Props) {
|
||||||
const newNavigationEnabled = config.featureToggles.newNavigation;
|
const newNavigationEnabled = Boolean(config.featureToggles.newNavigation);
|
||||||
const theme = useTheme2();
|
const theme = useTheme2();
|
||||||
const styles = getStyles(theme, newNavigationEnabled);
|
const styles = getStyles(theme, newNavigationEnabled);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ export class ContextSrv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
accessControlEnabled(): boolean {
|
accessControlEnabled(): boolean {
|
||||||
return featureEnabled('accesscontrol') && config.featureToggles['accesscontrol'];
|
return featureEnabled('accesscontrol') && Boolean(config.featureToggles['accesscontrol']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks whether user has required permission
|
// Checks whether user has required permission
|
||||||
|
Reference in New Issue
Block a user