Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated api #125524

Merged
merged 9 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions x-pack/plugins/fleet/.storybook/context/stubs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import type { FleetStartServices } from '../../public/plugin';

type Stubs =
| 'licensing'
| 'storage'
| 'data'
| 'fieldFormats'
| 'deprecations'
| 'fatalErrors'
| 'navigation'
Expand All @@ -19,8 +21,10 @@ type Stubs =
type StubbedStartServices = Pick<FleetStartServices, Stubs>;

export const stubbedStartServices: StubbedStartServices = {
licensing: {} as FleetStartServices['licensing'],
storage: {} as FleetStartServices['storage'],
data: {} as FleetStartServices['data'],
fieldFormats: {} as FleetStartServices['fieldFormats'],
deprecations: {} as FleetStartServices['deprecations'],
fatalErrors: {} as FleetStartServices['fatalErrors'],
navigation: {} as FleetStartServices['navigation'],
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/fleet/public/applications/fleet/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ export const WithPermissionsAndSetup: React.FC = memo(({ children }) => {
* and no routes defined
*/
export const FleetAppContext: React.FC<{
basepath: string;
startServices: FleetStartServices;
config: FleetConfigType;
history: AppMountParameters['history'];
Expand Down
6 changes: 1 addition & 5 deletions x-pack/plugins/fleet/public/applications/fleet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const ProtectedRoute: React.FunctionComponent<ProtectedRouteProps> = ({
};

interface FleetAppProps {
basepath: string;
startServices: FleetStartServices;
config: FleetConfigType;
history: AppMountParameters['history'];
Expand All @@ -41,7 +40,6 @@ interface FleetAppProps {
theme$: AppMountParameters['theme$'];
}
const FleetApp = ({
basepath,
startServices,
config,
history,
Expand All @@ -52,7 +50,6 @@ const FleetApp = ({
}: FleetAppProps) => {
return (
<FleetAppContext
basepath={basepath}
startServices={startServices}
config={config}
history={history}
Expand All @@ -69,14 +66,13 @@ const FleetApp = ({

export function renderApp(
startServices: FleetStartServices,
{ element, appBasePath, history, setHeaderActionMenu, theme$ }: AppMountParameters,
{ element, history, setHeaderActionMenu, theme$ }: AppMountParameters,
config: FleetConfigType,
kibanaVersion: string,
extensions: UIExtensionsStorage
) {
ReactDOM.render(
<FleetApp
basepath={appBasePath}
startServices={startServices}
config={config}
history={history}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ import { DataStreamRowActions } from './components/data_stream_row_actions';
export const DataStreamListPage: React.FunctionComponent<{}> = () => {
useBreadcrumbs('data_streams');

const {
data: { fieldFormats },
} = useStartServices();
const { fieldFormats } = useStartServices();

const { pagination, pageSizeOptions } = usePagination();

Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/fleet/public/mock/create_test_renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export const createFleetTestRendererMock = (): TestRenderer => {
AppWrapper: memo(({ children }) => {
return (
<FleetAppContext
basepath={basePath}
startServices={testRendererMocks.startServices}
config={testRendererMocks.config}
history={testRendererMocks.mountHistory}
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/fleet/public/mock/plugin_dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import { homePluginMock } from '../../../../../src/plugins/home/public/mocks';
import { navigationPluginMock } from '../../../../../src/plugins/navigation/public/mocks';
import { customIntegrationsMock } from '../../../../../src/plugins/custom_integrations/public/mocks';
import { sharePluginMock } from '../../../../../src/plugins/share/public/mocks';
import { fieldFormatsServiceMock } from '../../../../../src/plugins/field_formats/public/mocks';

export const createSetupDepsMock = () => {
const cloud = cloudMock.createSetup();
return {
licensing: licensingMock.createSetup(),
data: dataPluginMock.createSetupContract(),
home: homePluginMock.createSetupContract(),
customIntegrations: customIntegrationsMock.createSetup(),
Expand All @@ -26,7 +26,9 @@ export const createSetupDepsMock = () => {

export const createStartDepsMock = () => {
return {
licensing: licensingMock.createStart(),
data: dataPluginMock.createStartContract(),
fieldFormats: fieldFormatsServiceMock.createStartContract() as any,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this the type check was failing in createStartServices here. I think there is something weird with the type returned by createStartContract.

navigation: navigationPluginMock.createStartContract(),
customIntegrations: customIntegrationsMock.createStart(),
share: sharePluginMock.createStartContract(),
Expand Down
12 changes: 7 additions & 5 deletions x-pack/plugins/fleet/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ import type {
DataPublicPluginSetup,
DataPublicPluginStart,
} from '../../../../src/plugins/data/public';
import type { FieldFormatsStart } from '../../../../src/plugins/field_formats/public/index';
import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public';
import type { HomePublicPluginSetup } from '../../../../src/plugins/home/public';
import { Storage } from '../../../../src/plugins/kibana_utils/public';
import type { LicensingPluginSetup } from '../../licensing/public';
import type { LicensingPluginStart } from '../../licensing/public';
import type { CloudSetup } from '../../cloud/public';
import type { GlobalSearchPluginSetup } from '../../global_search/public';
import {
Expand Down Expand Up @@ -82,7 +83,6 @@ export interface FleetStart {
}

export interface FleetSetupDeps {
licensing: LicensingPluginSetup;
data: DataPublicPluginSetup;
home?: HomePublicPluginSetup;
cloud?: CloudSetup;
Expand All @@ -92,7 +92,9 @@ export interface FleetSetupDeps {
}

export interface FleetStartDeps {
licensing: LicensingPluginStart;
data: DataPublicPluginStart;
fieldFormats: FieldFormatsStart;
navigation: NavigationPublicPluginStart;
customIntegrations: CustomIntegrationsStart;
share: SharePluginStart;
Expand Down Expand Up @@ -129,9 +131,6 @@ export class FleetPlugin implements Plugin<FleetSetup, FleetStart, FleetSetupDep
// Set up http client
setHttpClient(core.http);

// Set up license service
licenseService.start(deps.licensing.license$);

// Register Integrations app
core.application.register({
id: INTEGRATIONS_PLUGIN_ID,
Expand Down Expand Up @@ -256,6 +255,9 @@ export class FleetPlugin implements Plugin<FleetSetup, FleetStart, FleetSetupDep
core.http.get<CheckPermissionsResponse>(appRoutesService.getCheckPermissionsPath())
);

// Set up license service
licenseService.start(deps.licensing.license$);

registerExtension({
package: CUSTOM_LOGS_INTEGRATION_NAME,
view: 'package-detail-assets',
Expand Down
13 changes: 5 additions & 8 deletions x-pack/plugins/fleet/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
CoreStart,
ElasticsearchServiceStart,
Logger,
AsyncPlugin,
Plugin,
PluginInitializerContext,
SavedObjectsServiceStart,
HttpServiceSetup,
Expand All @@ -33,7 +33,7 @@ import {
ServiceStatusLevels,
} from '../../../../src/core/server';
import type { PluginStart as DataPluginStart } from '../../../../src/plugins/data/server';
import type { LicensingPluginSetup, ILicense } from '../../licensing/server';
import type { LicensingPluginStart } from '../../licensing/server';
import type {
EncryptedSavedObjectsPluginStart,
EncryptedSavedObjectsPluginSetup,
Expand Down Expand Up @@ -93,7 +93,6 @@ import { TelemetryEventsSender } from './telemetry/sender';
import { setupFleet } from './services/setup';

export interface FleetSetupDeps {
licensing: LicensingPluginSetup;
security: SecurityPluginSetup;
features?: FeaturesPluginSetup;
encryptedSavedObjects: EncryptedSavedObjectsPluginSetup;
Expand All @@ -105,6 +104,7 @@ export interface FleetSetupDeps {

export interface FleetStartDeps {
data: DataPluginStart;
licensing: LicensingPluginStart;
encryptedSavedObjects: EncryptedSavedObjectsPluginStart;
security: SecurityPluginStart;
telemetry?: TelemetryPluginStart;
Expand Down Expand Up @@ -175,9 +175,8 @@ export interface FleetStartContract {
}

export class FleetPlugin
implements AsyncPlugin<FleetSetupContract, FleetStartContract, FleetSetupDeps, FleetStartDeps>
implements Plugin<FleetSetupContract, FleetStartContract, FleetSetupDeps, FleetStartDeps>
{
private licensing$!: Observable<ILicense>;
private config$: Observable<FleetConfigType>;
private configInitialValue: FleetConfigType;
private cloud?: CloudSetup;
Expand Down Expand Up @@ -212,7 +211,6 @@ export class FleetPlugin

public setup(core: CoreSetup, deps: FleetSetupDeps) {
this.httpSetup = core.http;
this.licensing$ = deps.licensing.license$;
this.encryptedSavedObjectsSetup = deps.encryptedSavedObjects;
this.cloud = deps.cloud;
this.securitySetup = deps.security;
Expand Down Expand Up @@ -384,7 +382,6 @@ export class FleetPlugin

this.telemetryEventsSender.setup(deps.telemetry);
}

public start(core: CoreStart, plugins: FleetStartDeps): FleetStartContract {
appContextService.start({
elasticsearch: core.elasticsearch,
Expand All @@ -404,7 +401,7 @@ export class FleetPlugin
logger: this.logger,
telemetryEventsSender: this.telemetryEventsSender,
});
licenseService.start(this.licensing$);
licenseService.start(plugins.licensing.license$);

this.telemetryEventsSender.start(plugins.telemetry, core);

Expand Down