Skip to content

Commit

Permalink
Remove deprecated api (elastic#125524)
Browse files Browse the repository at this point in the history
* [Fleet] Remove deprecated kibana APIs - License

* Remove basePath from FleetApp

* Replace AsyncPlugin with Plugin

* Get fieldFormats from fieldFormats plugin rather than data plugin

* Fix ts errors

* Attempt fixing wrong type

* Move licenseService to FleetStartDeps

* Fix types and mocks

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
2 people authored and lucasfcosta committed Mar 2, 2022
1 parent eb20c02 commit f38b492
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 24 deletions.
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,
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

0 comments on commit f38b492

Please sign in to comment.