diff --git a/x-pack/legacy/plugins/maps/check_license.js b/x-pack/legacy/plugins/maps/check_license.js deleted file mode 100644 index 9e5397ee5dc75..0000000000000 --- a/x-pack/legacy/plugins/maps/check_license.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/** - * on the license information extracted from the xPackInfo. - * @param {XPackInfo} xPackInfo XPackInfo instance to extract license information from. - * @returns {LicenseCheckResult} - */ -export function checkLicense(xPackInfo) { - if (!xPackInfo.isAvailable()) { - return { - maps: false, - }; - } - - const isAnyXpackLicense = xPackInfo.license.isOneOf([ - 'basic', - 'standard', - 'gold', - 'platinum', - 'enterprise', - 'trial', - ]); - - if (!isAnyXpackLicense) { - return { - maps: false, - }; - } - - return { - maps: true, - uid: xPackInfo.license.getUid(), - }; -} diff --git a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.js b/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.js index b9346516eeea8..8bae140de9558 100644 --- a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.js +++ b/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.js @@ -24,6 +24,8 @@ import { getInitialLayers } from '../angular/get_initial_layers'; import { mergeInputWithSavedMap } from './merge_input_with_saved_map'; import '../angular/services/gis_map_saved_object_loader'; import 'ui/vis/map/service_settings'; +import { bindSetupCoreAndPlugins } from '../plugin'; +import { npSetup } from 'ui/new_platform'; export class MapEmbeddableFactory extends EmbeddableFactory { type = MAP_SAVED_OBJECT_TYPE; @@ -38,6 +40,7 @@ export class MapEmbeddableFactory extends EmbeddableFactory { getIconForSavedObject: () => APP_ICON, }, }); + bindSetupCoreAndPlugins(npSetup.core, npSetup.plugins); } isEditable() { return capabilities.get().maps.save; diff --git a/x-pack/legacy/plugins/maps/public/plugin.ts b/x-pack/legacy/plugins/maps/public/plugin.ts index 0df7109852486..b3c0522679e5e 100644 --- a/x-pack/legacy/plugins/maps/public/plugin.ts +++ b/x-pack/legacy/plugins/maps/public/plugin.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Plugin, CoreStart } from 'src/core/public'; +import { Plugin, CoreStart, CoreSetup } from 'src/core/public'; // @ts-ignore import { wrapInI18nContext } from 'ui/i18n'; // @ts-ignore @@ -20,12 +20,19 @@ import { setLicenseId } from './kibana_services'; export type MapsPluginSetup = ReturnType; export type MapsPluginStart = ReturnType; +export const bindSetupCoreAndPlugins = (core: CoreSetup, plugins: any) => { + const { licensing } = plugins; + if (licensing) { + licensing.license$.subscribe(({ uid }: { uid: string }) => setLicenseId(uid)); + } +}; + /** @internal */ export class MapsPlugin implements Plugin { public setup(core: any, plugins: any) { const { __LEGACY: { uiModules }, - np: { licensing }, + np, } = plugins; uiModules @@ -34,9 +41,7 @@ export class MapsPlugin implements Plugin { return reactDirective(wrapInI18nContext(MapListing)); }); - if (licensing) { - licensing.license$.subscribe(({ uid }: { uid: string }) => setLicenseId(uid)); - } + bindSetupCoreAndPlugins(core, np); } public start(core: CoreStart, plugins: any) {}