Skip to content

Commit

Permalink
[Remote clusters] Fix regression with xpack.remote_clusters.ui.enable…
Browse files Browse the repository at this point in the history
…d setting (#57895)
  • Loading branch information
alisonelizabeth authored Feb 19, 2020
1 parent faac5be commit cf743f3
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 31 deletions.
4 changes: 3 additions & 1 deletion x-pack/plugins/remote_clusters/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { PluginInitializerContext } from 'kibana/public';
import { RemoteClustersUIPlugin } from './plugin';

export const plugin = () => new RemoteClustersUIPlugin();
export const plugin = (initializerContext: PluginInitializerContext) =>
new RemoteClustersUIPlugin(initializerContext);
72 changes: 43 additions & 29 deletions x-pack/plugins/remote_clusters/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,64 @@
*/

import { i18n } from '@kbn/i18n';
import { CoreSetup, Plugin, CoreStart } from 'kibana/public';
import { CoreSetup, Plugin, CoreStart, PluginInitializerContext } from 'kibana/public';
import { init as initBreadcrumbs } from './application/services/breadcrumb';
import { init as initDocumentation } from './application/services/documentation';
import { init as initHttp } from './application/services/http';
import { init as initUiMetric } from './application/services/ui_metric';
import { init as initNotification } from './application/services/notification';
import { init as initRedirect } from './application/services/redirect';
import { Dependencies } from './types';
import { Dependencies, ClientConfigType } from './types';

export class RemoteClustersUIPlugin implements Plugin<void, void, Dependencies, any> {
constructor(private readonly initializerContext: PluginInitializerContext) {}

setup(
{ notifications: { toasts }, http, getStartServices }: CoreSetup,
{ management, usageCollection }: Dependencies
) {
const esSection = management.sections.getSection('elasticsearch');

esSection!.registerApp({
id: 'remote_clusters',
title: i18n.translate('xpack.remoteClusters.appTitle', {
defaultMessage: 'Remote Clusters',
}),
mount: async ({ element, setBreadcrumbs }) => {
const [core] = await getStartServices();
const {
i18n: { Context: i18nContext },
docLinks,
fatalErrors,
} = core;

// Initialize services
initBreadcrumbs(setBreadcrumbs);
initDocumentation(docLinks);
initUiMetric(usageCollection);
initNotification(toasts, fatalErrors);
initHttp(http);

const { renderApp } = await import('./application');
return renderApp(element, i18nContext);
},
});
const {
ui: { enabled: isRemoteClustersUiEnabled },
} = this.initializerContext.config.get<ClientConfigType>();

if (isRemoteClustersUiEnabled) {
const esSection = management.sections.getSection('elasticsearch');

esSection!.registerApp({
id: 'remote_clusters',
title: i18n.translate('xpack.remoteClusters.appTitle', {
defaultMessage: 'Remote Clusters',
}),
mount: async ({ element, setBreadcrumbs }) => {
const [core] = await getStartServices();
const {
i18n: { Context: i18nContext },
docLinks,
fatalErrors,
} = core;

// Initialize services
initBreadcrumbs(setBreadcrumbs);
initDocumentation(docLinks);
initUiMetric(usageCollection);
initNotification(toasts, fatalErrors);
initHttp(http);

const { renderApp } = await import('./application');
return renderApp(element, i18nContext);
},
});
}
}

start({ application }: CoreStart) {
initRedirect(application.navigateToApp);
const {
ui: { enabled: isRemoteClustersUiEnabled },
} = this.initializerContext.config.get<ClientConfigType>();

if (isRemoteClustersUiEnabled) {
initRedirect(application.navigateToApp);
}
}

stop() {}
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/remote_clusters/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export interface Dependencies {
usageCollection: UsageCollectionSetup;
}

export interface ClientConfigType {
ui: {
enabled: boolean;
};
}

export { RegisterManagementAppArgs };

export { I18nStart };
5 changes: 4 additions & 1 deletion x-pack/plugins/remote_clusters/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import { PluginConfigDescriptor } from 'kibana/server';

export const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: true }),
ui: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
});

export type ConfigType = TypeOf<typeof configSchema>;

export const config: PluginConfigDescriptor<ConfigType> = {
schema: configSchema,
exposeToBrowser: {
enabled: true,
ui: true,
},
};

0 comments on commit cf743f3

Please sign in to comment.