From fb23b203cbe9b9555685f0798ca6916b9ab3252b Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Mon, 11 Jan 2021 12:07:58 -0500 Subject: [PATCH] init --- .../plugins/maps/public/licensed_features.ts | 24 ++++++++++++------- x-pack/plugins/maps/public/plugin.ts | 4 ++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/maps/public/licensed_features.ts b/x-pack/plugins/maps/public/licensed_features.ts index f709dd529e375..f16fcac900683 100644 --- a/x-pack/plugins/maps/public/licensed_features.ts +++ b/x-pack/plugins/maps/public/licensed_features.ts @@ -54,17 +54,23 @@ export function registerLicensedFeatures(licensingPlugin: LicensingPluginSetup) } let licensingPluginStart: LicensingPluginStart; -export function setLicensingPluginStart(licensingPlugin: LicensingPluginStart) { - licensingPluginStart = licensingPlugin; - licensingPluginStart.license$.subscribe((license: ILicense) => { - const gold = license.check(APP_ID, 'gold'); - isGoldPlus = gold.state === 'valid'; - const enterprise = license.check(APP_ID, 'enterprise'); - isEnterprisePlus = enterprise.state === 'valid'; +function updateLicenseState(license: ILicense) { + const gold = license.check(APP_ID, 'gold'); + isGoldPlus = gold.state === 'valid'; + + const enterprise = license.check(APP_ID, 'enterprise'); + isEnterprisePlus = enterprise.state === 'valid'; + + licenseId = license.uid; +} + +export async function setLicensingPluginStart(licensingPlugin: LicensingPluginStart) { + const license = await licensingPlugin.refresh(); + updateLicenseState(license); - licenseId = license.uid; - }); + licensingPluginStart = licensingPlugin; + licensingPluginStart.license$.subscribe(updateLicenseState); } export function notifyLicensedFeatureUsage(licensedFeature: LICENSED_FEATURES) { diff --git a/x-pack/plugins/maps/public/plugin.ts b/x-pack/plugins/maps/public/plugin.ts index 8bffea3ce5a87..b5340f4e31068 100644 --- a/x-pack/plugins/maps/public/plugin.ts +++ b/x-pack/plugins/maps/public/plugin.ts @@ -158,8 +158,8 @@ export class MapsPlugin }); } - public start(core: CoreStart, plugins: MapsPluginStartDependencies): MapsStartApi { - setLicensingPluginStart(plugins.licensing); + public async start(core: CoreStart, plugins: MapsPluginStartDependencies): Promise { + await setLicensingPluginStart(plugins.licensing); plugins.uiActions.addTriggerAction(VISUALIZE_GEO_FIELD_TRIGGER, visualizeGeoFieldAction); setStartServices(core, plugins); // unregisters the OSS alias