diff --git a/x-pack/common/constants/index.ts b/x-pack/common/constants/index.ts index d08dc538c77c36..842b0aea91d304 100644 --- a/x-pack/common/constants/index.ts +++ b/x-pack/common/constants/index.ts @@ -10,3 +10,13 @@ export { LICENSE_STATUS_EXPIRED, LICENSE_STATUS_VALID, } from './license_status'; + +export { + LICENSE_TYPE_BASIC, + LICENSE_TYPE_STANDARD, + LICENSE_TYPE_GOLD, + LICENSE_TYPE_PLATINUM, + LICENSE_TYPE_TRIAL, + RANKED_LICENSE_TYPES, + LicenseType, +} from './license_types'; diff --git a/x-pack/server/lib/constants/license.ts b/x-pack/common/constants/license_types.ts similarity index 81% rename from x-pack/server/lib/constants/license.ts rename to x-pack/common/constants/license_types.ts index 193620acde9655..3971ed5e95174e 100644 --- a/x-pack/server/lib/constants/license.ts +++ b/x-pack/common/constants/license_types.ts @@ -10,6 +10,13 @@ export const LICENSE_TYPE_GOLD = 'gold'; export const LICENSE_TYPE_PLATINUM = 'platinum'; export const LICENSE_TYPE_TRIAL = 'trial'; +export type LicenseType = + | typeof LICENSE_TYPE_BASIC + | typeof LICENSE_TYPE_STANDARD + | typeof LICENSE_TYPE_GOLD + | typeof LICENSE_TYPE_PLATINUM + | typeof LICENSE_TYPE_TRIAL; + // These are ordered from least featureful to most featureful, so we can assume that someone holding // a license at a particular index cannot access any features unlocked by the licenses that follow it. export const RANKED_LICENSE_TYPES = [ diff --git a/x-pack/plugins/index_management/common/constants/plugin.js b/x-pack/plugins/index_management/common/constants/plugin.js index 3334751ecd058c..15031e7808d650 100644 --- a/x-pack/plugins/index_management/common/constants/plugin.js +++ b/x-pack/plugins/index_management/common/constants/plugin.js @@ -5,11 +5,12 @@ */ import { i18n } from '@kbn/i18n'; +import { LICENSE_TYPE_BASIC } from '../../../../common/constants'; export const PLUGIN = { ID: 'index_management', NAME: i18n.translate('xpack.idxMgmt.appTitle', { defaultMessage: 'Index Management' }), - MINIMUM_LICENSE_REQUIRED: 'basic', + MINIMUM_LICENSE_REQUIRED: LICENSE_TYPE_BASIC, }; diff --git a/x-pack/plugins/license_management/common/constants/plugin.js b/x-pack/plugins/license_management/common/constants/plugin.js index 7da3dbdeba1c82..ee7977f759822d 100644 --- a/x-pack/plugins/license_management/common/constants/plugin.js +++ b/x-pack/plugins/license_management/common/constants/plugin.js @@ -5,11 +5,12 @@ */ import { i18n } from '@kbn/i18n'; +import { LICENSE_TYPE_BASIC } from '../../../../common/constants'; export const PLUGIN = { ID: 'license_management', NAME: i18n.translate('xpack.licenseMgmt.managementSectionDisplayName', { defaultMessage: 'License Management', }), - MINIMUM_LICENSE_REQUIRED: 'basic', + MINIMUM_LICENSE_REQUIRED: LICENSE_TYPE_BASIC, }; diff --git a/x-pack/server/lib/check_license/check_license.js b/x-pack/server/lib/check_license/check_license.js index 9f25ff1314ca5a..5f5ecf816a4ab1 100644 --- a/x-pack/server/lib/check_license/check_license.js +++ b/x-pack/server/lib/check_license/check_license.js @@ -5,12 +5,12 @@ */ import { i18n } from '@kbn/i18n'; -import { RANKED_LICENSE_TYPES } from '../constants'; import { LICENSE_STATUS_UNAVAILABLE, LICENSE_STATUS_INVALID, LICENSE_STATUS_EXPIRED, LICENSE_STATUS_VALID, + RANKED_LICENSE_TYPES, } from '../../../common/constants'; export function checkLicense(pluginName, minimumLicenseRequired, xpackLicenseInfo) { diff --git a/x-pack/server/lib/check_license/check_license.test.js b/x-pack/server/lib/check_license/check_license.test.js index bb6005cc3198d8..ccf3cbff3d5a11 100644 --- a/x-pack/server/lib/check_license/check_license.test.js +++ b/x-pack/server/lib/check_license/check_license.test.js @@ -10,12 +10,13 @@ import { LICENSE_STATUS_UNAVAILABLE, LICENSE_STATUS_EXPIRED, LICENSE_STATUS_VALID, + LICENSE_TYPE_BASIC, } from '../../../common/constants'; describe('check_license', function () { const pluginName = 'Foo'; - const minimumLicenseRequired = 'basic'; + const minimumLicenseRequired = LICENSE_TYPE_BASIC; let mockLicenseInfo; beforeEach(() => mockLicenseInfo = {}); @@ -46,7 +47,7 @@ describe('check_license', function () { describe('license information is available', () => { beforeEach(() => { mockLicenseInfo.isAvailable = () => true; - set(mockLicenseInfo, 'license.getType', () => 'basic'); + set(mockLicenseInfo, 'license.getType', () => LICENSE_TYPE_BASIC); }); describe('& license is trial, standard, gold, platinum', () => { diff --git a/x-pack/server/lib/constants/index.ts b/x-pack/server/lib/constants/index.ts index 222b5ec20e225a..c6cf975fe32f3f 100644 --- a/x-pack/server/lib/constants/index.ts +++ b/x-pack/server/lib/constants/index.ts @@ -6,11 +6,3 @@ export { XPACK_DEFAULT_ADMIN_EMAIL_UI_SETTING } from './admin'; export { XPACK_INFO_API_DEFAULT_POLL_FREQUENCY_IN_MILLIS } from './xpack_info'; -export { - LICENSE_TYPE_BASIC, - LICENSE_TYPE_STANDARD, - LICENSE_TYPE_GOLD, - LICENSE_TYPE_PLATINUM, - LICENSE_TYPE_TRIAL, - RANKED_LICENSE_TYPES, -} from './license';