Skip to content

Commit

Permalink
Re-introduce injected elasticsearch variable and use it in public
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Jan 23, 2020
1 parent a3c85d9 commit 212a1a3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
7 changes: 7 additions & 0 deletions src/legacy/core_plugins/console_legacy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
*/

import { first } from 'rxjs/operators';
import { head } from 'lodash';
import { resolve } from 'path';
import url from 'url';

// TODO: Remove this hack once we can get the ES config we need for Console proxy a better way.
let _legacyEsConfig: any;
Expand All @@ -39,6 +41,11 @@ export default function(kibana: any) {

uiExports: {
styleSheetPaths: resolve(__dirname, 'public/styles/index.scss'),
injectDefaultVars: () => ({
elasticsearchUrl: url.format(
Object.assign(url.parse(head(_legacyEsConfig.hosts)), { auth: false })
),
}),
},
} as any);
}
6 changes: 2 additions & 4 deletions src/plugins/console/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
* under the License.
*/

import { PluginInitializerContext } from 'kibana/public';

import { ConsoleUIPlugin } from './plugin';

export { ConsoleUIPlugin as Plugin };

export { Panel, PanelsContainer } from './application/components/split_panel';

export function plugin(ctx: PluginInitializerContext) {
return new ConsoleUIPlugin(ctx);
export function plugin() {
return new ConsoleUIPlugin();
}
10 changes: 7 additions & 3 deletions src/plugins/console/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
import { render, unmountComponentAtNode } from 'react-dom';
import { i18n } from '@kbn/i18n';

import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'kibana/public';
import { CoreSetup, CoreStart, Plugin } from 'kibana/public';

import { FeatureCatalogueCategory } from '../../home/public';

import { AppSetupUIPluginDependencies } from './types';

export class ConsoleUIPlugin implements Plugin<void, void, AppSetupUIPluginDependencies> {
constructor(private readonly ctx: PluginInitializerContext) {}
constructor() {}

async setup(
{ notifications, getStartServices }: CoreSetup,
Expand Down Expand Up @@ -56,7 +56,11 @@ export class ConsoleUIPlugin implements Plugin<void, void, AppSetupUIPluginDepen
enableRouting: false,
mount: async ({ core: { docLinks, i18n: i18nDep } }, { element }) => {
const { boot } = await import('./application');
const { elasticsearchUrl } = this.ctx.config.get<any>();
const [{ injectedMetadata }] = await getStartServices();
const elasticsearchUrl = injectedMetadata.getInjectedVar(
'elasticsearchUrl',
'http://localhost:9200'
) as string;
render(
boot({
docLinkVersion: docLinks.DOC_LINK_VERSION,
Expand Down
13 changes: 10 additions & 3 deletions src/plugins/console/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ export class ConsoleServerPlugin implements Plugin<ConsoleSetup> {
this.log = this.ctx.logger.get();
}

async setup({ http }: CoreSetup) {
async setup({ http, capabilities, getStartServices }: CoreSetup) {
capabilities.registerProvider(() => ({
dev_tools: {
show: true,
save: true,
},
}));

const config = await this.ctx.config
.create()
.pipe(first())
Expand Down Expand Up @@ -69,6 +76,6 @@ export class ConsoleServerPlugin implements Plugin<ConsoleSetup> {
addProcessorDefinition,
};
}
async start() {}
stop() {}

start() {}
}

0 comments on commit 212a1a3

Please sign in to comment.