Skip to content

Commit

Permalink
[Observability] Update plugin start/setup types naming (#95301)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 authored Mar 26, 2021
1 parent 33b81b1 commit b9f5d0c
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 40 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/apm/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ConfigSchema } from '.';
import {
FetchDataParams,
HasDataParams,
ObservabilityPluginSetup,
ObservabilityPublicSetup,
} from '../../observability/public';
import {
AppMountParameters,
Expand Down Expand Up @@ -52,7 +52,7 @@ export interface ApmPluginSetupDeps {
home?: HomePublicPluginSetup;
licensing: LicensingPluginSetup;
triggersActionsUi: TriggersAndActionsUIPublicPluginSetup;
observability?: ObservabilityPluginSetup;
observability?: ObservabilityPublicSetup;
}

export interface ApmPluginStartDeps {
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/infra/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import type {
} from '../../../plugins/triggers_actions_ui/public';
import type { DataEnhancedSetup, DataEnhancedStart } from '../../data_enhanced/public';
import type {
ObservabilityPluginSetup,
ObservabilityPluginStart,
ObservabilityPublicSetup,
ObservabilityPublicStart,
} from '../../observability/public';
import type { SpacesPluginStart } from '../../spaces/public';
import { MlPluginStart, MlPluginSetup } from '../../ml/public';
Expand All @@ -33,7 +33,7 @@ export type InfraClientStartExports = void;
export interface InfraClientSetupDeps {
dataEnhanced: DataEnhancedSetup;
home?: HomePublicPluginSetup;
observability: ObservabilityPluginSetup;
observability: ObservabilityPublicSetup;
triggersActionsUi: TriggersAndActionsUIPublicPluginSetup;
usageCollection: UsageCollectionSetup;
ml: MlPluginSetup;
Expand All @@ -43,7 +43,7 @@ export interface InfraClientSetupDeps {
export interface InfraClientStartDeps {
data: DataPublicPluginStart;
dataEnhanced: DataEnhancedStart;
observability: ObservabilityPluginStart;
observability: ObservabilityPublicStart;
spaces: SpacesPluginStart;
triggersActionsUi: TriggersAndActionsUIPublicPluginStart;
usageCollection: UsageCollectionStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createMemoryHistory } from 'history';
import React from 'react';
import { Observable } from 'rxjs';
import { AppMountParameters, CoreStart } from 'src/core/public';
import { ObservabilityPluginSetupDeps } from '../plugin';
import { ObservabilityPublicPluginsStart } from '../plugin';
import { renderApp } from './';

describe('renderApp', () => {
Expand All @@ -32,7 +32,7 @@ describe('renderApp', () => {
},
},
},
} as unknown) as ObservabilityPluginSetupDeps;
} as unknown) as ObservabilityPublicPluginsStart;
const core = ({
application: { currentAppId$: new Observable(), navigateToUrl: () => {} },
chrome: {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/observability/public/application/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { PluginContext } from '../context/plugin_context';
import { usePluginContext } from '../hooks/use_plugin_context';
import { useRouteParams } from '../hooks/use_route_params';
import { ObservabilityPluginSetupDeps } from '../plugin';
import { ObservabilityPublicPluginsStart } from '../plugin';
import { HasDataContextProvider } from '../context/has_data_context';
import { Breadcrumbs, routes } from '../routes';
import { Storage } from '../../../../../src/plugins/kibana_utils/public';
Expand Down Expand Up @@ -68,7 +68,7 @@ function App() {

export const renderApp = (
core: CoreStart,
plugins: ObservabilityPluginSetupDeps,
plugins: ObservabilityPublicPluginsStart,
appMountParameters: AppMountParameters
) => {
const { element, history } = appMountParameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as hasDataHook from '../../../../hooks/use_has_data';
import * as pluginContext from '../../../../hooks/use_plugin_context';
import { HasDataContextValue } from '../../../../context/has_data_context';
import { AppMountParameters, CoreStart } from 'kibana/public';
import { ObservabilityPluginSetupDeps } from '../../../../plugin';
import { ObservabilityPublicPluginsStart } from '../../../../plugin';

jest.mock('react-router-dom', () => ({
useLocation: () => ({
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('APMSection', () => {
},
},
},
} as unknown) as ObservabilityPluginSetupDeps,
} as unknown) as ObservabilityPublicPluginsStart,
}));
});
it('renders with transaction series and stats', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { HasDataContextValue } from '../../../../context/has_data_context';
import * as fetcherHook from '../../../../hooks/use_fetcher';
import * as hasDataHook from '../../../../hooks/use_has_data';
import * as pluginContext from '../../../../hooks/use_plugin_context';
import { ObservabilityPluginSetupDeps } from '../../../../plugin';
import { ObservabilityPublicPluginsStart } from '../../../../plugin';
import { render } from '../../../../utils/test_helper';
import { UXSection } from './';
import { response } from './mock_data/ux.mock';
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('UXSection', () => {
},
},
},
} as unknown) as ObservabilityPluginSetupDeps,
} as unknown) as ObservabilityPublicPluginsStart,
}));
});
it('renders with core web vitals', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import { createContext } from 'react';
import { AppMountParameters, CoreStart } from 'kibana/public';
import { ObservabilityPluginSetupDeps } from '../plugin';
import { ObservabilityPublicPluginsStart } from '../plugin';

export interface PluginContextValue {
appMountParameters: AppMountParameters;
core: CoreStart;
plugins: ObservabilityPluginSetupDeps;
plugins: ObservabilityPublicPluginsStart;
}

export const PluginContext = createContext({} as PluginContextValue);
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { useTimeRange } from './use_time_range';
import * as pluginContext from './use_plugin_context';
import { AppMountParameters, CoreStart } from 'kibana/public';
import { ObservabilityPluginSetupDeps } from '../plugin';
import { ObservabilityPublicPluginsStart } from '../plugin';
import * as kibanaUISettings from './use_kibana_ui_settings';

jest.mock('react-router-dom', () => ({
Expand Down Expand Up @@ -36,7 +36,7 @@ describe('useTimeRange', () => {
},
},
},
} as unknown) as ObservabilityPluginSetupDeps,
} as unknown) as ObservabilityPublicPluginsStart,
}));
jest.spyOn(kibanaUISettings, 'useKibanaUISettings').mockImplementation(() => ({
from: '2020-10-08T05:00:00.000Z',
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('useTimeRange', () => {
},
},
},
} as unknown) as ObservabilityPluginSetupDeps,
} as unknown) as ObservabilityPublicPluginsStart,
}));
});
it('returns ranges and absolute times from kibana default settings', () => {
Expand Down
24 changes: 19 additions & 5 deletions x-pack/plugins/observability/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,26 @@
*/

import { PluginInitializerContext, PluginInitializer } from 'kibana/public';
import { Plugin, ObservabilityPluginSetup, ObservabilityPluginStart } from './plugin';
export type { ObservabilityPluginSetup, ObservabilityPluginStart };
import {
Plugin,
ObservabilityPublicPluginsStart,
ObservabilityPublicPluginsSetup,
ObservabilityPublicStart,
ObservabilityPublicSetup,
} from './plugin';
export type {
ObservabilityPublicSetup,
ObservabilityPublicStart,
ObservabilityPublicPluginsSetup,
ObservabilityPublicPluginsStart,
};

export const plugin: PluginInitializer<ObservabilityPluginSetup, ObservabilityPluginStart> = (
context: PluginInitializerContext
) => {
export const plugin: PluginInitializer<
ObservabilityPublicSetup,
ObservabilityPublicStart,
ObservabilityPublicPluginsSetup,
ObservabilityPublicPluginsStart
> = (context: PluginInitializerContext) => {
return new Plugin(context);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { UI_SETTINGS } from '../../../../../../src/plugins/data/public';
import { HasDataContextProvider } from '../../context/has_data_context';
import { PluginContext } from '../../context/plugin_context';
import { registerDataHandler, unregisterDataHandler } from '../../data_handler';
import { ObservabilityPluginSetupDeps } from '../../plugin';
import { ObservabilityPublicPluginsStart } from '../../plugin';
import { OverviewPage } from './';
import { alertsFetchData } from './mock/alerts.mock';
import { emptyResponse as emptyAPMResponse, fetchApmData } from './mock/apm.mock';
Expand Down Expand Up @@ -51,7 +51,7 @@ const withCore = makeDecorator({
timefilter: { timefilter: { setTime: () => {}, getTime: () => ({}) } },
},
},
} as unknown) as ObservabilityPluginSetupDeps,
} as unknown) as ObservabilityPublicPluginsStart,
}}
>
<EuiThemeProvider>
Expand Down
37 changes: 27 additions & 10 deletions x-pack/plugins/observability/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { BehaviorSubject } from 'rxjs';
import { i18n } from '@kbn/i18n';
import { DataPublicPluginSetup } from '../../../../src/plugins/data/public';
import { DataPublicPluginSetup, DataPublicPluginStart } from '../../../../src/plugins/data/public';
import {
AppMountParameters,
AppUpdater,
Expand All @@ -17,36 +17,53 @@ import {
PluginInitializerContext,
CoreStart,
} from '../../../../src/core/public';
import { HomePublicPluginSetup } from '../../../../src/plugins/home/public';
import { HomePublicPluginSetup, HomePublicPluginStart } from '../../../../src/plugins/home/public';
import { registerDataHandler } from './data_handler';
import { toggleOverviewLinkInNav } from './toggle_overview_link_in_nav';
import { LensPublicStart } from '../../lens/public';

export interface ObservabilityPluginSetup {
export interface ObservabilityPublicSetup {
dashboard: { register: typeof registerDataHandler };
}

export interface ObservabilityPluginSetupDeps {
home?: HomePublicPluginSetup;
export interface ObservabilityPublicPluginsSetup {
data: DataPublicPluginSetup;
home?: HomePublicPluginSetup;
}

export interface ObservabilityPublicPluginsStart {
home?: HomePublicPluginStart;
data: DataPublicPluginStart;
lens: LensPublicStart;
}

export type ObservabilityPluginStart = void;
export type ObservabilityPublicStart = void;

export class Plugin implements PluginClass<ObservabilityPluginSetup, ObservabilityPluginStart> {
export class Plugin
implements
PluginClass<
ObservabilityPublicSetup,
ObservabilityPublicStart,
ObservabilityPublicPluginsSetup,
ObservabilityPublicPluginsStart
> {
private readonly appUpdater$ = new BehaviorSubject<AppUpdater>(() => ({}));

constructor(context: PluginInitializerContext) {}

public setup(core: CoreSetup, plugins: ObservabilityPluginSetupDeps) {
public setup(
core: CoreSetup<ObservabilityPublicPluginsStart>,
plugins: ObservabilityPublicPluginsSetup
) {
const category = DEFAULT_APP_CATEGORIES.observability;
const euiIconType = 'logoObservability';
const mount = async (params: AppMountParameters<unknown>) => {
// Load application bundle
const { renderApp } = await import('./application');
// Get start services
const [coreStart] = await core.getStartServices();
const [coreStart, startPlugins] = await core.getStartServices();

return renderApp(coreStart, plugins, params);
return renderApp(coreStart, startPlugins, params);
};
const updater$ = this.appUpdater$;

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/observability/public/utils/test_helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { of } from 'rxjs';
import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public';
import translations from '../../../translations/translations/ja-JP.json';
import { PluginContext } from '../context/plugin_context';
import { ObservabilityPluginSetupDeps } from '../plugin';
import { ObservabilityPublicPluginsStart } from '../plugin';
import { EuiThemeProvider } from '../../../../../src/plugins/kibana_react/common';

const appMountParameters = ({ setHeaderActionMenu: () => {} } as unknown) as AppMountParameters;
Expand All @@ -32,7 +32,7 @@ export const core = ({

const plugins = ({
data: { query: { timefilter: { timefilter: { setTime: jest.fn() } } } },
} as unknown) as ObservabilityPluginSetupDeps;
} as unknown) as ObservabilityPublicPluginsStart;

export const render = (component: React.ReactNode) => {
return testLibRender(
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/observability/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
{ "path": "../../../src/plugins/usage_collection/tsconfig.json" },
{ "path": "../alerting/tsconfig.json" },
{ "path": "../licensing/tsconfig.json" },
{ "path": "../lens/tsconfig.json" },
{ "path": "../translations/tsconfig.json" }
]
}
4 changes: 2 additions & 2 deletions x-pack/plugins/uptime/public/apps/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import {
DataPublicPluginStart,
} from '../../../../../src/plugins/data/public';
import { alertTypeInitializers } from '../lib/alert_types';
import { FetchDataParams, ObservabilityPluginSetup } from '../../../observability/public';
import { FetchDataParams, ObservabilityPublicSetup } from '../../../observability/public';
import { PLUGIN } from '../../common/constants/plugin';

export interface ClientPluginsSetup {
data: DataPublicPluginSetup;
home?: HomePublicPluginSetup;
observability: ObservabilityPluginSetup;
observability: ObservabilityPublicSetup;
triggersActionsUi: TriggersAndActionsUIPublicPluginSetup;
}

Expand Down

0 comments on commit b9f5d0c

Please sign in to comment.