Commit 26f72ccc by Emil Tullstedt Committed by GitHub

Config: Use license info instead of build info for feature toggling (#21558)

parent 0e3a7b1a
......@@ -5,7 +5,7 @@ import { GrafanaTheme, GrafanaThemeType, PanelPluginMeta, DataSourceInstanceSett
export interface BuildInfo {
version: string;
commit: string;
isEnterprise: boolean;
isEnterprise: boolean; // deprecated: use licenseInfo.hasLicense instead
env: string;
latestVersion: string;
hasUpdate: boolean;
......@@ -17,6 +17,12 @@ interface FeatureToggles {
expressions: boolean;
newEdit: boolean;
}
interface LicenseInfo {
hasLicense: boolean;
expiry: number;
}
export class GrafanaBootConfig {
datasources: { [str: string]: DataSourceInstanceSettings } = {};
panels: { [key: string]: PanelPluginMeta } = {};
......@@ -55,6 +61,7 @@ export class GrafanaBootConfig {
expressions: false,
newEdit: false,
};
licenseInfo: LicenseInfo = {} as LicenseInfo;
constructor(options: GrafanaBootConfig) {
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}
onPasswordChange={this.onPasswordChange}
/>
{isLDAPUser && config.buildInfo.isEnterprise && ldapSyncInfo && (
{isLDAPUser && config.licenseInfo.hasLicense && ldapSyncInfo && (
<UserLdapSyncInfo ldapSyncInfo={ldapSyncInfo} user={user} onUserSync={this.onUserSync} />
)}
<UserPermissions isGrafanaAdmin={user.isGrafanaAdmin} onGrafanaAdminChange={this.onGrafanaAdminChange} />
......
......@@ -91,7 +91,7 @@ export class LdapPage extends PureComponent<Props, State> {
<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>
<div className="gf-form-group">
......
......@@ -28,7 +28,7 @@ export function loadAdminUserPage(userId: number): ThunkResult<void> {
await dispatch(loadUserProfile(userId));
await dispatch(loadUserOrgs(userId));
await dispatch(loadUserSessions(userId));
if (config.ldapEnabled && config.buildInfo.isEnterprise) {
if (config.ldapEnabled && config.licenseInfo.hasLicense) {
await dispatch(loadLdapSyncStatus());
}
dispatch(userAdminPageLoadedAction(true));
......@@ -171,7 +171,7 @@ export function revokeAllSessions(userId: number): ThunkResult<void> {
export function loadLdapSyncStatus(): ThunkResult<void> {
return async dispatch => {
// Available only in enterprise
if (config.buildInfo.isEnterprise) {
if (config.licenseInfo.hasLicense) {
const syncStatus = await getBackendSrv().get(`/api/admin/ldap-sync-status`);
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({
active: false,
icon: 'fa fa-fw fa-lock',
......
......@@ -7,7 +7,7 @@ import { User } from 'app/core/services/context_srv';
import { NavModel } from '@grafana/data';
jest.mock('app/core/config', () => ({
buildInfo: { isEnterprise: true },
licenseInfo: { hasLicense: true },
}));
const setup = (propOverrides?: object) => {
......
......@@ -45,7 +45,7 @@ export class TeamPages extends PureComponent<Props, State> {
this.state = {
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({
active: false,
icon: 'fa fa-fw fa-refresh',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment