diff --git a/x-pack/legacy/plugins/ml/public/license/__tests__/check_license.js b/x-pack/legacy/plugins/ml/public/license/__tests__/check_license.js index 068c0ba287219c..e620a29e1d7f1e 100644 --- a/x-pack/legacy/plugins/ml/public/license/__tests__/check_license.js +++ b/x-pack/legacy/plugins/ml/public/license/__tests__/check_license.js @@ -6,6 +6,7 @@ import expect from '@kbn/expect'; import { xpackInfo } from '../../../../xpack_main/public/services/xpack_info'; +import { LICENSE_STATUS_VALID } from '../../../../../common/constants/license_status'; import { xpackFeatureAvailable, } from '../check_license'; @@ -13,13 +14,13 @@ import { const initialInfo = { features: { watcher: { - isAvailable: true + status: LICENSE_STATUS_VALID } } }; describe('ML - check license', () => { - describe('xpackFeatureProvider', () => { + describe('xpackFeatureAvailable', () => { beforeEach(() => { xpackInfo.setAll(initialInfo); }); diff --git a/x-pack/legacy/plugins/ml/public/license/check_license.js b/x-pack/legacy/plugins/ml/public/license/check_license.js index 362f40828ee13f..9e86fa429b0dab 100644 --- a/x-pack/legacy/plugins/ml/public/license/check_license.js +++ b/x-pack/legacy/plugins/ml/public/license/check_license.js @@ -9,6 +9,7 @@ import React from 'react'; import { xpackInfo } from '../../../xpack_main/public/services/xpack_info'; import { banners, addAppRedirectMessageToUrl } from 'ui/notify'; import { LICENSE_TYPE } from '../../common/constants/license'; +import { LICENSE_STATUS_VALID } from '../../../../common/constants/license_status'; import chrome from 'ui/chrome'; import { EuiCallOut } from '@elastic/eui'; @@ -119,5 +120,17 @@ export function isFullLicense() { } export function xpackFeatureAvailable(feature) { - return xpackInfo.get(`features.${feature}.isAvailable`, false); + // each plugin can register their own set of features. + // so we need specific checks for each one. + // this list can grow if we need to check other plugin's features. + switch (feature) { + case 'watcher': + // watcher only has a license status feature + // if watcher is disabled in kibana.yml, the feature is completely missing from xpackInfo + return xpackInfo.get(`features.${feature}.status`, false) === LICENSE_STATUS_VALID; + default: + // historically plugins have used `isAvailable` as a catch all for + // license and feature enabled checks + return xpackInfo.get(`features.${feature}.isAvailable`, false); + } }