[ML] Only add ML links for sample data sets if full license (#38120) (#38274)

* [ML] Only add ML links for sample data sets if full license

* [ML] Update following review
This commit is contained in:
Pete Harverson 2019-06-06 21:28:15 +01:00 committed by GitHub
parent 99d6d9bc96
commit 8ab06e9a13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,6 +11,7 @@ import Boom from 'boom';
import { checkLicense } from './server/lib/check_license';
import { addLinksToSampleDatasets } from './server/lib/sample_data_sets';
import { FEATURE_ANNOTATIONS_ENABLED } from './common/constants/feature_flags';
import { LICENSE_TYPE } from './common/constants/license';
import { mirrorPluginStatus } from '../../server/lib/mirror_plugin_status';
import { annotationRoutes } from './server/routes/annotations';
@ -79,11 +80,16 @@ export const ml = (kibana) => {
xpackMainPlugin.status.once('green', () => {
// Register a function that is called whenever the xpack info changes,
// to re-compute the license check results for this plugin
xpackMainPlugin.info.feature(thisPlugin.id).registerLicenseCheckResultsGenerator(checkLicense);
const mlFeature = xpackMainPlugin.info.feature(thisPlugin.id);
mlFeature.registerLicenseCheckResultsGenerator(checkLicense);
const isEnabled = xpackMainPlugin.info.feature(thisPlugin.id).isEnabled();
if (isEnabled === true) {
addLinksToSampleDatasets(server);
// Add links to the Kibana sample data sets if ml is enabled
// and there is a full license (trial or platinum).
if (mlFeature.isEnabled() === true) {
const licenseCheckResults = mlFeature.getLicenseCheckResults();
if (licenseCheckResults.licenseType === LICENSE_TYPE.FULL) {
addLinksToSampleDatasets(server);
}
}
});