mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Config: Use license info instead of build info for feature toggling (#21558)
This commit is contained in:
parent
0e3a7b1a6f
commit
26f72ccc4e
@ -5,7 +5,7 @@ import { GrafanaTheme, GrafanaThemeType, PanelPluginMeta, DataSourceInstanceSett
|
|||||||
export interface BuildInfo {
|
export interface BuildInfo {
|
||||||
version: string;
|
version: string;
|
||||||
commit: string;
|
commit: string;
|
||||||
isEnterprise: boolean;
|
isEnterprise: boolean; // deprecated: use licenseInfo.hasLicense instead
|
||||||
env: string;
|
env: string;
|
||||||
latestVersion: string;
|
latestVersion: string;
|
||||||
hasUpdate: boolean;
|
hasUpdate: boolean;
|
||||||
@ -17,6 +17,12 @@ interface FeatureToggles {
|
|||||||
expressions: boolean;
|
expressions: boolean;
|
||||||
newEdit: boolean;
|
newEdit: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface LicenseInfo {
|
||||||
|
hasLicense: boolean;
|
||||||
|
expiry: number;
|
||||||
|
}
|
||||||
|
|
||||||
export class GrafanaBootConfig {
|
export class GrafanaBootConfig {
|
||||||
datasources: { [str: string]: DataSourceInstanceSettings } = {};
|
datasources: { [str: string]: DataSourceInstanceSettings } = {};
|
||||||
panels: { [key: string]: PanelPluginMeta } = {};
|
panels: { [key: string]: PanelPluginMeta } = {};
|
||||||
@ -55,6 +61,7 @@ export class GrafanaBootConfig {
|
|||||||
expressions: false,
|
expressions: false,
|
||||||
newEdit: false,
|
newEdit: false,
|
||||||
};
|
};
|
||||||
|
licenseInfo: LicenseInfo = {} as LicenseInfo;
|
||||||
|
|
||||||
constructor(options: GrafanaBootConfig) {
|
constructor(options: GrafanaBootConfig) {
|
||||||
this.theme = options.bootData.user.lightTheme ? getTheme(GrafanaThemeType.Light) : getTheme(GrafanaThemeType.Dark);
|
this.theme = options.bootData.user.lightTheme ? getTheme(GrafanaThemeType.Light) : getTheme(GrafanaThemeType.Dark);
|
||||||
|
@ -141,7 +141,7 @@ export class UserAdminPage extends PureComponent<Props, State> {
|
|||||||
onUserEnable={this.onUserEnable}
|
onUserEnable={this.onUserEnable}
|
||||||
onPasswordChange={this.onPasswordChange}
|
onPasswordChange={this.onPasswordChange}
|
||||||
/>
|
/>
|
||||||
{isLDAPUser && config.buildInfo.isEnterprise && ldapSyncInfo && (
|
{isLDAPUser && config.licenseInfo.hasLicense && ldapSyncInfo && (
|
||||||
<UserLdapSyncInfo ldapSyncInfo={ldapSyncInfo} user={user} onUserSync={this.onUserSync} />
|
<UserLdapSyncInfo ldapSyncInfo={ldapSyncInfo} user={user} onUserSync={this.onUserSync} />
|
||||||
)}
|
)}
|
||||||
<UserPermissions isGrafanaAdmin={user.isGrafanaAdmin} onGrafanaAdminChange={this.onGrafanaAdminChange} />
|
<UserPermissions isGrafanaAdmin={user.isGrafanaAdmin} onGrafanaAdminChange={this.onGrafanaAdminChange} />
|
||||||
|
@ -91,7 +91,7 @@ export class LdapPage extends PureComponent<Props, State> {
|
|||||||
|
|
||||||
<LdapConnectionStatus ldapConnectionInfo={ldapConnectionInfo} />
|
<LdapConnectionStatus ldapConnectionInfo={ldapConnectionInfo} />
|
||||||
|
|
||||||
{config.buildInfo.isEnterprise && ldapSyncInfo && <LdapSyncInfo ldapSyncInfo={ldapSyncInfo} />}
|
{config.licenseInfo.hasLicense && ldapSyncInfo && <LdapSyncInfo ldapSyncInfo={ldapSyncInfo} />}
|
||||||
|
|
||||||
<h3 className="page-heading">Test user mapping</h3>
|
<h3 className="page-heading">Test user mapping</h3>
|
||||||
<div className="gf-form-group">
|
<div className="gf-form-group">
|
||||||
|
@ -28,7 +28,7 @@ export function loadAdminUserPage(userId: number): ThunkResult<void> {
|
|||||||
await dispatch(loadUserProfile(userId));
|
await dispatch(loadUserProfile(userId));
|
||||||
await dispatch(loadUserOrgs(userId));
|
await dispatch(loadUserOrgs(userId));
|
||||||
await dispatch(loadUserSessions(userId));
|
await dispatch(loadUserSessions(userId));
|
||||||
if (config.ldapEnabled && config.buildInfo.isEnterprise) {
|
if (config.ldapEnabled && config.licenseInfo.hasLicense) {
|
||||||
await dispatch(loadLdapSyncStatus());
|
await dispatch(loadLdapSyncStatus());
|
||||||
}
|
}
|
||||||
dispatch(userAdminPageLoadedAction(true));
|
dispatch(userAdminPageLoadedAction(true));
|
||||||
@ -171,7 +171,7 @@ export function revokeAllSessions(userId: number): ThunkResult<void> {
|
|||||||
export function loadLdapSyncStatus(): ThunkResult<void> {
|
export function loadLdapSyncStatus(): ThunkResult<void> {
|
||||||
return async dispatch => {
|
return async dispatch => {
|
||||||
// Available only in enterprise
|
// Available only in enterprise
|
||||||
if (config.buildInfo.isEnterprise) {
|
if (config.licenseInfo.hasLicense) {
|
||||||
const syncStatus = await getBackendSrv().get(`/api/admin/ldap-sync-status`);
|
const syncStatus = await getBackendSrv().get(`/api/admin/ldap-sync-status`);
|
||||||
dispatch(ldapSyncStatusLoadedAction(syncStatus));
|
dispatch(ldapSyncStatusLoadedAction(syncStatus));
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ export function buildNavModel(dataSource: DataSourceSettings, plugin: GenericDat
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.buildInfo.isEnterprise) {
|
if (config.licenseInfo.hasLicense) {
|
||||||
navModel.children.push({
|
navModel.children.push({
|
||||||
active: false,
|
active: false,
|
||||||
icon: 'fa fa-fw fa-lock',
|
icon: 'fa fa-fw fa-lock',
|
||||||
|
@ -7,7 +7,7 @@ import { User } from 'app/core/services/context_srv';
|
|||||||
import { NavModel } from '@grafana/data';
|
import { NavModel } from '@grafana/data';
|
||||||
|
|
||||||
jest.mock('app/core/config', () => ({
|
jest.mock('app/core/config', () => ({
|
||||||
buildInfo: { isEnterprise: true },
|
licenseInfo: { hasLicense: true },
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const setup = (propOverrides?: object) => {
|
const setup = (propOverrides?: object) => {
|
||||||
|
@ -45,7 +45,7 @@ export class TeamPages extends PureComponent<Props, State> {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isSyncEnabled: config.buildInfo.isEnterprise,
|
isSyncEnabled: config.licenseInfo.hasLicense,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ export function buildNavModel(team: Team): NavModelItem {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (config.buildInfo.isEnterprise) {
|
if (config.licenseInfo.hasLicense) {
|
||||||
navModel.children.push({
|
navModel.children.push({
|
||||||
active: false,
|
active: false,
|
||||||
icon: 'fa fa-fw fa-refresh',
|
icon: 'fa fa-fw fa-refresh',
|
||||||
|
Loading…
Reference in New Issue
Block a user