From 5afac07c8d5d0be27d8262d9dba8634c61f7f368 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Tue, 14 Apr 2020 15:36:36 -0600 Subject: [PATCH 1/9] Move logic to NP and add basic plugin structure --- .../maps_legacy_licensing}/README.md | 0 .../maps_legacy_licensing}/index.js | 0 .../plugins/maps_legacy_licensing/kibana.json | 8 +++++ .../maps_legacy_licensing/public/index.ts | 11 +++++++ .../maps_legacy_licensing/public/plugin.ts | 29 +++++++++++++++++++ .../update_tilemap_settings.js | 0 .../server/lib/__tests__/inspect_settings.js | 0 .../server/lib/inspect_settings.js | 0 8 files changed, 48 insertions(+) rename x-pack/{legacy/plugins/tilemap => plugins/maps_legacy_licensing}/README.md (100%) rename x-pack/{legacy/plugins/tilemap => plugins/maps_legacy_licensing}/index.js (100%) create mode 100644 x-pack/plugins/maps_legacy_licensing/kibana.json create mode 100644 x-pack/plugins/maps_legacy_licensing/public/index.ts create mode 100644 x-pack/plugins/maps_legacy_licensing/public/plugin.ts rename x-pack/{legacy/plugins/tilemap => plugins/maps_legacy_licensing}/public/vis_type_enhancers/update_tilemap_settings.js (100%) rename x-pack/{legacy/plugins/tilemap => plugins/maps_legacy_licensing}/server/lib/__tests__/inspect_settings.js (100%) rename x-pack/{legacy/plugins/tilemap => plugins/maps_legacy_licensing}/server/lib/inspect_settings.js (100%) diff --git a/x-pack/legacy/plugins/tilemap/README.md b/x-pack/plugins/maps_legacy_licensing/README.md similarity index 100% rename from x-pack/legacy/plugins/tilemap/README.md rename to x-pack/plugins/maps_legacy_licensing/README.md diff --git a/x-pack/legacy/plugins/tilemap/index.js b/x-pack/plugins/maps_legacy_licensing/index.js similarity index 100% rename from x-pack/legacy/plugins/tilemap/index.js rename to x-pack/plugins/maps_legacy_licensing/index.js diff --git a/x-pack/plugins/maps_legacy_licensing/kibana.json b/x-pack/plugins/maps_legacy_licensing/kibana.json new file mode 100644 index 0000000000000..0e34cbacefd5e --- /dev/null +++ b/x-pack/plugins/maps_legacy_licensing/kibana.json @@ -0,0 +1,8 @@ +{ + "id": "mapsLegacyLicensing", + "version": "8.0.0", + "kibanaVersion": "kibana", + "server": true, + "ui": true, + "requiredPlugins": ["licensing", "maps_legacy"] +} diff --git a/x-pack/plugins/maps_legacy_licensing/public/index.ts b/x-pack/plugins/maps_legacy_licensing/public/index.ts new file mode 100644 index 0000000000000..edda6118f92dd --- /dev/null +++ b/x-pack/plugins/maps_legacy_licensing/public/index.ts @@ -0,0 +1,11 @@ +/* + * 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. + */ + +import { MapsLegacyLicensing } from './plugin'; + +export function plugin() { + return new MapsLegacyLicensing(); +} diff --git a/x-pack/plugins/maps_legacy_licensing/public/plugin.ts b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts new file mode 100644 index 0000000000000..693b4205fda1f --- /dev/null +++ b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// @ts-ignore +import { CoreSetup, CoreStart, Plugin } from 'kibana/server'; + +/** + * These are the interfaces with your public contracts. You should export these + * for other plugins to use in _their_ `SetupDeps`/`StartDeps` interfaces. + * @public + */ + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface MapsLegacyLicensingSetupDependencies {} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface MapsLegacyLicensingStartDependencies {} + +export type MapsLegacyLicensingSetup = ReturnType; +export type MapsLegacyLicensingStart = ReturnType; + +export class MapsLegacyLicensing + implements Plugin { + public setup(core: CoreSetup, plugins: MapsLegacyLicensingSetupDependencies) {} + + public start(core: CoreStart, plugins: MapsLegacyLicensingStartDependencies) {} +} diff --git a/x-pack/legacy/plugins/tilemap/public/vis_type_enhancers/update_tilemap_settings.js b/x-pack/plugins/maps_legacy_licensing/public/vis_type_enhancers/update_tilemap_settings.js similarity index 100% rename from x-pack/legacy/plugins/tilemap/public/vis_type_enhancers/update_tilemap_settings.js rename to x-pack/plugins/maps_legacy_licensing/public/vis_type_enhancers/update_tilemap_settings.js diff --git a/x-pack/legacy/plugins/tilemap/server/lib/__tests__/inspect_settings.js b/x-pack/plugins/maps_legacy_licensing/server/lib/__tests__/inspect_settings.js similarity index 100% rename from x-pack/legacy/plugins/tilemap/server/lib/__tests__/inspect_settings.js rename to x-pack/plugins/maps_legacy_licensing/server/lib/__tests__/inspect_settings.js diff --git a/x-pack/legacy/plugins/tilemap/server/lib/inspect_settings.js b/x-pack/plugins/maps_legacy_licensing/server/lib/inspect_settings.js similarity index 100% rename from x-pack/legacy/plugins/tilemap/server/lib/inspect_settings.js rename to x-pack/plugins/maps_legacy_licensing/server/lib/inspect_settings.js From e0dc9a113cfa7551cabc02f279f8a4259e4cc81b Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Tue, 14 Apr 2020 16:23:38 -0600 Subject: [PATCH 2/9] Remove unused server-side licensing logic and old index --- x-pack/plugins/maps_legacy_licensing/index.js | 31 ---------------- .../update_tilemap_settings.js | 16 --------- .../server/lib/__tests__/inspect_settings.js | 36 ------------------- .../server/lib/inspect_settings.js | 32 ----------------- 4 files changed, 115 deletions(-) delete mode 100644 x-pack/plugins/maps_legacy_licensing/index.js delete mode 100644 x-pack/plugins/maps_legacy_licensing/public/vis_type_enhancers/update_tilemap_settings.js delete mode 100644 x-pack/plugins/maps_legacy_licensing/server/lib/__tests__/inspect_settings.js delete mode 100644 x-pack/plugins/maps_legacy_licensing/server/lib/inspect_settings.js diff --git a/x-pack/plugins/maps_legacy_licensing/index.js b/x-pack/plugins/maps_legacy_licensing/index.js deleted file mode 100644 index d4105519ee0a7..0000000000000 --- a/x-pack/plugins/maps_legacy_licensing/index.js +++ /dev/null @@ -1,31 +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. - */ - -import { mirrorPluginStatus } from '../../server/lib/mirror_plugin_status'; -import { inspectSettings } from './server/lib/inspect_settings'; -import { resolve } from 'path'; - -export const tilemap = kibana => { - return new kibana.Plugin({ - id: 'tilemap', - configPrefix: 'xpack.tilemap', - require: ['xpack_main', 'vis_type_vislib'], - publicDir: resolve(__dirname, 'public'), - uiExports: { - hacks: ['plugins/tilemap/vis_type_enhancers/update_tilemap_settings'], - }, - init: function(server) { - const thisPlugin = this; - const xpackMainPlugin = server.plugins.xpack_main; - mirrorPluginStatus(xpackMainPlugin, thisPlugin); - xpackMainPlugin.status.once('green', () => { - xpackMainPlugin.info - .feature(thisPlugin.id) - .registerLicenseCheckResultsGenerator(inspectSettings); - }); - }, - }); -}; diff --git a/x-pack/plugins/maps_legacy_licensing/public/vis_type_enhancers/update_tilemap_settings.js b/x-pack/plugins/maps_legacy_licensing/public/vis_type_enhancers/update_tilemap_settings.js deleted file mode 100644 index 294bc31e3893e..0000000000000 --- a/x-pack/plugins/maps_legacy_licensing/public/vis_type_enhancers/update_tilemap_settings.js +++ /dev/null @@ -1,16 +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. - */ - -import { xpackInfo } from 'plugins/xpack_main/services/xpack_info'; -import { npSetup } from 'ui/new_platform'; - -const tileMapPluginInfo = xpackInfo.get('features.tilemap'); - -if (tileMapPluginInfo && (tileMapPluginInfo.license.active || tileMapPluginInfo.license.valid)) { - const { serviceSettings } = npSetup.plugins.mapsLegacy; - serviceSettings.addQueryParams({ license: tileMapPluginInfo.license.uid }); - serviceSettings.disableZoomMessage(); -} diff --git a/x-pack/plugins/maps_legacy_licensing/server/lib/__tests__/inspect_settings.js b/x-pack/plugins/maps_legacy_licensing/server/lib/__tests__/inspect_settings.js deleted file mode 100644 index ce7987ee396b8..0000000000000 --- a/x-pack/plugins/maps_legacy_licensing/server/lib/__tests__/inspect_settings.js +++ /dev/null @@ -1,36 +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. - */ - -import expect from '@kbn/expect'; -import { inspectSettings } from '../../../server/lib/inspect_settings'; - -describe('inspectSettings', function() { - it('should propagate x-pack info', function() { - const mockSettings = { - isAvailable: () => true, - license: { - getUid: () => 'foobar', - isActive: () => true, - isOneOf: () => true, - }, - }; - - const licenseInfo = inspectSettings(mockSettings); - expect(licenseInfo.license.uid).to.equal('foobar'); - expect(licenseInfo.license.active).to.equal(true); - expect(licenseInfo.license.valid).to.equal(true); - }); - - it('should break when unavailable info', function() { - const mockSettings = { - isAvailable: () => false, - }; - - const licenseInfo = inspectSettings(mockSettings); - expect(licenseInfo).to.have.property('message'); - expect(typeof licenseInfo.message === 'string').to.be.ok(); - }); -}); diff --git a/x-pack/plugins/maps_legacy_licensing/server/lib/inspect_settings.js b/x-pack/plugins/maps_legacy_licensing/server/lib/inspect_settings.js deleted file mode 100644 index cd6fb8bd8c110..0000000000000 --- a/x-pack/plugins/maps_legacy_licensing/server/lib/inspect_settings.js +++ /dev/null @@ -1,32 +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. - */ - -export function inspectSettings(xpackInfo) { - if (!xpackInfo || !xpackInfo.isAvailable()) { - return { - message: - 'You cannot use the Tilemap Plugin because license information is not available at this time.', - }; - } - - /** - *Propagate these settings to the client - */ - return { - license: { - uid: xpackInfo.license.getUid(), - active: xpackInfo.license.isActive(), - valid: xpackInfo.license.isOneOf([ - 'trial', - 'standard', - 'basic', - 'gold', - 'platinum', - 'enterprise', - ]), - }, - }; -} From 71c76cc210825010e8c3697c59d6879f7005feaa Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Tue, 14 Apr 2020 16:31:26 -0600 Subject: [PATCH 3/9] Set license in maps_legacy via new plugin --- .../public/map/service_settings.js | 4 ++++ x-pack/index.js | 2 -- .../plugins/maps_legacy_licensing/kibana.json | 4 ++-- .../maps_legacy_licensing/public/plugin.ts | 20 +++++++++++++++++-- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/plugins/maps_legacy/public/map/service_settings.js b/src/plugins/maps_legacy/public/map/service_settings.js index 11c853d39e107..d6496755cd9a5 100644 --- a/src/plugins/maps_legacy/public/map/service_settings.js +++ b/src/plugins/maps_legacy/public/map/service_settings.js @@ -69,6 +69,10 @@ export class ServiceSettings { return origin === ORIGIN.EMS && this._showZoomMessage; } + enableZoomMessage() { + this._showZoomMessage = true; + } + disableZoomMessage() { this._showZoomMessage = false; } diff --git a/x-pack/index.js b/x-pack/index.js index 3126dc17a7107..b45f3d361b779 100644 --- a/x-pack/index.js +++ b/x-pack/index.js @@ -9,7 +9,6 @@ import { graph } from './legacy/plugins/graph'; import { monitoring } from './legacy/plugins/monitoring'; import { reporting } from './legacy/plugins/reporting'; import { security } from './legacy/plugins/security'; -import { tilemap } from './legacy/plugins/tilemap'; import { dashboardMode } from './legacy/plugins/dashboard_mode'; import { logstash } from './legacy/plugins/logstash'; import { beats } from './legacy/plugins/beats_management'; @@ -41,7 +40,6 @@ module.exports = function(kibana) { reporting(kibana), spaces(kibana), security(kibana), - tilemap(kibana), dashboardMode(kibana), logstash(kibana), beats(kibana), diff --git a/x-pack/plugins/maps_legacy_licensing/kibana.json b/x-pack/plugins/maps_legacy_licensing/kibana.json index 0e34cbacefd5e..e98c33d21ec40 100644 --- a/x-pack/plugins/maps_legacy_licensing/kibana.json +++ b/x-pack/plugins/maps_legacy_licensing/kibana.json @@ -2,7 +2,7 @@ "id": "mapsLegacyLicensing", "version": "8.0.0", "kibanaVersion": "kibana", - "server": true, + "server": false, "ui": true, - "requiredPlugins": ["licensing", "maps_legacy"] + "requiredPlugins": ["licensing", "mapsLegacy"] } diff --git a/x-pack/plugins/maps_legacy_licensing/public/plugin.ts b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts index 693b4205fda1f..14b9e94410f19 100644 --- a/x-pack/plugins/maps_legacy_licensing/public/plugin.ts +++ b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts @@ -5,7 +5,7 @@ */ // @ts-ignore -import { CoreSetup, CoreStart, Plugin } from 'kibana/server'; +import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; /** * These are the interfaces with your public contracts. You should export these @@ -23,7 +23,23 @@ export type MapsLegacyLicensingStart = ReturnType; export class MapsLegacyLicensing implements Plugin { - public setup(core: CoreSetup, plugins: MapsLegacyLicensingSetupDependencies) {} + public setup(core: CoreSetup, plugins: MapsLegacyLicensingSetupDependencies) { + const { + licensing, + mapsLegacy: { serviceSettings }, + } = plugins; + if (licensing) { + licensing.license$.subscribe(({ uid, isActive }: { uid: string; isActive: boolean }) => { + if (isActive) { + serviceSettings.addQueryParams({ license: uid }); + serviceSettings.disableZoomMessage(); + } else { + serviceSettings.addQueryParams({ license: undefined }); + serviceSettings.enableZoomMessage(); + } + }); + } + } public start(core: CoreStart, plugins: MapsLegacyLicensingStartDependencies) {} } From 0d4f85cd369166a8f89db65f850a39d69da935b1 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 15 Apr 2020 13:25:44 -0600 Subject: [PATCH 4/9] Change add to set for service settings queryParams function --- .../public/__tests__/map/service_settings.js | 16 ++++++++-------- .../maps_legacy/public/map/service_settings.js | 5 +++-- x-pack/plugins/maps/public/meta.js | 2 +- .../maps_legacy_licensing/public/plugin.ts | 4 ++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/plugins/maps_legacy/public/__tests__/map/service_settings.js b/src/plugins/maps_legacy/public/__tests__/map/service_settings.js index a9272ea396639..4cbe098501c67 100644 --- a/src/plugins/maps_legacy/public/__tests__/map/service_settings.js +++ b/src/plugins/maps_legacy/public/__tests__/map/service_settings.js @@ -143,24 +143,24 @@ describe('service_settings (FKA tilemaptest)', function() { } it('accepts an object', async () => { - serviceSettings.addQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ foo: 'bar' }); tilemapServices = await serviceSettings.getTMSServices(); await assertQuery({ foo: 'bar' }); }); it('merged additions with previous values', async () => { // ensure that changes are always additive - serviceSettings.addQueryParams({ foo: 'bar' }); - serviceSettings.addQueryParams({ bar: 'stool' }); + serviceSettings.setQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ bar: 'stool' }); tilemapServices = await serviceSettings.getTMSServices(); await assertQuery({ foo: 'bar', bar: 'stool' }); }); it('overwrites conflicting previous values', async () => { // ensure that conflicts are overwritten - serviceSettings.addQueryParams({ foo: 'bar' }); - serviceSettings.addQueryParams({ bar: 'stool' }); - serviceSettings.addQueryParams({ foo: 'tstool' }); + serviceSettings.setQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ bar: 'stool' }); + serviceSettings.setQueryParams({ foo: 'tstool' }); tilemapServices = await serviceSettings.getTMSServices(); await assertQuery({ foo: 'tstool', bar: 'stool' }); }); @@ -168,7 +168,7 @@ describe('service_settings (FKA tilemaptest)', function() { it('when overridden, should continue to work', async () => { mapConfig.emsFileApiUrl = emsFileApiUrl2; mapConfig.emsTileApiUrl = emsTileApiUrl2; - serviceSettings.addQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ foo: 'bar' }); tilemapServices = await serviceSettings.getTMSServices(); await assertQuery({ foo: 'bar' }); }); @@ -292,7 +292,7 @@ describe('service_settings (FKA tilemaptest)', function() { describe('File layers', function() { it('should load manifest (all props)', async function() { - serviceSettings.addQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ foo: 'bar' }); const fileLayers = await serviceSettings.getFileLayers(); expect(fileLayers.length).to.be(18); const assertions = fileLayers.map(async function(fileLayer) { diff --git a/src/plugins/maps_legacy/public/map/service_settings.js b/src/plugins/maps_legacy/public/map/service_settings.js index d6496755cd9a5..f4f0d66ee20de 100644 --- a/src/plugins/maps_legacy/public/map/service_settings.js +++ b/src/plugins/maps_legacy/public/map/service_settings.js @@ -152,11 +152,12 @@ export class ServiceSettings { } /** - * Add optional query-parameters to all requests + * Set optional query-parameters for all requests * * @param additionalQueryParams */ - addQueryParams(additionalQueryParams) { + setQueryParams(additionalQueryParams) { + // Functions more as a "set" than an "add" in ems-client this._emsClient.addQueryParams(additionalQueryParams); } diff --git a/x-pack/plugins/maps/public/meta.js b/x-pack/plugins/maps/public/meta.js index d4612554cf00b..ac3a4572e0e70 100644 --- a/x-pack/plugins/maps/public/meta.js +++ b/x-pack/plugins/maps/public/meta.js @@ -80,7 +80,7 @@ export function getEMSClient() { const licenseId = getLicenseId(); if (latestLicenseId !== licenseId) { latestLicenseId = licenseId; - emsClient.addQueryParams({ license: licenseId }); + emsClient.setQueryParams({ license: licenseId }); } return emsClient; } diff --git a/x-pack/plugins/maps_legacy_licensing/public/plugin.ts b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts index 14b9e94410f19..a555d3d08ff84 100644 --- a/x-pack/plugins/maps_legacy_licensing/public/plugin.ts +++ b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts @@ -31,10 +31,10 @@ export class MapsLegacyLicensing if (licensing) { licensing.license$.subscribe(({ uid, isActive }: { uid: string; isActive: boolean }) => { if (isActive) { - serviceSettings.addQueryParams({ license: uid }); + serviceSettings.setQueryParams({ license: uid }); serviceSettings.disableZoomMessage(); } else { - serviceSettings.addQueryParams({ license: undefined }); + serviceSettings.setQueryParams({ license: undefined }); serviceSettings.enableZoomMessage(); } }); From 6ba1460789b6e0ccddf1894c5dcca672a4c2c890 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Thu, 16 Apr 2020 06:37:49 -0600 Subject: [PATCH 5/9] Fix accidentally changed emsClient method call --- x-pack/plugins/maps/public/meta.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/maps/public/meta.js b/x-pack/plugins/maps/public/meta.js index ac3a4572e0e70..d4612554cf00b 100644 --- a/x-pack/plugins/maps/public/meta.js +++ b/x-pack/plugins/maps/public/meta.js @@ -80,7 +80,7 @@ export function getEMSClient() { const licenseId = getLicenseId(); if (latestLicenseId !== licenseId) { latestLicenseId = licenseId; - emsClient.setQueryParams({ license: licenseId }); + emsClient.addQueryParams({ license: licenseId }); } return emsClient; } From 8988ed09684892d26a29682fb48467ba8d3ae6c0 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Thu, 16 Apr 2020 08:34:41 -0600 Subject: [PATCH 6/9] Require at least a basic license --- x-pack/plugins/maps_legacy_licensing/public/plugin.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/maps_legacy_licensing/public/plugin.ts b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts index a555d3d08ff84..21b3d39e10caf 100644 --- a/x-pack/plugins/maps_legacy_licensing/public/plugin.ts +++ b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts @@ -29,8 +29,9 @@ export class MapsLegacyLicensing mapsLegacy: { serviceSettings }, } = plugins; if (licensing) { - licensing.license$.subscribe(({ uid, isActive }: { uid: string; isActive: boolean }) => { - if (isActive) { + licensing.license$.subscribe(license => { + const { uid, isActive }: { uid: string; isActive: boolean } = license; + if (isActive && license.hasAtLeast('basic')) { serviceSettings.setQueryParams({ license: uid }); serviceSettings.disableZoomMessage(); } else { From 473437651ca455cbfca80be9a9514ce1d0caa041 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Thu, 16 Apr 2020 08:46:08 -0600 Subject: [PATCH 7/9] Type updates --- x-pack/plugins/maps_legacy_licensing/public/plugin.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/maps_legacy_licensing/public/plugin.ts b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts index 21b3d39e10caf..69c25efd96e75 100644 --- a/x-pack/plugins/maps_legacy_licensing/public/plugin.ts +++ b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -// @ts-ignore import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; +import { LicensingPluginSetup, ILicense } from '../../licensing/public'; /** * These are the interfaces with your public contracts. You should export these @@ -14,7 +14,10 @@ import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; */ // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface MapsLegacyLicensingSetupDependencies {} +export interface MapsLegacyLicensingSetupDependencies { + licensing: LicensingPluginSetup; + mapsLegacy: any; +} // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface MapsLegacyLicensingStartDependencies {} @@ -29,8 +32,8 @@ export class MapsLegacyLicensing mapsLegacy: { serviceSettings }, } = plugins; if (licensing) { - licensing.license$.subscribe(license => { - const { uid, isActive }: { uid: string; isActive: boolean } = license; + licensing.license$.subscribe((license: ILicense) => { + const { uid, isActive } = license; if (isActive && license.hasAtLeast('basic')) { serviceSettings.setQueryParams({ license: uid }); serviceSettings.disableZoomMessage(); From 7733a70fe461cdc3123bb9a35b8f48b515e434ee Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Fri, 17 Apr 2020 10:33:07 -0600 Subject: [PATCH 8/9] Remove unneeded legacy license test --- x-pack/test/licensing_plugin/legacy/updates.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/x-pack/test/licensing_plugin/legacy/updates.ts b/x-pack/test/licensing_plugin/legacy/updates.ts index 5fa1299d1f285..ed533f1d6cc32 100644 --- a/x-pack/test/licensing_plugin/legacy/updates.ts +++ b/x-pack/test/licensing_plugin/legacy/updates.ts @@ -55,9 +55,6 @@ export default function(ftrContext: FtrProviderContext) { .expect(200); expect(legacyBasicLicense.license?.type).to.be('basic'); expect(legacyBasicLicense.features).to.have.property('security'); - expect(legacyBasicLicenseHeaders['kbn-xpack-sig']).to.not.be( - legacyInitialLicenseHeaders['kbn-xpack-sig'] - ); // banner shown only when license expired not just deleted await testSubjects.missingOrFail('licenseExpiredBanner'); From d7df0dae2bb1c345fa870d68cfdbf81c1b62f5d3 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Fri, 17 Apr 2020 11:46:05 -0600 Subject: [PATCH 9/9] Remove unused headers in test --- x-pack/test/licensing_plugin/legacy/updates.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/x-pack/test/licensing_plugin/legacy/updates.ts b/x-pack/test/licensing_plugin/legacy/updates.ts index ed533f1d6cc32..03b61b9db87f8 100644 --- a/x-pack/test/licensing_plugin/legacy/updates.ts +++ b/x-pack/test/licensing_plugin/legacy/updates.ts @@ -50,9 +50,7 @@ export default function(ftrContext: FtrProviderContext) { await scenario.startBasic(); await scenario.waitForPluginToDetectLicenseUpdate(); - const { body: legacyBasicLicense, header: legacyBasicLicenseHeaders } = await supertest - .get('/api/xpack/v1/info') - .expect(200); + const { body: legacyBasicLicense } = await supertest.get('/api/xpack/v1/info').expect(200); expect(legacyBasicLicense.license?.type).to.be('basic'); expect(legacyBasicLicense.features).to.have.property('security');