[7.6] [Maps] Add missing license to requests in maps embeddables (#59207) (#59336)

* [Maps] Add missing license to requests in maps embeddables (#59207)

* Pull core service init out into separate function

* Call bind function from embeddable factory constructor

* Move inspector init back to start method. Remove old license check file

* Add TS types

* Fix remaining merge issues
This commit is contained in:
Aaron Caldwell 2020-03-04 15:26:59 -07:00 committed by GitHub
parent 0522b39706
commit a967cbc86c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 43 deletions

View file

@ -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(),
};
}

View file

@ -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;

View file

@ -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<MapsPlugin['setup']>;
export type MapsPluginStart = ReturnType<MapsPlugin['start']>;
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<MapsPluginSetup, MapsPluginStart> {
public setup(core: any, plugins: any) {
const {
__LEGACY: { uiModules },
np: { licensing },
np,
} = plugins;
uiModules
@ -34,9 +41,7 @@ export class MapsPlugin implements Plugin<MapsPluginSetup, MapsPluginStart> {
return reactDirective(wrapInI18nContext(MapListing));
});
if (licensing) {
licensing.license$.subscribe(({ uid }: { uid: string }) => setLicenseId(uid));
}
bindSetupCoreAndPlugins(core, np);
}
public start(core: CoreStart, plugins: any) {}