Skip to content

Commit

Permalink
remove LegacyInternals
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Sep 22, 2020
1 parent 6ba8682 commit 7e4a35b
Show file tree
Hide file tree
Showing 20 changed files with 8 additions and 451 deletions.
7 changes: 1 addition & 6 deletions src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,7 @@ export {
SavedObjectsMigrationVersion,
} from './types';

export {
LegacyServiceSetupDeps,
LegacyServiceStartDeps,
LegacyConfig,
LegacyInternals,
} from './legacy';
export { LegacyServiceSetupDeps, LegacyServiceStartDeps, LegacyConfig } from './legacy';

export {
CoreStatus,
Expand Down
2 changes: 0 additions & 2 deletions src/core/server/legacy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
/** @internal */
export { ensureValidConfiguration } from './config';
/** @internal */
export { LegacyInternals } from './legacy_internals';
/** @internal */
export { LegacyService, ILegacyService } from './legacy_service';
/** @internal */
export * from './types';
121 changes: 0 additions & 121 deletions src/core/server/legacy/legacy_internals.test.ts

This file was deleted.

58 changes: 0 additions & 58 deletions src/core/server/legacy/legacy_internals.ts

This file was deleted.

12 changes: 1 addition & 11 deletions src/core/server/legacy/legacy_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ import { CspConfigType, config as cspConfig } from '../csp';
import { DevConfig, DevConfigType, config as devConfig } from '../dev';
import { BasePathProxyServer, HttpConfig, HttpConfigType, config as httpConfig } from '../http';
import { Logger } from '../logging';
import {
ILegacyInternals,
LegacyServiceSetupDeps,
LegacyServiceStartDeps,
LegacyConfig,
LegacyVars,
} from './types';
import { LegacyInternals } from './legacy_internals';
import { LegacyServiceSetupDeps, LegacyServiceStartDeps, LegacyConfig, LegacyVars } from './types';
import { CoreSetup, CoreStart } from '..';

interface LegacyKbnServer {
Expand Down Expand Up @@ -81,7 +74,6 @@ export class LegacyService implements CoreService {
private update$?: ConnectableObservable<[Config, PathConfigType]>;
private legacyRawConfig?: LegacyConfig;
private settings?: LegacyVars;
public legacyInternals?: ILegacyInternals;

constructor(private readonly coreContext: CoreContext) {
const { logger, configService } = coreContext;
Expand Down Expand Up @@ -140,7 +132,6 @@ export class LegacyService implements CoreService {
this.legacyRawConfig!.set('server.uuid', setupDeps.core.environment.instanceUuid);

this.setupDeps = setupDeps;
this.legacyInternals = new LegacyInternals();
}

public async start(startDeps: LegacyServiceStartDeps) {
Expand Down Expand Up @@ -315,7 +306,6 @@ export class LegacyService implements CoreService {
uiPlugins: setupDeps.uiPlugins,
elasticsearch: setupDeps.core.elasticsearch,
rendering: setupDeps.core.rendering,
legacy: this.legacyInternals,
},
logger: this.coreContext.logger,
});
Expand Down
55 changes: 0 additions & 55 deletions src/core/server/legacy/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
* under the License.
*/

import { Server } from 'hapi';

import { KibanaRequest, LegacyRequest } from '../http';
import { InternalCoreSetup, InternalCoreStart } from '../internal_types';
import { PluginsServiceSetup, PluginsServiceStart, UiPlugins } from '../plugins';
import { InternalRenderingServiceSetup } from '../rendering';
Expand Down Expand Up @@ -49,33 +46,6 @@ export interface LegacyConfig {
set(config: LegacyVars): void;
}

/**
* @internal
* @deprecated
*/
export interface VarsProvider {
fn: (server: Server, configValue: any) => LegacyVars;
pluginSpec: {
readConfigValue(config: any, key: string | string[]): any;
};
}

/**
* @internal
* @deprecated
*/
export type VarsInjector = () => LegacyVars;

/**
* @internal
* @deprecated
*/
export type VarsReplacer = (
vars: LegacyVars,
request: LegacyRequest,
server: Server
) => LegacyVars | Promise<LegacyVars>;

/**
* @public
* @deprecated
Expand Down Expand Up @@ -103,28 +73,3 @@ export interface LegacyServiceSetupConfig {
legacyConfig: LegacyConfig;
settings: LegacyVars;
}

/**
* @internal
* @deprecated
*/
export interface ILegacyInternals {
/**
* Inject UI app vars for a particular plugin
*/
injectUiAppVars(id: string, injector: VarsInjector): void;

/**
* Get all the merged injected UI app vars for a particular plugin
*/
getInjectedUiAppVars(id: string): Promise<LegacyVars>;

/**
* Get the metadata vars for a particular plugin
*/
getVars(
id: string,
request: KibanaRequest | LegacyRequest,
injected?: LegacyVars
): Promise<LegacyVars>;
}
2 changes: 0 additions & 2 deletions src/core/server/rendering/__mocks__/rendering_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ export const setupMock: jest.Mocked<InternalRenderingServiceSetup> = {
render: jest.fn(),
};
export const mockSetup = jest.fn().mockResolvedValue(setupMock);
export const mockStart = jest.fn();
export const mockStop = jest.fn();
export const mockRenderingService: jest.Mocked<IRenderingService> = {
setup: mockSetup,
start: mockStart,
stop: mockStop,
};
export const RenderingService = jest.fn<IRenderingService, [typeof mockRenderingServiceParams]>(
Expand Down
7 changes: 0 additions & 7 deletions src/core/server/rendering/rendering_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ describe('RenderingService', () => {
registered: { name: 'title' },
});
render = (await service.setup(mockRenderingSetupDeps)).render;
await service.start({
legacy: {
legacyInternals: {
getVars: () => ({}),
},
},
} as any);
});

it('renders "core" page', async () => {
Expand Down
15 changes: 2 additions & 13 deletions src/core/server/rendering/rendering_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { take } from 'rxjs/operators';

import { i18n } from '@kbn/i18n';

import { UiPlugins } from '../plugins';
import { CoreService } from '../../types';
import { CoreContext } from '../core_context';
import { Template } from './views';
import { LegacyService } from '../legacy';
import {
IRenderOptions,
RenderingSetupDeps,
Expand All @@ -36,8 +33,7 @@ import {
} from './types';

/** @internal */
export class RenderingService implements CoreService<InternalRenderingServiceSetup> {
private legacyInternals?: LegacyService['legacyInternals'];
export class RenderingService {
constructor(private readonly coreContext: CoreContext) {}

public async setup({
Expand All @@ -51,9 +47,6 @@ export class RenderingService implements CoreService<InternalRenderingServiceSet
uiSettings,
{ app = { getId: () => 'core' }, includeUserSettings = true, vars }: IRenderOptions = {}
) => {
if (!this.legacyInternals) {
throw new Error('Cannot render before "start"');
}
const env = {
mode: this.coreContext.env.mode,
packageInfo: this.coreContext.env.packageInfo,
Expand Down Expand Up @@ -86,7 +79,7 @@ export class RenderingService implements CoreService<InternalRenderingServiceSet
translationsUrl: `${basePath}/translations/${i18n.getLocale()}.json`,
},
csp: { warnLegacyBrowsers: http.csp.warnLegacyBrowsers },
vars: vars ?? (await this.legacyInternals!.getVars('core', request)),
vars: vars ?? {},
uiPlugins: await Promise.all(
[...uiPlugins.public].map(async ([id, plugin]) => ({
id,
Expand Down Expand Up @@ -114,10 +107,6 @@ export class RenderingService implements CoreService<InternalRenderingServiceSet
};
}

public async start({ legacy }: { legacy: LegacyService }) {
this.legacyInternals = legacy.legacyInternals;
}

public async stop() {}

private async getUiConfig(uiPlugins: UiPlugins, pluginId: string) {
Expand Down
Loading

0 comments on commit 7e4a35b

Please sign in to comment.