diff --git a/packages/grafana-runtime/src/config.ts b/packages/grafana-runtime/src/config.ts index 3da9f814845..b734f57ddb0 100644 --- a/packages/grafana-runtime/src/config.ts +++ b/packages/grafana-runtime/src/config.ts @@ -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); diff --git a/public/app/features/admin/UserAdminPage.tsx b/public/app/features/admin/UserAdminPage.tsx index d8ef4539264..f8e9a0904c4 100644 --- a/public/app/features/admin/UserAdminPage.tsx +++ b/public/app/features/admin/UserAdminPage.tsx @@ -141,7 +141,7 @@ export class UserAdminPage extends PureComponent { onUserEnable={this.onUserEnable} onPasswordChange={this.onPasswordChange} /> - {isLDAPUser && config.buildInfo.isEnterprise && ldapSyncInfo && ( + {isLDAPUser && config.licenseInfo.hasLicense && ldapSyncInfo && ( )} diff --git a/public/app/features/admin/ldap/LdapPage.tsx b/public/app/features/admin/ldap/LdapPage.tsx index 0db89100768..80ec3bf72c2 100644 --- a/public/app/features/admin/ldap/LdapPage.tsx +++ b/public/app/features/admin/ldap/LdapPage.tsx @@ -91,7 +91,7 @@ export class LdapPage extends PureComponent { - {config.buildInfo.isEnterprise && ldapSyncInfo && } + {config.licenseInfo.hasLicense && ldapSyncInfo && }

Test user mapping

diff --git a/public/app/features/admin/state/actions.ts b/public/app/features/admin/state/actions.ts index c4437e33b4b..f61c11d49ae 100644 --- a/public/app/features/admin/state/actions.ts +++ b/public/app/features/admin/state/actions.ts @@ -28,7 +28,7 @@ export function loadAdminUserPage(userId: number): ThunkResult { 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 { export function loadLdapSyncStatus(): ThunkResult { 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)); } diff --git a/public/app/features/datasources/state/navModel.ts b/public/app/features/datasources/state/navModel.ts index f97ecacd603..46afb489bde 100644 --- a/public/app/features/datasources/state/navModel.ts +++ b/public/app/features/datasources/state/navModel.ts @@ -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', diff --git a/public/app/features/teams/TeamPages.test.tsx b/public/app/features/teams/TeamPages.test.tsx index 53d3b0834bb..eafad3ba057 100644 --- a/public/app/features/teams/TeamPages.test.tsx +++ b/public/app/features/teams/TeamPages.test.tsx @@ -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) => { diff --git a/public/app/features/teams/TeamPages.tsx b/public/app/features/teams/TeamPages.tsx index ed3f3130a85..6d7774ecf6c 100644 --- a/public/app/features/teams/TeamPages.tsx +++ b/public/app/features/teams/TeamPages.tsx @@ -45,7 +45,7 @@ export class TeamPages extends PureComponent { this.state = { isLoading: false, - isSyncEnabled: config.buildInfo.isEnterprise, + isSyncEnabled: config.licenseInfo.hasLicense, }; } diff --git a/public/app/features/teams/state/navModel.ts b/public/app/features/teams/state/navModel.ts index 81671203539..b8420f99f8b 100644 --- a/public/app/features/teams/state/navModel.ts +++ b/public/app/features/teams/state/navModel.ts @@ -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',