Skip to content

Commit

Permalink
Add missing first() pipe operator to read license$
Browse files Browse the repository at this point in the history
  • Loading branch information
sebelga committed Mar 16, 2020
1 parent 8a62038 commit 761e9fa
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export const PLUGIN = {
title: i18n.translate('xpack.licenseMgmt.managementSectionDisplayName', {
defaultMessage: 'License Management',
}),
id: 'licenseManagement',
id: 'license_management',
};
7 changes: 2 additions & 5 deletions x-pack/plugins/license_management/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"version": "kibana",
"server": true,
"ui": true,
"requiredPlugins": [
"home",
"management",
"licensing"
],
"requiredPlugins": ["home", "licensing", "management"],
"optionalPlugins": ["telemetry"],
"configPath": ["xpack", "license_management"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export interface AppDependencies {
breadcrumbService: BreadcrumbService;
};
plugins: {
telemetry: TelemetryPluginSetup;
licensing: LicensingPluginSetup;
telemetry?: TelemetryPluginSetup;
};
docLinks: {
security: string;
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/license_management/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { PluginInitializerContext } from 'src/core/public';

import { LicenseManagementUIPlugin } from './plugin';
import './application/index.scss';

Expand Down
21 changes: 13 additions & 8 deletions x-pack/plugins/license_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { first } from 'rxjs/operators';
import { CoreSetup, Plugin, PluginInitializerContext } from 'src/core/public';

import { TelemetryPluginSetup } from '../../../../src/plugins/telemetry/public';
Expand All @@ -15,9 +15,9 @@ import { AppDependencies } from './application';
import { BreadcrumbService } from './application/breadcrumbs';

interface PluginsDependencies {
telemetry: TelemetryPluginSetup;
management: ManagementSetup;
licensing: LicensingPluginSetup;
telemetry?: TelemetryPluginSetup;
}

export class LicenseManagementUIPlugin implements Plugin<void, void, any, any> {
Expand All @@ -34,40 +34,45 @@ export class LicenseManagementUIPlugin implements Plugin<void, void, any, any> {
}

const { getStartServices } = coreSetup;
const { management } = plugins;
const { management, telemetry, licensing } = plugins;

management.sections.getSection('elasticsearch')!.registerApp({
id: PLUGIN.id,
title: PLUGIN.title,
order: 99,
mount: async ({ element, setBreadcrumbs }) => {
const [core] = await getStartServices();
const initialLicense = await plugins.licensing.license$.toPromise();
const initialLicense = await plugins.licensing.license$.pipe(first()).toPromise();

// Setup documentation links
const { docLinks } = core;
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = docLinks;
const esBase = `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}`;
const appDocLinks = {
security: `${esBase}/security-settings.html`,
};

// Setup services
this.breadcrumbService.setup(setBreadcrumbs);

const appDependencies: AppDependencies = {
core,
config,
plugins,
plugins: {
licensing,
telemetry,
},
services: {
breadcrumbService: this.breadcrumbService,
},
store: {
initialLicense,
},
docLinks: {
security: `${esBase}/security-settings.html`,
},
docLinks: appDocLinks,
};

const { renderApp } = await import('./application');

return renderApp(element, appDependencies);
},
});
Expand Down

0 comments on commit 761e9fa

Please sign in to comment.