diff --git a/x-pack/plugins/fleet/.storybook/context/stubs.tsx b/x-pack/plugins/fleet/.storybook/context/stubs.tsx index f72b176bd8d7b..65485a31d376a 100644 --- a/x-pack/plugins/fleet/.storybook/context/stubs.tsx +++ b/x-pack/plugins/fleet/.storybook/context/stubs.tsx @@ -8,8 +8,10 @@ import type { FleetStartServices } from '../../public/plugin'; type Stubs = + | 'licensing' | 'storage' | 'data' + | 'fieldFormats' | 'deprecations' | 'fatalErrors' | 'navigation' @@ -19,8 +21,10 @@ type Stubs = type StubbedStartServices = Pick; 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'], diff --git a/x-pack/plugins/fleet/public/applications/fleet/app.tsx b/x-pack/plugins/fleet/public/applications/fleet/app.tsx index 29a491fe0c932..b5872b0a995a9 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/app.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/app.tsx @@ -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']; diff --git a/x-pack/plugins/fleet/public/applications/fleet/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/index.tsx index 9c6319a92b2ee..8946e6af0ce75 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/index.tsx @@ -31,7 +31,6 @@ export const ProtectedRoute: React.FunctionComponent = ({ }; interface FleetAppProps { - basepath: string; startServices: FleetStartServices; config: FleetConfigType; history: AppMountParameters['history']; @@ -41,7 +40,6 @@ interface FleetAppProps { theme$: AppMountParameters['theme$']; } const FleetApp = ({ - basepath, startServices, config, history, @@ -52,7 +50,6 @@ const FleetApp = ({ }: FleetAppProps) => { return ( = () => { useBreadcrumbs('data_streams'); - const { - data: { fieldFormats }, - } = useStartServices(); + const { fieldFormats } = useStartServices(); const { pagination, pageSizeOptions } = usePagination(); diff --git a/x-pack/plugins/fleet/public/mock/create_test_renderer.tsx b/x-pack/plugins/fleet/public/mock/create_test_renderer.tsx index 22b58c14fb072..5952fbebcf272 100644 --- a/x-pack/plugins/fleet/public/mock/create_test_renderer.tsx +++ b/x-pack/plugins/fleet/public/mock/create_test_renderer.tsx @@ -77,7 +77,6 @@ export const createFleetTestRendererMock = (): TestRenderer => { AppWrapper: memo(({ children }) => { return ( { const cloud = cloudMock.createSetup(); return { - licensing: licensingMock.createSetup(), data: dataPluginMock.createSetupContract(), home: homePluginMock.createSetupContract(), customIntegrations: customIntegrationsMock.createSetup(), @@ -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(), diff --git a/x-pack/plugins/fleet/public/plugin.ts b/x-pack/plugins/fleet/public/plugin.ts index 385ef2bee6512..79dc8cc38c4bf 100644 --- a/x-pack/plugins/fleet/public/plugin.ts +++ b/x-pack/plugins/fleet/public/plugin.ts @@ -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 { @@ -82,7 +83,6 @@ export interface FleetStart { } export interface FleetSetupDeps { - licensing: LicensingPluginSetup; data: DataPublicPluginSetup; home?: HomePublicPluginSetup; cloud?: CloudSetup; @@ -92,7 +92,9 @@ export interface FleetSetupDeps { } export interface FleetStartDeps { + licensing: LicensingPluginStart; data: DataPublicPluginStart; + fieldFormats: FieldFormatsStart; navigation: NavigationPublicPluginStart; customIntegrations: CustomIntegrationsStart; share: SharePluginStart; @@ -129,9 +131,6 @@ export class FleetPlugin implements Plugin(appRoutesService.getCheckPermissionsPath()) ); + // Set up license service + licenseService.start(deps.licensing.license$); + registerExtension({ package: CUSTOM_LOGS_INTEGRATION_NAME, view: 'package-detail-assets', diff --git a/x-pack/plugins/fleet/server/plugin.ts b/x-pack/plugins/fleet/server/plugin.ts index 4bc06d51e7e0b..272e92fca6eae 100644 --- a/x-pack/plugins/fleet/server/plugin.ts +++ b/x-pack/plugins/fleet/server/plugin.ts @@ -14,7 +14,7 @@ import type { CoreStart, ElasticsearchServiceStart, Logger, - AsyncPlugin, + Plugin, PluginInitializerContext, SavedObjectsServiceStart, HttpServiceSetup, @@ -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, @@ -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; @@ -105,6 +104,7 @@ export interface FleetSetupDeps { export interface FleetStartDeps { data: DataPluginStart; + licensing: LicensingPluginStart; encryptedSavedObjects: EncryptedSavedObjectsPluginStart; security: SecurityPluginStart; telemetry?: TelemetryPluginStart; @@ -175,9 +175,8 @@ export interface FleetStartContract { } export class FleetPlugin - implements AsyncPlugin + implements Plugin { - private licensing$!: Observable; private config$: Observable; private configInitialValue: FleetConfigType; private cloud?: CloudSetup; @@ -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; @@ -384,7 +382,6 @@ export class FleetPlugin this.telemetryEventsSender.setup(deps.telemetry); } - public start(core: CoreStart, plugins: FleetStartDeps): FleetStartContract { appContextService.start({ elasticsearch: core.elasticsearch, @@ -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);