From 19854c19b7ebf6d941b6e5e62ca47bf86caf3ce7 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 9 Aug 2019 14:44:01 +0100 Subject: [PATCH 1/4] [ML] Fix check for watcher being enabled --- x-pack/legacy/plugins/ml/public/license/check_license.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 362f40828ee13..2939cae0878af 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,10 @@ export function isFullLicense() { } export function xpackFeatureAvailable(feature) { - return xpackInfo.get(`features.${feature}.isAvailable`, false); + switch (feature) { + case 'watcher': + return xpackInfo.get(`features.${feature}.status`, false) === LICENSE_STATUS_VALID; + default: + return xpackInfo.get(`features.${feature}.isAvailable`, false); + } } From 55901357191e5e839e4868ecb8122322658c491a Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 9 Aug 2019 14:48:44 +0100 Subject: [PATCH 2/4] adding comments --- x-pack/legacy/plugins/ml/public/license/check_license.js | 7 +++++++ 1 file changed, 7 insertions(+) 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 2939cae0878af..965c655fe51fc 100644 --- a/x-pack/legacy/plugins/ml/public/license/check_license.js +++ b/x-pack/legacy/plugins/ml/public/license/check_license.js @@ -120,10 +120,17 @@ export function isFullLicense() { } export function xpackFeatureAvailable(feature) { + // 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 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); } } From 0ac5fa488f461a2444ecdfe5a24435b26b17c592 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 9 Aug 2019 14:49:21 +0100 Subject: [PATCH 3/4] typo --- x-pack/legacy/plugins/ml/public/license/check_license.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 965c655fe51fc..9e86fa429b0da 100644 --- a/x-pack/legacy/plugins/ml/public/license/check_license.js +++ b/x-pack/legacy/plugins/ml/public/license/check_license.js @@ -122,7 +122,7 @@ export function isFullLicense() { export function xpackFeatureAvailable(feature) { // 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 features. + // this list can grow if we need to check other plugin's features. switch (feature) { case 'watcher': // watcher only has a license status feature From 8dc3a55a2bc5acfd2d3d3d12f9322dcfebe34657 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 9 Aug 2019 15:48:21 +0100 Subject: [PATCH 4/4] fixing test --- .../plugins/ml/public/license/__tests__/check_license.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 068c0ba287219..e620a29e1d7f1 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); });