From e18ca4b4e93324d673ffad899722f44d6892881f Mon Sep 17 00:00:00 2001 From: Kyle Pollich Date: Thu, 27 May 2021 15:19:54 -0400 Subject: [PATCH] WIP: Re-create separation of integrations app --- .../plugins/fleet/common/constants/plugin.ts | 1 + .../fleet/public/applications/fleet/app.tsx | 26 +- .../applications/fleet/components/index.ts | 13 +- .../applications/fleet/constants/index.ts | 19 +- .../fleet/constants/page_paths.ts | 104 -------- .../public/applications/fleet/hooks/index.ts | 19 +- .../fleet/hooks/use_breadcrumbs.tsx | 131 +--------- .../applications/fleet/layouts/index.tsx | 4 +- .../sections/agent_policy/components/index.ts | 4 +- .../components/layout.tsx | 2 +- .../create_package_policy_page/index.test.tsx | 12 +- .../create_package_policy_page/index.tsx | 7 +- .../step_define_package_policy.tsx | 3 +- .../step_select_package.tsx | 5 +- .../agent_policy/details_page/index.tsx | 8 +- .../edit_package_policy_page/index.tsx | 7 +- .../agents/agent_details_page/index.tsx | 8 +- .../agent_policy_package_badges.tsx | 2 +- .../sections/data_stream/list_page/index.tsx | 2 +- .../applications/fleet/services/index.ts | 27 +- .../public/applications/fleet/types/index.ts | 123 +-------- .../public/applications/integrations/app.tsx | 233 ++++++++++++++++++ .../integrations/components/index.ts | 7 + .../applications/integrations/constants.tsx | 61 +++++ .../index.tsx => integrations/hooks/index.ts} | 13 +- .../integrations/hooks/use_breadcrumbs.tsx | 155 ++++++++++++ .../integrations/hooks/use_epm_links.tsx | 47 ++++ .../epm => integrations}/hooks/use_links.tsx | 0 .../hooks/use_local_search.tsx | 0 .../hooks/use_package_install.tsx | 2 +- .../applications/integrations/index.tsx | 93 +++++++ .../integrations/layouts/default.tsx | 71 ++++++ .../integrations/layouts/index.ts | 10 + .../epm/components/assets_facet_group.tsx | 0 .../sections/epm/components/icons.tsx | 0 .../sections/epm/components/package_card.tsx | 2 +- .../epm/components/package_list_grid.tsx | 2 +- .../sections/epm/components/release_badge.ts | 0 .../sections/epm/components/requirements.tsx | 0 .../sections/epm/components/version.tsx | 0 .../sections/epm/constants.tsx | 0 .../sections/epm/index.tsx | 12 +- .../screens/detail/components/icon_panel.tsx | 0 .../epm/screens/detail/components/index.tsx | 0 .../integration_agent_policy_count.tsx | 0 .../screens/detail/components/update_icon.tsx | 0 .../epm/screens/detail/custom/custom.tsx | 7 +- .../epm/screens/detail/custom/index.ts | 0 .../sections/epm/screens/detail/index.scss | 0 .../epm/screens/detail/index.test.tsx | 18 +- .../sections/epm/screens/detail/index.tsx | 25 +- .../epm/screens/detail/overview/details.tsx | 0 .../epm/screens/detail/overview/index.ts | 0 .../detail/overview/markdown_renderers.tsx | 0 .../epm/screens/detail/overview/overview.tsx | 0 .../epm/screens/detail/overview/readme.tsx | 3 +- .../screens/detail/overview/screenshots.tsx | 2 +- .../epm/screens/detail/policies/index.ts | 0 .../detail/policies/package_policies.tsx | 5 +- .../epm/screens/detail/policies/persona.tsx | 0 .../use_package_policies_with_agent_policy.ts | 5 +- .../settings/confirm_package_install.tsx | 0 .../settings/confirm_package_uninstall.tsx | 0 .../epm/screens/detail/settings/index.ts | 0 .../detail/settings/installation_button.tsx | 8 +- .../epm/screens/detail/settings/settings.tsx | 3 +- .../epm/screens/home/category_facets.tsx | 0 .../sections/epm/screens/home/header.tsx | 3 +- .../sections/epm/screens/home/index.tsx | 6 +- .../sections/epm/screens/policy/index.tsx | 3 +- .../integrations/sections/index.ts | 8 + .../integrations/services/index.ts | 7 + .../applications/integrations/types/index.ts | 7 + .../fleet => }/components/alpha_flyout.tsx | 0 .../fleet => }/components/alpha_messaging.tsx | 0 .../components/context_menu_actions.tsx | 0 .../fleet => }/components/error.tsx | 0 .../components/extension_wrapper.tsx | 0 .../fleet => }/components/header.tsx | 0 .../components/home_integration/index.tsx | 0 .../tutorial_directory_header_link.tsx | 4 +- .../tutorial_directory_notice.tsx | 4 +- .../tutorial_module_notice.tsx | 2 +- .../plugins/fleet/public/components/index.ts | 17 ++ .../components/link_and_revision.tsx | 2 +- .../components/linked_agent_count.tsx | 0 .../fleet => }/components/loading.tsx | 0 .../fleet => }/components/package_icon.tsx | 0 .../settings_flyout/confirm_modal.tsx | 0 .../components/settings_flyout/index.tsx | 7 +- .../plugins/fleet/public/constants/index.ts | 26 ++ .../fleet/public/constants/page_paths.ts | 134 ++++++++++ x-pack/plugins/fleet/public/hooks/index.ts | 26 ++ .../fleet => }/hooks/use_capabilities.ts | 2 +- .../fleet => }/hooks/use_config.ts | 0 .../fleet => }/hooks/use_core.ts | 4 +- .../fleet => }/hooks/use_debounce.tsx | 0 .../fleet => }/hooks/use_fleet_status.tsx | 0 .../fleet => }/hooks/use_input.ts | 0 .../fleet => }/hooks/use_intra_app_state.tsx | 0 .../fleet => }/hooks/use_kibana_link.ts | 0 .../fleet => }/hooks/use_kibana_version.ts | 0 .../fleet => }/hooks/use_license.ts | 2 +- .../fleet => }/hooks/use_link.ts | 0 .../fleet => }/hooks/use_package_icon_type.ts | 6 +- .../fleet => }/hooks/use_pagination.tsx | 0 .../hooks/use_request/agent_policy.ts | 0 .../fleet => }/hooks/use_request/agents.ts | 0 .../fleet => }/hooks/use_request/app.ts | 0 .../hooks/use_request/data_stream.ts | 0 .../hooks/use_request/enrollment_api_keys.ts | 0 .../fleet => }/hooks/use_request/epm.ts | 0 .../fleet => }/hooks/use_request/index.ts | 2 +- .../fleet => }/hooks/use_request/outputs.ts | 0 .../hooks/use_request/package_policy.ts | 0 .../fleet => }/hooks/use_request/settings.ts | 0 .../fleet => }/hooks/use_request/setup.ts | 0 .../hooks/use_request/use_request.ts | 6 +- .../fleet => }/hooks/use_sorting.tsx | 0 .../fleet => }/hooks/use_ui_extension.ts | 0 .../fleet => }/hooks/use_url_modal.ts | 0 .../fleet => }/hooks/use_url_pagination.ts | 0 .../fleet => }/hooks/use_url_params.ts | 0 x-pack/plugins/fleet/public/index.ts | 10 +- x-pack/plugins/fleet/public/layouts/index.ts | 9 + .../fleet => }/layouts/with_header.tsx | 0 .../fleet => }/layouts/without_header.tsx | 3 +- .../fleet => }/mock/create_test_renderer.tsx | 50 +++- .../fleet => }/mock/fleet_start_services.tsx | 6 +- .../{applications/fleet => }/mock/index.ts | 0 .../fleet => }/mock/plugin_configuration.ts | 0 .../fleet => }/mock/plugin_dependencies.ts | 6 +- .../fleet => }/mock/plugin_interfaces.ts | 0 .../{applications/fleet => }/mock/types.ts | 0 x-pack/plugins/fleet/public/plugin.ts | 49 +++- x-pack/plugins/fleet/public/services/index.ts | 36 +++ .../services/pkg_key_from_package_info.ts | 0 .../fleet => }/services/ui_extensions.test.ts | 0 .../fleet => }/services/ui_extensions.ts | 0 x-pack/plugins/fleet/public/types/index.ts | 129 ++++++++++ .../fleet => }/types/intra_app_route_state.ts | 0 .../fleet => }/types/ui_extensions.ts | 0 142 files changed, 1313 insertions(+), 574 deletions(-) delete mode 100644 x-pack/plugins/fleet/public/applications/fleet/constants/page_paths.ts create mode 100644 x-pack/plugins/fleet/public/applications/integrations/app.tsx create mode 100644 x-pack/plugins/fleet/public/applications/integrations/components/index.ts create mode 100644 x-pack/plugins/fleet/public/applications/integrations/constants.tsx rename x-pack/plugins/fleet/public/applications/{fleet/sections/epm/hooks/index.tsx => integrations/hooks/index.ts} (55%) create mode 100644 x-pack/plugins/fleet/public/applications/integrations/hooks/use_breadcrumbs.tsx create mode 100644 x-pack/plugins/fleet/public/applications/integrations/hooks/use_epm_links.tsx rename x-pack/plugins/fleet/public/applications/{fleet/sections/epm => integrations}/hooks/use_links.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet/sections/epm => integrations}/hooks/use_local_search.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet/sections/epm => integrations}/hooks/use_package_install.tsx (98%) create mode 100644 x-pack/plugins/fleet/public/applications/integrations/index.tsx create mode 100644 x-pack/plugins/fleet/public/applications/integrations/layouts/default.tsx create mode 100644 x-pack/plugins/fleet/public/applications/integrations/layouts/index.ts rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/components/assets_facet_group.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/components/icons.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/components/package_card.tsx (96%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/components/package_list_grid.tsx (98%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/components/release_badge.ts (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/components/requirements.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/components/version.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/constants.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/index.tsx (63%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/components/icon_panel.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/components/index.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/components/integration_agent_policy_count.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/components/update_icon.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/custom/custom.tsx (79%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/custom/index.ts (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/index.scss (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/index.test.tsx (98%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/index.tsx (95%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/overview/details.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/overview/index.ts (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/overview/markdown_renderers.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/overview/overview.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/overview/readme.tsx (94%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/overview/screenshots.tsx (98%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/policies/index.ts (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/policies/package_policies.tsx (96%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/policies/persona.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts (95%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/settings/confirm_package_install.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/settings/confirm_package_uninstall.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/settings/index.ts (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/settings/installation_button.tsx (96%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/detail/settings/settings.tsx (98%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/home/category_facets.tsx (100%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/home/header.tsx (94%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/home/index.tsx (97%) rename x-pack/plugins/fleet/public/applications/{fleet => integrations}/sections/epm/screens/policy/index.tsx (80%) create mode 100644 x-pack/plugins/fleet/public/applications/integrations/sections/index.ts create mode 100644 x-pack/plugins/fleet/public/applications/integrations/services/index.ts create mode 100644 x-pack/plugins/fleet/public/applications/integrations/types/index.ts rename x-pack/plugins/fleet/public/{applications/fleet => }/components/alpha_flyout.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/alpha_messaging.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/context_menu_actions.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/error.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/extension_wrapper.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/header.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/home_integration/index.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/home_integration/tutorial_directory_header_link.tsx (93%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/home_integration/tutorial_directory_notice.tsx (97%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/home_integration/tutorial_module_notice.tsx (97%) create mode 100644 x-pack/plugins/fleet/public/components/index.ts rename x-pack/plugins/fleet/public/{applications/fleet => }/components/link_and_revision.tsx (97%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/linked_agent_count.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/loading.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/package_icon.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/settings_flyout/confirm_modal.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/components/settings_flyout/index.tsx (98%) create mode 100644 x-pack/plugins/fleet/public/constants/index.ts create mode 100644 x-pack/plugins/fleet/public/constants/page_paths.ts create mode 100644 x-pack/plugins/fleet/public/hooks/index.ts rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_capabilities.ts (85%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_config.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_core.ts (77%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_debounce.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_fleet_status.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_input.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_intra_app_state.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_kibana_link.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_kibana_version.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_license.ts (83%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_link.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_package_icon_type.ts (94%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_pagination.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_request/agent_policy.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_request/agents.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_request/app.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_request/data_stream.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_request/enrollment_api_keys.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_request/epm.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_request/index.ts (88%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_request/outputs.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_request/package_policy.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_request/settings.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_request/setup.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_request/use_request.ts (92%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_sorting.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_ui_extension.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_url_modal.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_url_pagination.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/hooks/use_url_params.ts (100%) create mode 100644 x-pack/plugins/fleet/public/layouts/index.ts rename x-pack/plugins/fleet/public/{applications/fleet => }/layouts/with_header.tsx (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/layouts/without_header.tsx (96%) rename x-pack/plugins/fleet/public/{applications/fleet => }/mock/create_test_renderer.tsx (64%) rename x-pack/plugins/fleet/public/{applications/fleet => }/mock/fleet_start_services.tsx (89%) rename x-pack/plugins/fleet/public/{applications/fleet => }/mock/index.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/mock/plugin_configuration.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/mock/plugin_dependencies.ts (74%) rename x-pack/plugins/fleet/public/{applications/fleet => }/mock/plugin_interfaces.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/mock/types.ts (100%) create mode 100644 x-pack/plugins/fleet/public/services/index.ts rename x-pack/plugins/fleet/public/{applications/fleet => }/services/pkg_key_from_package_info.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/services/ui_extensions.test.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/services/ui_extensions.ts (100%) create mode 100644 x-pack/plugins/fleet/public/types/index.ts rename x-pack/plugins/fleet/public/{applications/fleet => }/types/intra_app_route_state.ts (100%) rename x-pack/plugins/fleet/public/{applications/fleet => }/types/ui_extensions.ts (100%) diff --git a/x-pack/plugins/fleet/common/constants/plugin.ts b/x-pack/plugins/fleet/common/constants/plugin.ts index 86175d4cd24bc9f..ee0e1e5caeae4df 100644 --- a/x-pack/plugins/fleet/common/constants/plugin.ts +++ b/x-pack/plugins/fleet/common/constants/plugin.ts @@ -6,3 +6,4 @@ */ export const PLUGIN_ID = 'fleet'; +export const INTEGRATIONS_PLUGIN_ID = 'integrations'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/app.tsx b/x-pack/plugins/fleet/public/applications/fleet/app.tsx index 5327d4b7cc4a4ce..1ec4c021d097328 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/app.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/app.tsx @@ -20,29 +20,30 @@ import type { FleetConfigType, FleetStartServices } from '../../plugin'; import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; import { EuiThemeProvider } from '../../../../../../src/plugins/kibana_react/common'; +import { PackageInstallProvider } from '../integrations/hooks'; + import { ConfigContext, FleetStatusProvider, + IntraAppStateProvider, KibanaVersionContext, sendGetPermissionsCheck, sendSetup, useBreadcrumbs, useConfig, useStartServices, + UIExtensionsContext, } from './hooks'; import { Error, Loading } from './components'; -import { IntraAppStateProvider } from './hooks/use_intra_app_state'; -import { PackageInstallProvider } from './sections/epm/hooks'; -import { PAGE_ROUTING_PATHS } from './constants'; +import type { UIExtensionsStorage } from './types'; + +import { FLEET_ROUTING_PATHS } from './constants'; import { DefaultLayout, WithoutHeaderLayout } from './layouts'; -import { EPMApp } from './sections/epm'; import { AgentPolicyApp } from './sections/agent_policy'; import { DataStreamApp } from './sections/data_stream'; import { FleetApp } from './sections/agents'; import { IngestManagerOverview } from './sections/overview'; import { ProtectedRoute } from './index'; -import type { UIExtensionsStorage } from './types'; -import { UIExtensionsContext } from './hooks/use_ui_extension'; const ErrorLayout = ({ children }: { children: JSX.Element }) => ( @@ -236,27 +237,22 @@ export const AppRoutes = memo(() => { return ( - - - - - - + - + - + - + diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/index.ts b/x-pack/plugins/fleet/public/applications/fleet/components/index.ts index 1c3f8047e95fb78..ac5a78a4ea7095b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/index.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/components/index.ts @@ -5,12 +5,7 @@ * 2.0. */ -export { Loading } from './loading'; -export { Error } from './error'; -export { Header, HeaderProps } from './header'; -export { AlphaMessaging } from './alpha_messaging'; -export { PackageIcon } from './package_icon'; -export { ContextMenuActions } from './context_menu_actions'; -export { SearchBar } from './search_bar'; -export * from './settings_flyout'; -export * from './link_and_revision'; +export * from '../../../components'; + +export * from './enrollment_instructions'; +export * from './search_bar'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/constants/index.ts b/x-pack/plugins/fleet/public/applications/fleet/constants/index.ts index bbf14dcae45fcb1..aafaac157034a72 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/constants/index.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/constants/index.ts @@ -5,21 +5,4 @@ * 2.0. */ -export { - PLUGIN_ID, - EPM_API_ROUTES, - AGENT_API_ROUTES, - SO_SEARCH_LIMIT, - AGENT_POLICY_SAVED_OBJECT_TYPE, - AGENT_SAVED_OBJECT_TYPE, - ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE, - PACKAGE_POLICY_SAVED_OBJECT_TYPE, - FLEET_SERVER_PACKAGE, - // Fleet Server index - AGENTS_INDEX, - ENROLLMENT_API_KEYS_INDEX, -} from '../../../../common'; - -export * from './page_paths'; - -export const INDEX_NAME = '.kibana'; +export * from '../../../constants'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/constants/page_paths.ts b/x-pack/plugins/fleet/public/applications/fleet/constants/page_paths.ts deleted file mode 100644 index 27df7a4ebf11d37..000000000000000 --- a/x-pack/plugins/fleet/public/applications/fleet/constants/page_paths.ts +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export type StaticPage = - | 'base' - | 'overview' - | 'integrations' - | 'integrations_all' - | 'integrations_installed' - | 'policies' - | 'policies_list' - | 'fleet' - | 'fleet_enrollment_tokens' - | 'data_streams'; - -export type DynamicPage = - | 'integration_details_overview' - | 'integration_details_policies' - | 'integration_details_settings' - | 'integration_details_custom' - | 'integration_policy_edit' - | 'policy_details' - | 'add_integration_from_policy' - | 'add_integration_to_policy' - | 'edit_integration' - | 'fleet_agent_list' - | 'fleet_agent_details'; - -export type Page = StaticPage | DynamicPage; - -export interface DynamicPagePathValues { - [key: string]: string; -} - -export const BASE_PATH = '/app/fleet'; - -// If routing paths are changed here, please also check to see if -// `pagePathGetters()`, below, needs any modifications -export const PAGE_ROUTING_PATHS = { - overview: '/', - integrations: '/integrations/:tabId?', - integrations_all: '/integrations', - integrations_installed: '/integrations/installed', - integration_details: '/integrations/detail/:pkgkey/:panel?', - integration_details_overview: '/integrations/detail/:pkgkey/overview', - integration_details_policies: '/integrations/detail/:pkgkey/policies', - integration_details_settings: '/integrations/detail/:pkgkey/settings', - integration_details_custom: '/integrations/detail/:pkgkey/custom', - integration_policy_edit: '/integrations/edit-integration/:packagePolicyId', - policies: '/policies', - policies_list: '/policies', - policy_details: '/policies/:policyId/:tabId?', - policy_details_settings: '/policies/:policyId/settings', - add_integration_from_policy: '/policies/:policyId/add-integration', - add_integration_to_policy: '/integrations/:pkgkey/add-integration/:integration?', - edit_integration: '/policies/:policyId/edit-integration/:packagePolicyId', - fleet: '/fleet', - fleet_agent_list: '/fleet/agents', - fleet_agent_details: '/fleet/agents/:agentId/:tabId?', - fleet_agent_details_logs: '/fleet/agents/:agentId/logs', - fleet_enrollment_tokens: '/fleet/enrollment-tokens', - data_streams: '/data-streams', -}; - -export const pagePathGetters: { - [key in StaticPage]: () => string; -} & - { - [key in DynamicPage]: (values: DynamicPagePathValues) => string; - } = { - base: () => '/', - overview: () => '/', - integrations: () => '/integrations', - integrations_all: () => '/integrations', - integrations_installed: () => '/integrations/installed', - integration_details_overview: ({ pkgkey, integration }) => - `/integrations/detail/${pkgkey}/overview${integration ? `?integration=${integration}` : ''}`, - integration_details_policies: ({ pkgkey, integration }) => - `/integrations/detail/${pkgkey}/policies${integration ? `?integration=${integration}` : ''}`, - integration_details_settings: ({ pkgkey, integration }) => - `/integrations/detail/${pkgkey}/settings${integration ? `?integration=${integration}` : ''}`, - integration_details_custom: ({ pkgkey, integration }) => - `/integrations/detail/${pkgkey}/custom${integration ? `?integration=${integration}` : ''}`, - integration_policy_edit: ({ packagePolicyId }) => - `/integrations/edit-integration/${packagePolicyId}`, - policies: () => '/policies', - policies_list: () => '/policies', - policy_details: ({ policyId, tabId }) => `/policies/${policyId}${tabId ? `/${tabId}` : ''}`, - add_integration_from_policy: ({ policyId }) => `/policies/${policyId}/add-integration`, - add_integration_to_policy: ({ pkgkey, integration }) => - `/integrations/${pkgkey}/add-integration${integration ? `/${integration}` : ''}`, - edit_integration: ({ policyId, packagePolicyId }) => - `/policies/${policyId}/edit-integration/${packagePolicyId}`, - fleet: () => '/fleet', - fleet_agent_list: ({ kuery }) => `/fleet/agents${kuery ? `?kuery=${kuery}` : ''}`, - fleet_agent_details: ({ agentId, tabId, logQuery }) => - `/fleet/agents/${agentId}${tabId ? `/${tabId}` : ''}${logQuery ? `?_q=${logQuery}` : ''}`, - fleet_enrollment_tokens: () => '/fleet/enrollment-tokens', - data_streams: () => '/data-streams', -}; diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/index.ts b/x-pack/plugins/fleet/public/applications/fleet/hooks/index.ts index f7176de302fdea5..7cf16b1b7ae9092 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/index.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/index.ts @@ -5,21 +5,6 @@ * 2.0. */ -export { useCapabilities } from './use_capabilities'; -export { useStartServices } from './use_core'; -export { useConfig, ConfigContext } from './use_config'; -export { useKibanaVersion, KibanaVersionContext } from './use_kibana_version'; -export { licenseService, useLicense } from './use_license'; +export * from '../../../hooks'; + export { useBreadcrumbs } from './use_breadcrumbs'; -export { useLink } from './use_link'; -export { useKibanaLink } from './use_kibana_link'; -export { usePackageIconType, UsePackageIconType } from './use_package_icon_type'; -export { usePagination, Pagination, PAGE_SIZE_OPTIONS } from './use_pagination'; -export { useUrlPagination } from './use_url_pagination'; -export { useSorting } from './use_sorting'; -export { useDebounce } from './use_debounce'; -export { useUrlModal } from './use_url_modal'; -export * from './use_request'; -export * from './use_input'; -export * from './use_url_params'; -export * from './use_fleet_status'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_breadcrumbs.tsx b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_breadcrumbs.tsx index e10f53741dba9b5..ae2a5dc720107cd 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_breadcrumbs.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_breadcrumbs.tsx @@ -9,12 +9,12 @@ import { i18n } from '@kbn/i18n'; import type { ChromeBreadcrumb } from 'src/core/public'; import type { Page, DynamicPagePathValues } from '../constants'; -import { BASE_PATH, pagePathGetters } from '../constants'; +import { FLEET_BASE_PATH, pagePathGetters } from '../constants'; -import { useStartServices } from './use_core'; +import { useStartServices } from './'; const BASE_BREADCRUMB: ChromeBreadcrumb = { - href: pagePathGetters.overview(), + href: pagePathGetters.overview()[1], text: i18n.translate('xpack.fleet.breadcrumbs.appTitle', { defaultMessage: 'Fleet', }), @@ -32,66 +32,7 @@ const breadcrumbGetters: { }), }, ], - integrations: () => [ - BASE_BREADCRUMB, - { - text: i18n.translate('xpack.fleet.breadcrumbs.integrationsPageTitle', { - defaultMessage: 'Integrations', - }), - }, - ], - integrations_all: () => [ - BASE_BREADCRUMB, - { - href: pagePathGetters.integrations(), - text: i18n.translate('xpack.fleet.breadcrumbs.integrationsPageTitle', { - defaultMessage: 'Integrations', - }), - }, - { - text: i18n.translate('xpack.fleet.breadcrumbs.allIntegrationsPageTitle', { - defaultMessage: 'All', - }), - }, - ], - integrations_installed: () => [ - BASE_BREADCRUMB, - { - href: pagePathGetters.integrations(), - text: i18n.translate('xpack.fleet.breadcrumbs.integrationsPageTitle', { - defaultMessage: 'Integrations', - }), - }, - { - text: i18n.translate('xpack.fleet.breadcrumbs.installedIntegrationsPageTitle', { - defaultMessage: 'Installed', - }), - }, - ], - integration_details_overview: ({ pkgTitle }) => [ - BASE_BREADCRUMB, - { - href: pagePathGetters.integrations(), - text: i18n.translate('xpack.fleet.breadcrumbs.integrationsPageTitle', { - defaultMessage: 'Integrations', - }), - }, - { text: pkgTitle }, - ], - integration_policy_edit: ({ pkgTitle, pkgkey, policyName }) => [ - BASE_BREADCRUMB, - { - href: pagePathGetters.integrations(), - text: i18n.translate('xpack.fleet.breadcrumbs.integrationPageTitle', { - defaultMessage: 'Integration', - }), - }, - { - href: pagePathGetters.integration_details_policies({ pkgkey }), - text: pkgTitle, - }, - { text: policyName }, - ], + policies: () => [ BASE_BREADCRUMB, { @@ -111,67 +52,13 @@ const breadcrumbGetters: { policy_details: ({ policyName }) => [ BASE_BREADCRUMB, { - href: pagePathGetters.policies(), + href: pagePathGetters.policies()[1], text: i18n.translate('xpack.fleet.breadcrumbs.policiesPageTitle', { defaultMessage: 'Policies', }), }, { text: policyName }, ], - add_integration_from_policy: ({ policyName, policyId }) => [ - BASE_BREADCRUMB, - { - href: pagePathGetters.policies(), - text: i18n.translate('xpack.fleet.breadcrumbs.policiesPageTitle', { - defaultMessage: 'Policies', - }), - }, - { - href: pagePathGetters.policy_details({ policyId }), - text: policyName, - }, - { - text: i18n.translate('xpack.fleet.breadcrumbs.addPackagePolicyPageTitle', { - defaultMessage: 'Add integration', - }), - }, - ], - add_integration_to_policy: ({ pkgTitle, pkgkey }) => [ - BASE_BREADCRUMB, - { - href: pagePathGetters.integrations(), - text: i18n.translate('xpack.fleet.breadcrumbs.integrationsPageTitle', { - defaultMessage: 'Integrations', - }), - }, - { - href: pagePathGetters.integration_details_overview({ pkgkey }), - text: pkgTitle, - }, - { - text: i18n.translate('xpack.fleet.breadcrumbs.addPackagePolicyPageTitle', { - defaultMessage: 'Add integration', - }), - }, - ], - edit_integration: ({ policyName, policyId }) => [ - BASE_BREADCRUMB, - { - href: pagePathGetters.policies(), - text: i18n.translate('xpack.fleet.breadcrumbs.policiesPageTitle', { - defaultMessage: 'Policies', - }), - }, - { - href: pagePathGetters.policy_details({ policyId }), - text: policyName, - }, - { - text: i18n.translate('xpack.fleet.breadcrumbs.editPackagePolicyPageTitle', { - defaultMessage: 'Edit integration', - }), - }, - ], fleet: () => [ BASE_BREADCRUMB, { @@ -191,7 +78,7 @@ const breadcrumbGetters: { fleet_agent_details: ({ agentHost }) => [ BASE_BREADCRUMB, { - href: pagePathGetters.fleet(), + href: pagePathGetters.fleet()[1], text: i18n.translate('xpack.fleet.breadcrumbs.agentsPageTitle', { defaultMessage: 'Agents', }), @@ -201,7 +88,7 @@ const breadcrumbGetters: { fleet_enrollment_tokens: () => [ BASE_BREADCRUMB, { - href: pagePathGetters.fleet(), + href: pagePathGetters.fleet()[1], text: i18n.translate('xpack.fleet.breadcrumbs.agentsPageTitle', { defaultMessage: 'Agents', }), @@ -227,7 +114,9 @@ export function useBreadcrumbs(page: Page, values: DynamicPagePathValues = {}) { const breadcrumbs: ChromeBreadcrumb[] = breadcrumbGetters[page]?.(values).map((breadcrumb) => ({ ...breadcrumb, - href: breadcrumb.href ? http.basePath.prepend(`${BASE_PATH}#${breadcrumb.href}`) : undefined, + href: breadcrumb.href + ? http.basePath.prepend(`${FLEET_BASE_PATH}#${breadcrumb.href}`) + : undefined, })) || []; const docTitle: string[] = [...breadcrumbs] .reverse() diff --git a/x-pack/plugins/fleet/public/applications/fleet/layouts/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/layouts/index.tsx index cf84a29b84d4487..71cb8d3aeeb3696 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/layouts/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/layouts/index.tsx @@ -5,6 +5,6 @@ * 2.0. */ +export * from '../../../layouts'; + export { DefaultLayout } from './default'; -export { WithHeaderLayout, WithHeaderLayoutProps } from './with_header'; -export { WithoutHeaderLayout } from './without_header'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/index.ts b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/index.ts index c65157697cc864e..09282a7de7cb9b0 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/index.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/index.ts @@ -5,12 +5,14 @@ * 2.0. */ +// TODO: Does this need to be re-exported here? +export { LinkedAgentCount } from '../../../components'; + export { AgentPolicyForm, agentPolicyFormValidation } from './agent_policy_form'; export { AgentPolicyCopyProvider } from './agent_policy_copy_provider'; export { AgentPolicyDeleteProvider } from './agent_policy_delete_provider'; export { PackagePolicyDeleteProvider } from './package_policy_delete_provider'; export { AgentPolicyYamlFlyout } from './agent_policy_yaml_flyout'; -export { LinkedAgentCount } from '../../../components/linked_agent_count'; export { ConfirmDeployAgentPolicyModal } from './confirm_deploy_modal'; export { DangerEuiContextMenuItem } from './danger_eui_context_menu_item'; export { AgentPolicyActionMenu } from './actions_menu'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/layout.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/layout.tsx index 4aaf5343638bede..d2bc49bdf00e071 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/layout.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/layout.tsx @@ -20,7 +20,7 @@ import { import { WithHeaderLayout } from '../../../../layouts'; import type { AgentPolicy, PackageInfo } from '../../../../types'; -import { PackageIcon } from '../../../../components/package_icon'; +import { PackageIcon } from '../../../../components'; import type { CreatePackagePolicyFrom } from '../types'; export const CreatePackagePolicyPageLayout: React.FunctionComponent<{ diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.test.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.test.tsx index 11c672aa0596d2a..635795dfd12fb19 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.test.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.test.tsx @@ -9,26 +9,26 @@ import { Route } from 'react-router-dom'; import React from 'react'; import { act } from 'react-test-renderer'; -import type { MockedFleetStartServices, TestRenderer } from '../../../mock'; -import { createTestRendererMock } from '../../../mock'; -import { PAGE_ROUTING_PATHS, pagePathGetters, PLUGIN_ID } from '../../../constants'; +import type { MockedFleetStartServices, TestRenderer } from '../../../../../mock'; +import { createFleetTestRendererMock } from '../../../../../mock'; +import { FLEET_ROUTING_PATHS, pagePathGetters, PLUGIN_ID } from '../../../constants'; import type { CreatePackagePolicyRouteState } from '../../../types'; import { CreatePackagePolicyPage } from './index'; describe('when on the package policy create page', () => { - const createPageUrlPath = pagePathGetters.add_integration_to_policy({ pkgkey: 'nginx-0.3.7' }); + const createPageUrlPath = pagePathGetters.add_integration_to_policy({ pkgkey: 'nginx-0.3.7' })[1]; let testRenderer: TestRenderer; let renderResult: ReturnType; const render = () => (renderResult = testRenderer.render( - + )); beforeEach(() => { - testRenderer = createTestRendererMock(); + testRenderer = createFleetTestRendererMock(); mockApiCalls(testRenderer.startServices.http); testRenderer.history.push(createPageUrlPath); }); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx index 55861726af46617..6563918a5efb2ca 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx @@ -39,12 +39,11 @@ import { } from '../../../hooks'; import { Loading } from '../../../components'; import { ConfirmDeployAgentPolicyModal } from '../components'; -import { useIntraAppState } from '../../../hooks/use_intra_app_state'; -import { useUIExtension } from '../../../hooks/use_ui_extension'; -import { ExtensionWrapper } from '../../../components/extension_wrapper'; +import { useIntraAppState, useUIExtension } from '../../../hooks'; +import { ExtensionWrapper } from '../../../components'; import type { PackagePolicyEditExtensionComponentProps } from '../../../types'; import { PLUGIN_ID } from '../../../../../../common/constants'; -import { pkgKeyFromPackageInfo } from '../../../services/pkg_key_from_package_info'; +import { pkgKeyFromPackageInfo } from '../../../services'; import { CreatePackagePolicyPageLayout } from './components'; import type { CreatePackagePolicyFrom, PackagePolicyFormState } from './types'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_define_package_policy.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_define_package_policy.tsx index 26a31a1394f7897..380e49a1d8dd97a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_define_package_policy.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_define_package_policy.tsx @@ -27,9 +27,8 @@ import type { NewPackagePolicy, RegistryVarsEntry, } from '../../../types'; -import { packageToPackagePolicy } from '../../../services'; +import { packageToPackagePolicy, pkgKeyFromPackageInfo } from '../../../services'; import { Loading } from '../../../components'; -import { pkgKeyFromPackageInfo } from '../../../services/pkg_key_from_package_info'; import { isAdvancedVar } from './services'; import type { PackagePolicyValidationResults } from './services'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_select_package.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_select_package.tsx index 80faba37e9a4358..50c63274b5e85c5 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_select_package.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_select_package.tsx @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFlexGroup, EuiFlexItem, EuiSelectable, EuiSpacer } from '@elastic/eui'; -import { Error } from '../../../components'; +import { Error, PackageIcon } from '../../../components'; import type { AgentPolicy, PackageInfo, PackagePolicy, GetPackagesResponse } from '../../../types'; import { useGetOneAgentPolicy, @@ -18,8 +18,7 @@ import { useGetLimitedPackages, sendGetPackageInfoByKey, } from '../../../hooks'; -import { PackageIcon } from '../../../components/package_icon'; -import { pkgKeyFromPackageInfo } from '../../../services/pkg_key_from_package_info'; +import { pkgKeyFromPackageInfo } from '../../../services'; export const StepSelectPackage: React.FunctionComponent<{ agentPolicyId: string; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx index e96ef8322401375..7138abb081a77f6 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx @@ -26,18 +26,18 @@ import type { Props as EuiTabProps } from '@elastic/eui/src/components/tabs/tab' import styled from 'styled-components'; import type { AgentPolicy, AgentPolicyDetailsDeployAgentAction } from '../../../types'; -import { PAGE_ROUTING_PATHS } from '../../../constants'; +import { FLEET_ROUTING_PATHS } from '../../../constants'; import { useGetOneAgentPolicy, useLink, useBreadcrumbs, useStartServices, useFleetStatus, + useIntraAppState, } from '../../../hooks'; import { Loading, Error } from '../../../components'; import { WithHeaderLayout } from '../../../layouts'; import { LinkedAgentCount, AgentPolicyActionMenu } from '../components'; -import { useIntraAppState } from '../../../hooks/use_intra_app_state'; import { AgentPolicyRefreshContext, useGetAgentStatus, AgentStatusRefreshContext } from './hooks'; import { PackagePoliciesView, SettingsView } from './components'; @@ -327,13 +327,13 @@ const AgentPolicyDetailsContent: React.FunctionComponent<{ agentPolicy: AgentPol return ( { return ; }} /> { return ; }} diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx index 3b9b5696ff7bdcb..fb3603aaef7f4df 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx @@ -24,13 +24,14 @@ import { useBreadcrumbs, useStartServices, useConfig, + useUIExtension, sendUpdatePackagePolicy, sendGetAgentStatus, sendGetOneAgentPolicy, sendGetOnePackagePolicy, sendGetPackageInfoByKey, } from '../../../hooks'; -import { Loading, Error } from '../../../components'; +import { Loading, Error, ExtensionWrapper } from '../../../components'; import { ConfirmDeployAgentPolicyModal } from '../components'; import { CreatePackagePolicyPageLayout } from '../create_package_policy_page/components'; import type { PackagePolicyValidationResults } from '../create_package_policy_page/services'; @@ -41,11 +42,9 @@ import type { } from '../create_package_policy_page/types'; import { StepConfigurePackagePolicy } from '../create_package_policy_page/step_configure_package'; import { StepDefinePackagePolicy } from '../create_package_policy_page/step_define_package_policy'; -import { useUIExtension } from '../../../hooks/use_ui_extension'; -import { ExtensionWrapper } from '../../../components/extension_wrapper'; import type { GetOnePackagePolicyResponse } from '../../../../../../common/types/rest_spec'; import type { PackagePolicyEditExtensionComponentProps } from '../../../types'; -import { pkgKeyFromPackageInfo } from '../../../services/pkg_key_from_package_info'; +import { pkgKeyFromPackageInfo } from '../../../services'; export const EditPackagePolicyPage = memo(() => { const { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/index.tsx index 56b99f645f97c57..dd6611d581e89fa 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/index.tsx @@ -23,7 +23,7 @@ import { i18n } from '@kbn/i18n'; import { EuiIconTip } from '@elastic/eui'; import type { Agent, AgentPolicy, AgentDetailsReassignPolicyAction } from '../../../types'; -import { PAGE_ROUTING_PATHS } from '../../../constants'; +import { FLEET_ROUTING_PATHS } from '../../../constants'; import { Loading, Error } from '../../../components'; import { useGetOneAgent, @@ -32,10 +32,10 @@ import { useBreadcrumbs, useStartServices, useKibanaVersion, + useIntraAppState, } from '../../../hooks'; import { WithHeaderLayout } from '../../../layouts'; import { AgentHealth } from '../components'; -import { useIntraAppState } from '../../../hooks/use_intra_app_state'; import { isAgentUpgradeable } from '../../../services'; import { AgentRefreshContext } from './hooks'; @@ -309,13 +309,13 @@ const AgentDetailsPageContent: React.FunctionComponent<{ return ( { return ; }} /> { return ; }} diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx index 89ac1b4f43b5f85..605888349ab4ec7 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx @@ -14,7 +14,7 @@ import { FLEET_SERVER_PACKAGE } from '../../../../../../common/constants'; import type { PackagePolicy, PackagePolicyPackage } from '../../../types'; import { useGetOneAgentPolicy } from '../../../hooks'; -import { PackageIcon } from '../../../components/package_icon'; +import { PackageIcon } from '../../../components'; interface Props { agentPolicyId: string; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/list_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/list_page/index.tsx index f8518dc2a866851..e805fb8f6f64ef2 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/list_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/data_stream/list_page/index.tsx @@ -22,7 +22,7 @@ import { FormattedMessage, FormattedDate } from '@kbn/i18n/react'; import type { DataStream } from '../../../types'; import { WithHeaderLayout } from '../../../layouts'; import { useGetDataStreams, useStartServices, usePagination, useBreadcrumbs } from '../../../hooks'; -import { PackageIcon } from '../../../components/package_icon'; +import { PackageIcon } from '../../../components'; import { DataStreamRowActions } from './components/data_stream_row_actions'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/services/index.ts b/x-pack/plugins/fleet/public/applications/fleet/services/index.ts index 07fb04628ea2e54..434e1addfdfa27f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/services/index.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/services/index.ts @@ -5,29 +5,4 @@ * 2.0. */ -export { getFlattenedObject } from '@kbn/std'; - -export { - AgentStatusKueryHelper, - agentPolicyRouteService, - packagePolicyRouteService, - dataStreamRouteService, - fleetSetupRouteService, - agentRouteService, - enrollmentAPIKeyRouteService, - epmRouteService, - setupRouteService, - outputRoutesService, - settingsRoutesService, - appRoutesService, - packageToPackagePolicy, - packageToPackagePolicyInputs, - storedPackagePoliciesToAgentInputs, - fullAgentPolicyToYaml, - isPackageLimited, - doesAgentPolicyAlreadyIncludePackage, - isValidNamespace, - LicenseService, - isAgentUpgradeable, - doesPackageHaveIntegrations, -} from '../../../../common'; +export * from '../../../services'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/types/index.ts b/x-pack/plugins/fleet/public/applications/fleet/types/index.ts index ea9bab2fb74e5ce..287b3f08566dfad 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/types/index.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/types/index.ts @@ -5,125 +5,4 @@ * 2.0. */ -export { - // utility function - entries, - // Object types - Agent, - AgentMetadata, - AgentPolicy, - NewAgentPolicy, - SimplifiedAgentStatus, - EnrollmentAPIKey, - PackagePolicy, - NewPackagePolicy, - UpdatePackagePolicy, - PackagePolicyInput, - NewPackagePolicyInput, - PackagePolicyInputStream, - NewPackagePolicyInputStream, - PackagePolicyConfigRecord, - PackagePolicyConfigRecordEntry, - PackagePolicyPackage, - Output, - DataStream, - // API schema - misc setup, status - GetFleetStatusResponse, - // API schemas - Agent policy - GetAgentPoliciesRequest, - GetAgentPoliciesResponse, - GetAgentPoliciesResponseItem, - GetOneAgentPolicyResponse, - GetFullAgentPolicyResponse, - CreateAgentPolicyRequest, - CreateAgentPolicyResponse, - UpdateAgentPolicyRequest, - UpdateAgentPolicyResponse, - CopyAgentPolicyRequest, - CopyAgentPolicyResponse, - DeleteAgentPolicyRequest, - DeleteAgentPolicyResponse, - // API schemas - Package policy - CreatePackagePolicyRequest, - CreatePackagePolicyResponse, - UpdatePackagePolicyRequest, - UpdatePackagePolicyResponse, - GetPackagePoliciesResponse, - // API schemas - Data streams - GetDataStreamsResponse, - // API schemas - Agents - GetAgentsResponse, - GetAgentsRequest, - GetOneAgentResponse, - PostAgentUnenrollRequest, - PostAgentUnenrollResponse, - PostBulkAgentUnenrollRequest, - PostBulkAgentUnenrollResponse, - PostAgentUpgradeRequest, - PostBulkAgentUpgradeRequest, - PostAgentUpgradeResponse, - PostBulkAgentUpgradeResponse, - GetAgentStatusRequest, - GetAgentStatusResponse, - PutAgentReassignRequest, - PutAgentReassignResponse, - PostBulkAgentReassignRequest, - PostBulkAgentReassignResponse, - PostNewAgentActionResponse, - PostNewAgentActionRequest, - // API schemas - Enrollment API Keys - GetEnrollmentAPIKeysResponse, - GetEnrollmentAPIKeysRequest, - GetOneEnrollmentAPIKeyResponse, - // API schemas - Outputs - GetOutputsResponse, - PutOutputRequest, - PutOutputResponse, - // API schemas - Settings - GetSettingsResponse, - PutSettingsRequest, - PutSettingsResponse, - // API schemas - app - CheckPermissionsResponse, - GenerateServiceTokenResponse, - // EPM types - AssetReference, - AssetsGroupedByServiceByType, - AssetType, - AssetTypeToParts, - CategoryId, - CategorySummaryItem, - CategorySummaryList, - ElasticsearchAssetType, - KibanaAssetType, - PackageInfo, - RegistryVarsEntry, - RegistryInput, - RegistryStream, - RegistryPolicyTemplate, - PackageList, - PackageListItem, - PackagesGroupedByStatus, - RequirementsByServiceName, - RequirementVersion, - ScreenshotItem, - ServiceName, - GetCategoriesRequest, - GetCategoriesResponse, - GetPackagesRequest, - GetPackagesResponse, - GetLimitedPackagesResponse, - GetInfoResponse, - InstallPackageResponse, - DeletePackageResponse, - DetailViewPanelName, - InstallStatus, - InstallationStatus, - Installable, - RegistryRelease, - PackageSpecCategory, -} from '../../../../common'; - -export * from './intra_app_route_state'; - -export * from './ui_extensions'; +export * from '../../../types'; diff --git a/x-pack/plugins/fleet/public/applications/integrations/app.tsx b/x-pack/plugins/fleet/public/applications/integrations/app.tsx new file mode 100644 index 000000000000000..12f5e3c0507546d --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/integrations/app.tsx @@ -0,0 +1,233 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { memo, useEffect, useState } from 'react'; +import type { AppMountParameters } from 'kibana/public'; +import { EuiCode, EuiEmptyPrompt, EuiErrorBoundary, EuiPanel } from '@elastic/eui'; +import type { History } from 'history'; +import { createHashHistory } from 'history'; +import { Router, Redirect, Route, Switch } from 'react-router-dom'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; +import styled from 'styled-components'; +import useObservable from 'react-use/lib/useObservable'; + +import { + ConfigContext, + FleetStatusProvider, + KibanaVersionContext, + sendGetPermissionsCheck, + sendSetup, +} from '../../hooks'; + +import type { FleetConfigType, FleetStartServices } from '../../plugin'; + +import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; +import { EuiThemeProvider } from '../../../../../../src/plugins/kibana_react/common'; + +import { INTEGRATIONS_ROUTING_PATHS } from './constants'; + +import { Error, Loading } from './components'; + +import type { UIExtensionsStorage } from './types'; + +import { EPMApp } from './sections/epm'; +import { DefaultLayout, WithoutHeaderLayout } from './layouts'; +import { PackageInstallProvider } from './hooks'; +import { useBreadcrumbs, IntraAppStateProvider, UIExtensionsContext } from './hooks'; + +const ErrorLayout = ({ children }: { children: JSX.Element }) => ( + + + {children} + + +); + +const Panel = styled(EuiPanel)` + max-width: 500px; + margin-right: auto; + margin-left: auto; +`; + +export const WithPermissionsAndSetup: React.FC = memo(({ children }) => { + useBreadcrumbs('integrations'); + + const [isPermissionsLoading, setIsPermissionsLoading] = useState(false); + const [permissionsError, setPermissionsError] = useState(); + const [isInitialized, setIsInitialized] = useState(false); + const [initializationError, setInitializationError] = useState(null); + + useEffect(() => { + (async () => { + setIsPermissionsLoading(false); + setPermissionsError(undefined); + setIsInitialized(false); + setInitializationError(null); + try { + setIsPermissionsLoading(true); + const permissionsResponse = await sendGetPermissionsCheck(); + setIsPermissionsLoading(false); + if (permissionsResponse.data?.success) { + try { + const setupResponse = await sendSetup(); + if (setupResponse.error) { + setInitializationError(setupResponse.error); + } + } catch (err) { + setInitializationError(err); + } + setIsInitialized(true); + } else { + setPermissionsError(permissionsResponse.data?.error || 'REQUEST_ERROR'); + } + } catch (err) { + setPermissionsError('REQUEST_ERROR'); + } + })(); + }, []); + + if (isPermissionsLoading || permissionsError) { + return ( + + {isPermissionsLoading ? ( + + ) : permissionsError === 'REQUEST_ERROR' ? ( + + } + error={i18n.translate('xpack.fleet.permissionsRequestErrorMessageDescription', { + defaultMessage: 'There was a problem checking Fleet permissions', + })} + /> + ) : ( + + + {permissionsError === 'MISSING_SUPERUSER_ROLE' ? ( + + ) : ( + + )} + + } + body={ +

+ {permissionsError === 'MISSING_SUPERUSER_ROLE' ? ( + superuser }} + /> + ) : ( + + )} +

+ } + /> +
+ )} +
+ ); + } + + if (!isInitialized || initializationError) { + return ( + + {initializationError ? ( + + } + error={initializationError} + /> + ) : ( + + )} + + ); + } + + return <>{children}; +}); + +/** + * Fleet Application context all the way down to the Router, but with no permissions or setup checks + * and no routes defined + */ +export const IntegrationsAppContext: React.FC<{ + basepath: string; + startServices: FleetStartServices; + config: FleetConfigType; + history: AppMountParameters['history']; + kibanaVersion: string; + extensions: UIExtensionsStorage; + /** For testing purposes only */ + routerHistory?: History; +}> = memo( + ({ children, startServices, config, history, kibanaVersion, extensions, routerHistory }) => { + const isDarkMode = useObservable(startServices.uiSettings.get$('theme:darkMode')); + const [routerHistoryInstance] = useState(routerHistory || createHashHistory()); + + return ( + + + + + + + + + + + + {children} + + + + + + + + + + + + ); + } +); + +export const AppRoutes = memo(() => { + return ( + + + + + + + + + ); +}); diff --git a/x-pack/plugins/fleet/public/applications/integrations/components/index.ts b/x-pack/plugins/fleet/public/applications/integrations/components/index.ts new file mode 100644 index 000000000000000..727ecb1c991ea6e --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/integrations/components/index.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +export * from '../../../components'; diff --git a/x-pack/plugins/fleet/public/applications/integrations/constants.tsx b/x-pack/plugins/fleet/public/applications/integrations/constants.tsx new file mode 100644 index 000000000000000..403a47f4b94b2fe --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/integrations/constants.tsx @@ -0,0 +1,61 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { IconType } from '@elastic/eui'; + +import type { AssetType, ServiceName } from '../../types'; +import { ElasticsearchAssetType, KibanaAssetType } from '../../types'; + +export * from '../../constants'; + +// only allow Kibana assets for the kibana key, ES asssets for elasticsearch, etc +type ServiceNameToAssetTypes = Record, KibanaAssetType[]> & + Record, ElasticsearchAssetType[]>; + +export const DisplayedAssets: ServiceNameToAssetTypes = { + kibana: Object.values(KibanaAssetType), + elasticsearch: Object.values(ElasticsearchAssetType), +}; + +export const AssetTitleMap: Record = { + dashboard: 'Dashboard', + ilm_policy: 'ILM Policy', + ingest_pipeline: 'Ingest Pipeline', + transform: 'Transform', + index_pattern: 'Index Pattern', + index_template: 'Index Template', + component_template: 'Component Template', + search: 'Saved Search', + visualization: 'Visualization', + input: 'Agent input', + map: 'Map', + data_stream_ilm_policy: 'Data Stream ILM Policy', + lens: 'Lens', + security_rule: 'Security Rule', + ml_module: 'ML Module', +}; + +export const ServiceTitleMap: Record = { + kibana: 'Kibana', + elasticsearch: 'Elasticsearch', +}; + +export const AssetIcons: Record = { + dashboard: 'dashboardApp', + index_pattern: 'indexPatternApp', + search: 'searchProfilerApp', + visualization: 'visualizeApp', + map: 'emsApp', + lens: 'lensApp', + security_rule: 'securityApp', + ml_module: 'mlApp', +}; + +export const ServiceIcons: Record = { + elasticsearch: 'logoElasticsearch', + kibana: 'logoKibana', +}; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/index.tsx b/x-pack/plugins/fleet/public/applications/integrations/hooks/index.ts similarity index 55% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/index.tsx rename to x-pack/plugins/fleet/public/applications/integrations/hooks/index.ts index 45f189afe350abe..adbb0236507945a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/index.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/hooks/index.ts @@ -4,13 +4,10 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ +export * from '../../../hooks'; +export { useBreadcrumbs } from './use_breadcrumbs'; +export { useEPMLinks } from './use_epm_links'; export { useLinks } from './use_links'; -export { useLocalSearch, searchIdField } from './use_local_search'; -export { - PackageInstallProvider, - useUninstallPackage, - useGetPackageInstallStatus, - useInstallPackage, - useSetPackageInstallStatus, -} from './use_package_install'; +export * from './use_local_search'; +export * from './use_package_install'; diff --git a/x-pack/plugins/fleet/public/applications/integrations/hooks/use_breadcrumbs.tsx b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_breadcrumbs.tsx new file mode 100644 index 000000000000000..0d9928ba272b70c --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_breadcrumbs.tsx @@ -0,0 +1,155 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import { i18n } from '@kbn/i18n'; +import type { ChromeBreadcrumb } from 'src/core/public'; + +import type { Page, DynamicPagePathValues } from '../constants'; +import { INTEGRATIONS_BASE_PATH, pagePathGetters } from '../constants'; + +import { useStartServices } from './index'; + +const BASE_BREADCRUMB: ChromeBreadcrumb = { + href: pagePathGetters.integrations()[1], + text: i18n.translate('xpack.fleet.breadcrumbs.integrationsAppTitle', { + defaultMessage: 'Integrations', + }), +}; + +const breadcrumbGetters: { + [key in Page]?: (values: DynamicPagePathValues) => ChromeBreadcrumb[]; +} = { + integrations: () => [ + BASE_BREADCRUMB, + { + text: i18n.translate('xpack.fleet.breadcrumbs.integrationsPageTitle', { + defaultMessage: 'Integrations', + }), + }, + ], + integrations_all: () => [ + BASE_BREADCRUMB, + { + href: pagePathGetters.integrations()[1], + text: i18n.translate('xpack.fleet.breadcrumbs.integrationsPageTitle', { + defaultMessage: 'Integrations', + }), + }, + { + text: i18n.translate('xpack.fleet.breadcrumbs.allIntegrationsPageTitle', { + defaultMessage: 'All', + }), + }, + ], + integrations_installed: () => [ + BASE_BREADCRUMB, + { + href: pagePathGetters.integrations()[1], + text: i18n.translate('xpack.fleet.breadcrumbs.integrationsPageTitle', { + defaultMessage: 'Integrations', + }), + }, + { + text: i18n.translate('xpack.fleet.breadcrumbs.installedIntegrationsPageTitle', { + defaultMessage: 'Installed', + }), + }, + ], + integration_details_overview: ({ pkgTitle }) => [ + BASE_BREADCRUMB, + { + href: pagePathGetters.integrations()[1], + text: i18n.translate('xpack.fleet.breadcrumbs.integrationsPageTitle', { + defaultMessage: 'Integrations', + }), + }, + { text: pkgTitle }, + ], + integration_policy_edit: ({ pkgTitle, pkgkey, policyName }) => [ + BASE_BREADCRUMB, + { + href: pagePathGetters.integrations()[1], + text: i18n.translate('xpack.fleet.breadcrumbs.integrationPageTitle', { + defaultMessage: 'Integration', + }), + }, + { + href: pagePathGetters.integration_details_policies({ pkgkey })[1], + text: pkgTitle, + }, + { text: policyName }, + ], + add_integration_from_policy: ({ policyName, policyId }) => [ + BASE_BREADCRUMB, + { + href: pagePathGetters.policies()[1], + text: i18n.translate('xpack.fleet.breadcrumbs.policiesPageTitle', { + defaultMessage: 'Policies', + }), + }, + { + href: pagePathGetters.policy_details({ policyId })[1], + text: policyName, + }, + { + text: i18n.translate('xpack.fleet.breadcrumbs.addPackagePolicyPageTitle', { + defaultMessage: 'Add integration', + }), + }, + ], + add_integration_to_policy: ({ pkgTitle, pkgkey }) => [ + BASE_BREADCRUMB, + { + href: pagePathGetters.integrations()[1], + text: i18n.translate('xpack.fleet.breadcrumbs.integrationsPageTitle', { + defaultMessage: 'Integrations', + }), + }, + { + href: pagePathGetters.integration_details_overview({ pkgkey })[1], + text: pkgTitle, + }, + { + text: i18n.translate('xpack.fleet.breadcrumbs.addPackagePolicyPageTitle', { + defaultMessage: 'Add integration', + }), + }, + ], + edit_integration: ({ policyName, policyId }) => [ + BASE_BREADCRUMB, + { + href: pagePathGetters.policies()[1], + text: i18n.translate('xpack.fleet.breadcrumbs.policiesPageTitle', { + defaultMessage: 'Policies', + }), + }, + { + href: pagePathGetters.policy_details({ policyId })[1], + text: policyName, + }, + { + text: i18n.translate('xpack.fleet.breadcrumbs.editPackagePolicyPageTitle', { + defaultMessage: 'Edit integration', + }), + }, + ], +}; + +export function useBreadcrumbs(page: Page, values: DynamicPagePathValues = {}) { + const { chrome, http } = useStartServices(); + const breadcrumbs: ChromeBreadcrumb[] = + breadcrumbGetters[page]?.(values).map((breadcrumb) => ({ + ...breadcrumb, + href: breadcrumb.href + ? http.basePath.prepend(`${INTEGRATIONS_BASE_PATH}#${breadcrumb.href}`) + : undefined, + })) || []; + const docTitle: string[] = [...breadcrumbs] + .reverse() + .map((breadcrumb) => breadcrumb.text as string); + chrome.docTitle.change(docTitle); + chrome.setBreadcrumbs(breadcrumbs); +} diff --git a/x-pack/plugins/fleet/public/applications/integrations/hooks/use_epm_links.tsx b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_epm_links.tsx new file mode 100644 index 000000000000000..39c71ea5bb49aac --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_epm_links.tsx @@ -0,0 +1,47 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import { useStartServices } from '../hooks'; +import { PLUGIN_ID } from '../constants'; +import { epmRouteService } from '../services'; +import type { PackageSpecIcon, PackageSpecScreenshot, RegistryImage } from '../../../../common'; + +const removeRelativePath = (relativePath: string): string => + new URL(relativePath, 'http://example.com').pathname; + +export function useEPMLinks() { + const { http } = useStartServices(); + return { + toAssets: (path: string) => http.basePath.prepend(`/plugins/${PLUGIN_ID}/assets/${path}`), + toPackageImage: ( + img: PackageSpecIcon | PackageSpecScreenshot | RegistryImage, + pkgName: string, + pkgVersion: string + ): string | undefined => { + const sourcePath = img.src + ? `/package/${pkgName}/${pkgVersion}${img.src}` + : 'path' in img && img.path; + if (sourcePath) { + const filePath = epmRouteService.getFilePath(sourcePath); + return http.basePath.prepend(filePath); + } + }, + toRelativeImage: ({ + path, + packageName, + version, + }: { + path: string; + packageName: string; + version: string; + }) => { + const imagePath = removeRelativePath(path); + const pkgkey = `${packageName}-${version}`; + const filePath = `${epmRouteService.getInfoPath(pkgkey)}/${imagePath}`; + return http.basePath.prepend(filePath); + }, + }; +} diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_links.tsx b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_links.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_links.tsx rename to x-pack/plugins/fleet/public/applications/integrations/hooks/use_links.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_local_search.tsx b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_local_search.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_local_search.tsx rename to x-pack/plugins/fleet/public/applications/integrations/hooks/use_local_search.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_package_install.tsx b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.tsx similarity index 98% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_package_install.tsx rename to x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.tsx index 4f8242fe42613a4..342d6b54c2613d7 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/hooks/use_package_install.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.tsx @@ -11,7 +11,7 @@ import { useHistory } from 'react-router-dom'; import { FormattedMessage } from '@kbn/i18n/react'; import type { NotificationsStart } from 'src/core/public'; -import { toMountPoint } from '../../../../../../../../../src/plugins/kibana_react/public'; +import { toMountPoint } from '../../../../../../../src/plugins/kibana_react/public'; import type { PackageInfo } from '../../../types'; import { sendInstallPackage, sendRemovePackage, useLink } from '../../../hooks'; import { InstallStatus } from '../../../types'; diff --git a/x-pack/plugins/fleet/public/applications/integrations/index.tsx b/x-pack/plugins/fleet/public/applications/integrations/index.tsx new file mode 100644 index 000000000000000..da8959a019ce572 --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/integrations/index.tsx @@ -0,0 +1,93 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import React from 'react'; +import ReactDOM from 'react-dom'; +import { Redirect, Route } from 'react-router-dom'; +import type { RouteProps } from 'react-router-dom'; + +import type { CoreStart, AppMountParameters } from 'src/core/public'; + +import type { FleetConfigType, FleetStartServices } from '../../plugin'; +import { licenseService } from '../../hooks'; +import type { UIExtensionsStorage } from '../../types'; + +import { AppRoutes, IntegrationsAppContext, WithPermissionsAndSetup } from './app'; + +export interface ProtectedRouteProps extends RouteProps { + isAllowed?: boolean; + restrictedPath?: string; +} + +export const ProtectedRoute: React.FunctionComponent = ({ + isAllowed = false, + restrictedPath = '/', + ...routeProps +}: ProtectedRouteProps) => { + return isAllowed ? : ; +}; + +interface IntegrationsAppProps { + basepath: string; + startServices: FleetStartServices; + config: FleetConfigType; + history: AppMountParameters['history']; + kibanaVersion: string; + extensions: UIExtensionsStorage; +} +const IntegrationsApp = ({ + basepath, + startServices, + config, + history, + kibanaVersion, + extensions, +}: IntegrationsAppProps) => { + return ( + + + + + + ); +}; + +export function renderApp( + startServices: FleetStartServices, + { element, appBasePath, history }: AppMountParameters, + config: FleetConfigType, + kibanaVersion: string, + extensions: UIExtensionsStorage +) { + ReactDOM.render( + , + element + ); + + return () => { + ReactDOM.unmountComponentAtNode(element); + }; +} + +export const teardownIntegrations = (coreStart: CoreStart) => { + coreStart.chrome.docTitle.reset(); + coreStart.chrome.setBreadcrumbs([]); + licenseService.stop(); +}; diff --git a/x-pack/plugins/fleet/public/applications/integrations/layouts/default.tsx b/x-pack/plugins/fleet/public/applications/integrations/layouts/default.tsx new file mode 100644 index 000000000000000..4c1ff4972b89e27 --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/integrations/layouts/default.tsx @@ -0,0 +1,71 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import React, { memo } from 'react'; +import { EuiText, EuiBetaBadge } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; + +import { useLink } from '../../../hooks'; +import type { Section } from '../sections'; + +import { HeroImage } from '../sections/epm/screens/home/header'; + +import { WithHeaderLayout } from './'; + +interface Props { + section?: Section; + children?: React.ReactNode; +} + +export const DefaultLayout: React.FunctionComponent = memo(({ section, children }) => { + const { getHref } = useLink(); + + return ( + } + leftColumn={ + +

+ {' '} + } + tooltipContent={ + + } + /> +

+
+ } + tabs={[ + { + name: ( + + ), + isSelected: section === 'browse', + href: getHref('integrations_all'), + }, + { + name: ( + + ), + isSelected: section === 'manage', + href: getHref('integrations_installed'), + }, + ]} + > + {children} +
+ ); +}); diff --git a/x-pack/plugins/fleet/public/applications/integrations/layouts/index.ts b/x-pack/plugins/fleet/public/applications/integrations/layouts/index.ts new file mode 100644 index 000000000000000..71cb8d3aeeb3696 --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/integrations/layouts/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export * from '../../../layouts'; + +export { DefaultLayout } from './default'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/assets_facet_group.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/assets_facet_group.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/assets_facet_group.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/assets_facet_group.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/icons.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/icons.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/icons.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/icons.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_card.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_card.tsx similarity index 96% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_card.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_card.tsx index be76f05b0f5a14e..c12e67fdb571813 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_card.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_card.tsx @@ -11,7 +11,7 @@ import { EuiCard } from '@elastic/eui'; import type { PackageListItem } from '../../../types'; import { useLink } from '../../../hooks'; -import { PackageIcon } from '../../../components/package_icon'; +import { PackageIcon } from '../../../components'; import { RELEASE_BADGE_LABEL, RELEASE_BADGE_DESCRIPTION } from './release_badge'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_list_grid.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_list_grid.tsx similarity index 98% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_list_grid.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_list_grid.tsx index d4d2b481950f6bc..7e56c25c2bbe71a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/package_list_grid.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_list_grid.tsx @@ -24,7 +24,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { Loading } from '../../../components'; import type { PackageList } from '../../../types'; -import { useLocalSearch, searchIdField } from '../hooks'; +import { useLocalSearch, searchIdField } from '../../../hooks'; import { PackageCard } from './package_card'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/release_badge.ts b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/release_badge.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/release_badge.ts rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/release_badge.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/requirements.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/requirements.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/requirements.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/requirements.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/version.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/version.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/components/version.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/version.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/constants.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/constants.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/constants.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/constants.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/index.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/index.tsx similarity index 63% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/index.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/index.tsx index cb94ddf3ddf2a32..07fd657a01708f6 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/index.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/index.tsx @@ -8,9 +8,8 @@ import React from 'react'; import { Switch, Route } from 'react-router-dom'; -import { PAGE_ROUTING_PATHS } from '../../constants'; +import { INTEGRATIONS_ROUTING_PATHS } from '../../constants'; import { useBreadcrumbs } from '../../hooks'; -import { CreatePackagePolicyPage } from '../agent_policy/create_package_policy_page'; import { EPMHomePage } from './screens/home'; import { Detail } from './screens/detail'; @@ -21,16 +20,13 @@ export const EPMApp: React.FunctionComponent = () => { return ( - - - - + - + - + diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/icon_panel.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/components/icon_panel.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/icon_panel.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/components/icon_panel.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/index.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/components/index.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/index.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/components/index.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/integration_agent_policy_count.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/components/integration_agent_policy_count.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/integration_agent_policy_count.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/components/integration_agent_policy_count.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/update_icon.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/components/update_icon.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/components/update_icon.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/components/update_icon.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/custom/custom.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/custom/custom.tsx similarity index 79% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/custom/custom.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/custom/custom.tsx index 6f76acbe187c677..ef8d21236c67045 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/custom/custom.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/custom/custom.tsx @@ -8,11 +8,10 @@ import React, { memo, useMemo } from 'react'; import { Redirect } from 'react-router-dom'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { useUIExtension } from '../../../../../hooks/use_ui_extension'; -import { useLink } from '../../../../../hooks'; +import { useLink, useUIExtension } from '../../../../../hooks'; import type { PackageInfo } from '../../../../../types'; -import { pkgKeyFromPackageInfo } from '../../../../../services/pkg_key_from_package_info'; -import { ExtensionWrapper } from '../../../../../components/extension_wrapper'; +import { pkgKeyFromPackageInfo } from '../../../../../services'; +import { ExtensionWrapper } from '../../../../../components'; interface Props { packageInfo: PackageInfo; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/custom/index.ts b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/custom/index.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/custom/index.ts rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/custom/index.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.scss b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.scss similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.scss rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.scss diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.test.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx similarity index 98% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.test.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx index a8e9ddf1c8f7896..0a68ed125b55829 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.test.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx @@ -9,7 +9,7 @@ import React, { lazy, memo } from 'react'; import { Route } from 'react-router-dom'; import { act, cleanup } from '@testing-library/react'; -import { PAGE_ROUTING_PATHS, pagePathGetters } from '../../../../constants'; +import { INTEGRATIONS_ROUTING_PATHS, pagePathGetters } from '../../../../constants'; import type { GetAgentPoliciesResponse, GetFleetStatusResponse, @@ -27,26 +27,26 @@ import { fleetSetupRouteService, packagePolicyRouteService, } from '../../../../../../../common/services'; -import type { MockedFleetStartServices, TestRenderer } from '../../../../mock'; -import { createTestRendererMock } from '../../../../mock'; +import type { MockedFleetStartServices, TestRenderer } from '../../../../../../mock'; +import { createIntegrationsTestRendererMock } from '../../../../../../mock'; import { Detail } from './index'; describe('when on integration detail', () => { const pkgkey = 'nginx-0.3.7'; - const detailPageUrlPath = pagePathGetters.integration_details_overview({ pkgkey }); + const detailPageUrlPath = pagePathGetters.integration_details_overview({ pkgkey })[1]; let testRenderer: TestRenderer; let renderResult: ReturnType; let mockedApi: MockedApi; const render = () => (renderResult = testRenderer.render( - + )); beforeEach(() => { - testRenderer = createTestRendererMock(); + testRenderer = createIntegrationsTestRendererMock(); mockedApi = mockApiCalls(testRenderer.startServices.http); testRenderer.history.push(detailPageUrlPath); }); @@ -106,7 +106,7 @@ describe('when on integration detail', () => { it('should redirect if custom url is accessed', () => { act(() => { testRenderer.history.push( - pagePathGetters.integration_details_custom({ pkgkey: 'nginx-0.3.7' }) + pagePathGetters.integration_details_custom({ pkgkey: 'nginx-0.3.7' })[1] ); }); expect(testRenderer.history.location.pathname).toEqual(detailPageUrlPath); @@ -154,7 +154,7 @@ describe('when on integration detail', () => { it('should display custom content when tab is clicked', async () => { act(() => { testRenderer.history.push( - pagePathGetters.integration_details_custom({ pkgkey: 'nginx-0.3.7' }) + pagePathGetters.integration_details_custom({ pkgkey: 'nginx-0.3.7' })[1] ); }); await lazyComponentWasRendered; @@ -194,7 +194,7 @@ describe('when on integration detail', () => { }); describe('and on the Policies Tab', () => { - const policiesTabURLPath = pagePathGetters.integration_details_policies({ pkgkey }); + const policiesTabURLPath = pagePathGetters.integration_details_policies({ pkgkey })[1]; beforeEach(() => { testRenderer.history.push(policiesTabURLPath); render(); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx similarity index 95% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx index 05d2f53688655e2..0394093d150ac3f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/index.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx @@ -24,10 +24,15 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import semverLt from 'semver/functions/lt'; -import { useUIExtension } from '../../../../hooks/use_ui_extension'; -import { PAGE_ROUTING_PATHS, PLUGIN_ID } from '../../../../constants'; +import { + useGetPackageInstallStatus, + useSetPackageInstallStatus, + useUIExtension, + useBreadcrumbs, +} from '../../../../hooks'; +import { INTEGRATIONS_ROUTING_PATHS, INTEGRATIONS_PLUGIN_ID } from '../../../../constants'; import { useCapabilities, useGetPackageInfoByKey, useLink } from '../../../../hooks'; -import { pkgKeyFromPackageInfo } from '../../../../services/pkg_key_from_package_info'; +import { pkgKeyFromPackageInfo } from '../../../../services'; import type { CreatePackagePolicyRouteState, DetailViewPanelName, @@ -35,11 +40,9 @@ import type { } from '../../../../types'; import { InstallStatus } from '../../../../types'; import { Error, Loading } from '../../../../components'; -import { useBreadcrumbs } from '../../../../hooks'; import type { WithHeaderLayoutProps } from '../../../../layouts'; import { WithHeaderLayout } from '../../../../layouts'; import { RELEASE_BADGE_DESCRIPTION, RELEASE_BADGE_LABEL } from '../../components/release_badge'; -import { useGetPackageInstallStatus, useSetPackageInstallStatus } from '../../hooks'; import { IntegrationAgentPolicyCount, UpdateIcon, IconPanel, LoadingIconPanel } from './components'; import { OverviewPage } from './overview'; @@ -203,7 +206,7 @@ export function Detail() { }); const redirectToPath: CreatePackagePolicyRouteState['onSaveNavigateTo'] & CreatePackagePolicyRouteState['onCancelNavigateTo'] = [ - PLUGIN_ID, + INTEGRATIONS_PLUGIN_ID, { path: currentPath, }, @@ -416,19 +419,19 @@ export function Detail() { ) : ( - + - + - + - + - + )} diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/details.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/details.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/details.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/details.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/index.ts b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/index.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/index.ts rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/index.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/markdown_renderers.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/markdown_renderers.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/markdown_renderers.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/markdown_renderers.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/overview.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/overview.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/overview.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/overview.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/readme.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/readme.tsx similarity index 94% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/readme.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/readme.tsx index d92b4ce598fd26d..240b3c7bf7442cd 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/readme.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/readme.tsx @@ -9,8 +9,7 @@ import { EuiLoadingContent, EuiText } from '@elastic/eui'; import React, { Fragment, useEffect, useState } from 'react'; import ReactMarkdown from 'react-markdown'; -import { useLinks } from '../../../hooks'; -import { sendGetFileByPath } from '../../../../../hooks'; +import { useLinks, sendGetFileByPath } from '../../../../../hooks'; import { markdownRenderers } from './markdown_renderers'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/screenshots.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/screenshots.tsx similarity index 98% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/screenshots.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/screenshots.tsx index 6df3a082ecb93d1..a2a765cf411659d 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/overview/screenshots.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/overview/screenshots.tsx @@ -10,7 +10,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFlexGroup, EuiFlexItem, EuiImage, EuiText, EuiPagination } from '@elastic/eui'; import type { ScreenshotItem } from '../../../../../types'; -import { useLinks } from '../../../hooks'; +import { useLinks } from '../../../../../hooks'; interface ScreenshotProps { images: ScreenshotItem[]; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/index.ts b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/index.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/index.ts rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/index.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/package_policies.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/package_policies.tsx similarity index 96% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/package_policies.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/package_policies.tsx index b14551098e688a3..d5dce6334762c0e 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/package_policies.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/package_policies.tsx @@ -13,11 +13,10 @@ import { i18n } from '@kbn/i18n'; import { FormattedRelative, FormattedMessage } from '@kbn/i18n/react'; import { InstallStatus } from '../../../../../types'; -import { useLink, useUrlPagination } from '../../../../../hooks'; +import { useLink, useUrlPagination, useGetPackageInstallStatus } from '../../../../../hooks'; import { PACKAGE_POLICY_SAVED_OBJECT_TYPE } from '../../../../../constants'; import { AgentPolicySummaryLine } from '../../../../../components'; -import { LinkedAgentCount } from '../../../../../components/linked_agent_count'; -import { useGetPackageInstallStatus } from '../../../hooks'; +import { LinkedAgentCount } from '../../../../../components'; import type { PackagePolicyAndAgentPolicy } from './use_package_policies_with_agent_policy'; import { usePackagePoliciesWithAgentPolicy } from './use_package_policies_with_agent_policy'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/persona.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/persona.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/persona.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/persona.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts similarity index 95% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts index f32047860717c3d..aae43a1acd5689b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts @@ -15,9 +15,8 @@ import type { } from '../../../../../types'; import { agentPolicyRouteService } from '../../../../../services'; import { AGENT_POLICY_SAVED_OBJECT_TYPE } from '../../../../../constants'; -import { useGetPackagePolicies } from '../../../../../hooks'; -import { useConditionalRequest } from '../../../../../hooks/use_request/use_request'; -import type { SendConditionalRequestConfig } from '../../../../../hooks/use_request/use_request'; +import { useGetPackagePolicies, useConditionalRequest } from '../../../../../hooks'; +import type { SendConditionalRequestConfig } from '../../../../../hooks'; export interface PackagePolicyEnriched extends PackagePolicy { _agentPolicy: GetAgentPoliciesResponseItem | undefined; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/confirm_package_install.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/confirm_package_install.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/confirm_package_install.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/confirm_package_install.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/confirm_package_uninstall.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/confirm_package_uninstall.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/confirm_package_uninstall.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/confirm_package_uninstall.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/index.ts b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/index.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/index.ts rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/index.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/installation_button.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/installation_button.tsx similarity index 96% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/installation_button.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/installation_button.tsx index 5edb695188a2ddc..8cf8466e6d9b0bc 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/installation_button.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/installation_button.tsx @@ -11,8 +11,12 @@ import { FormattedMessage } from '@kbn/i18n/react'; import type { PackageInfo } from '../../../../../types'; import { InstallStatus } from '../../../../../types'; -import { useCapabilities } from '../../../../../hooks'; -import { useUninstallPackage, useGetPackageInstallStatus, useInstallPackage } from '../../../hooks'; +import { + useCapabilities, + useUninstallPackage, + useGetPackageInstallStatus, + useInstallPackage, +} from '../../../../../hooks'; import { ConfirmPackageUninstall } from './confirm_package_uninstall'; import { ConfirmPackageInstall } from './confirm_package_install'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/settings.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/settings.tsx similarity index 98% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/settings.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/settings.tsx index f01364fc781574a..995423ea91f9684 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/detail/settings/settings.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/settings.tsx @@ -14,9 +14,8 @@ import { EuiTitle, EuiFlexGroup, EuiFlexItem, EuiText, EuiSpacer } from '@elasti import type { PackageInfo } from '../../../../../types'; import { InstallStatus } from '../../../../../types'; -import { useGetPackagePolicies } from '../../../../../hooks'; +import { useGetPackagePolicies, useGetPackageInstallStatus } from '../../../../../hooks'; import { PACKAGE_POLICY_SAVED_OBJECT_TYPE } from '../../../../../constants'; -import { useGetPackageInstallStatus } from '../../../hooks'; import { UpdateIcon } from '../components'; import { InstallationButton } from './installation_button'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/category_facets.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/home/category_facets.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/category_facets.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/home/category_facets.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/header.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/home/header.tsx similarity index 94% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/header.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/home/header.tsx index 54ee34e9021a57a..55d058a2d7900ed 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/header.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/home/header.tsx @@ -11,8 +11,7 @@ import styled from 'styled-components'; import { EuiFlexGroup, EuiFlexItem, EuiImage, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { useLinks } from '../../hooks'; -import { useStartServices } from '../../../../hooks'; +import { useLinks, useStartServices } from '../../../../hooks'; export const HeroCopy = memo(() => { return ( diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/index.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/home/index.tsx similarity index 97% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/index.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/home/index.tsx index 922628e7b68b13b..aa98b06bce718c7 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/home/index.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/home/index.tsx @@ -12,7 +12,7 @@ import type { Props as EuiTabProps } from '@elastic/eui/src/components/tabs/tab' import { i18n } from '@kbn/i18n'; import { installationStatuses } from '../../../../../../../common/constants'; -import { PAGE_ROUTING_PATHS } from '../../../../constants'; +import { INTEGRATIONS_ROUTING_PATHS } from '../../../../constants'; import { useLink, useGetCategories, useGetPackages, useBreadcrumbs } from '../../../../hooks'; import { doesPackageHaveIntegrations } from '../../../../services'; import { WithHeaderLayout } from '../../../../layouts'; @@ -54,10 +54,10 @@ export const EPMHomePage: React.FC = memo(() => { } > - + - + diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/policy/index.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/policy/index.tsx similarity index 80% rename from x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/policy/index.tsx rename to x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/policy/index.tsx index b8963b8e39514d9..cb95634de4c076b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/screens/policy/index.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/policy/index.tsx @@ -8,7 +8,8 @@ import React, { memo } from 'react'; import { useRouteMatch } from 'react-router-dom'; -import { EditPackagePolicyForm } from '../../../agent_policy/edit_package_policy_page'; +// TODO: Needs to be moved +import { EditPackagePolicyForm } from '../../../../../fleet/sections/agent_policy/edit_package_policy_page'; export const Policy = memo(() => { const { diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/index.ts b/x-pack/plugins/fleet/public/applications/integrations/sections/index.ts new file mode 100644 index 000000000000000..caa399a6cb8852e --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export type Section = 'manage' | 'browse'; diff --git a/x-pack/plugins/fleet/public/applications/integrations/services/index.ts b/x-pack/plugins/fleet/public/applications/integrations/services/index.ts new file mode 100644 index 000000000000000..dffc2027c19a77f --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/integrations/services/index.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +export * from '../../../services'; diff --git a/x-pack/plugins/fleet/public/applications/integrations/types/index.ts b/x-pack/plugins/fleet/public/applications/integrations/types/index.ts new file mode 100644 index 000000000000000..87e3ed4da55ea3d --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/integrations/types/index.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +export * from '../../../types'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/alpha_flyout.tsx b/x-pack/plugins/fleet/public/components/alpha_flyout.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/components/alpha_flyout.tsx rename to x-pack/plugins/fleet/public/components/alpha_flyout.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/alpha_messaging.tsx b/x-pack/plugins/fleet/public/components/alpha_messaging.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/components/alpha_messaging.tsx rename to x-pack/plugins/fleet/public/components/alpha_messaging.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/context_menu_actions.tsx b/x-pack/plugins/fleet/public/components/context_menu_actions.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/components/context_menu_actions.tsx rename to x-pack/plugins/fleet/public/components/context_menu_actions.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/error.tsx b/x-pack/plugins/fleet/public/components/error.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/components/error.tsx rename to x-pack/plugins/fleet/public/components/error.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/extension_wrapper.tsx b/x-pack/plugins/fleet/public/components/extension_wrapper.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/components/extension_wrapper.tsx rename to x-pack/plugins/fleet/public/components/extension_wrapper.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/header.tsx b/x-pack/plugins/fleet/public/components/header.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/components/header.tsx rename to x-pack/plugins/fleet/public/components/header.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/index.tsx b/x-pack/plugins/fleet/public/components/home_integration/index.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/components/home_integration/index.tsx rename to x-pack/plugins/fleet/public/components/home_integration/index.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_header_link.tsx b/x-pack/plugins/fleet/public/components/home_integration/tutorial_directory_header_link.tsx similarity index 93% rename from x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_header_link.tsx rename to x-pack/plugins/fleet/public/components/home_integration/tutorial_directory_header_link.tsx index 106df8a9afb1dc6..0c417e4ad630705 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_header_link.tsx +++ b/x-pack/plugins/fleet/public/components/home_integration/tutorial_directory_header_link.tsx @@ -10,8 +10,8 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButtonEmpty } from '@elastic/eui'; import type { TutorialDirectoryHeaderLinkComponent } from 'src/plugins/home/public'; -import { RedirectAppLinks } from '../../../../../../../../src/plugins/kibana_react/public'; -import { useLink, useCapabilities, useStartServices } from '../../hooks'; +import { RedirectAppLinks } from '../../../../../../src/plugins/kibana_react/public'; +import { useLink, useCapabilities, useStartServices } from '../../applications/fleet/hooks'; import { tutorialDirectoryNoticeState$ } from './tutorial_directory_notice'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_notice.tsx b/x-pack/plugins/fleet/public/components/home_integration/tutorial_directory_notice.tsx similarity index 97% rename from x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_notice.tsx rename to x-pack/plugins/fleet/public/components/home_integration/tutorial_directory_notice.tsx index 4e8123a4fadec9f..53bbd54e750c6c6 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_directory_notice.tsx +++ b/x-pack/plugins/fleet/public/components/home_integration/tutorial_directory_notice.tsx @@ -20,14 +20,14 @@ import { } from '@elastic/eui'; import type { TutorialDirectoryNoticeComponent } from 'src/plugins/home/public'; -import { RedirectAppLinks } from '../../../../../../../../src/plugins/kibana_react/public'; +import { RedirectAppLinks } from '../../../../../../src/plugins/kibana_react/public'; import { sendPutSettings, useGetSettings, useLink, useCapabilities, useStartServices, -} from '../../hooks'; +} from '../../applications/fleet/hooks'; const FlexItemButtonWrapper = styled(EuiFlexItem)` &&& { diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_module_notice.tsx b/x-pack/plugins/fleet/public/components/home_integration/tutorial_module_notice.tsx similarity index 97% rename from x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_module_notice.tsx rename to x-pack/plugins/fleet/public/components/home_integration/tutorial_module_notice.tsx index 51870b482c3f293..f5b76de46e3a448 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/home_integration/tutorial_module_notice.tsx +++ b/x-pack/plugins/fleet/public/components/home_integration/tutorial_module_notice.tsx @@ -11,7 +11,7 @@ import { EuiText, EuiLink, EuiSpacer } from '@elastic/eui'; import type { TutorialModuleNoticeComponent } from 'src/plugins/home/public'; import { useGetPackages, useLink, useCapabilities } from '../../hooks'; -import { pkgKeyFromPackageInfo } from '../../services/pkg_key_from_package_info'; +import { pkgKeyFromPackageInfo } from '../../services'; const TutorialModuleNotice: TutorialModuleNoticeComponent = memo(({ moduleName }) => { const { getHref } = useLink(); diff --git a/x-pack/plugins/fleet/public/components/index.ts b/x-pack/plugins/fleet/public/components/index.ts new file mode 100644 index 000000000000000..6db18c0e73a141a --- /dev/null +++ b/x-pack/plugins/fleet/public/components/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +export { Loading } from './loading'; +export { Error } from './error'; +export { PackageIcon } from './package_icon'; +export { ContextMenuActions } from './context_menu_actions'; +export { LinkedAgentCount } from './linked_agent_count'; +export { ExtensionWrapper } from './extension_wrapper'; +export { AlphaMessaging } from './alpha_messaging'; +export { AlphaFlyout } from './alpha_flyout'; +export { HeaderProps, Header } from './header'; +export * from './link_and_revision'; +export * from './settings_flyout'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/link_and_revision.tsx b/x-pack/plugins/fleet/public/components/link_and_revision.tsx similarity index 97% rename from x-pack/plugins/fleet/public/applications/fleet/components/link_and_revision.tsx rename to x-pack/plugins/fleet/public/components/link_and_revision.tsx index 41ef63b23b564e4..dd36e4b1e239c74 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/link_and_revision.tsx +++ b/x-pack/plugins/fleet/public/components/link_and_revision.tsx @@ -11,7 +11,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import type { CSSProperties } from 'react'; import React, { memo } from 'react'; -import type { AgentPolicy } from '../../../../common/types'; +import type { AgentPolicy } from '../../common/types'; import { useLink } from '../hooks'; const MIN_WIDTH: CSSProperties = { minWidth: 0 }; const NO_WRAP_WHITE_SPACE: CSSProperties = { whiteSpace: 'nowrap' }; diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/linked_agent_count.tsx b/x-pack/plugins/fleet/public/components/linked_agent_count.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/components/linked_agent_count.tsx rename to x-pack/plugins/fleet/public/components/linked_agent_count.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/loading.tsx b/x-pack/plugins/fleet/public/components/loading.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/components/loading.tsx rename to x-pack/plugins/fleet/public/components/loading.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/package_icon.tsx b/x-pack/plugins/fleet/public/components/package_icon.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/components/package_icon.tsx rename to x-pack/plugins/fleet/public/components/package_icon.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/settings_flyout/confirm_modal.tsx b/x-pack/plugins/fleet/public/components/settings_flyout/confirm_modal.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/components/settings_flyout/confirm_modal.tsx rename to x-pack/plugins/fleet/public/components/settings_flyout/confirm_modal.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/settings_flyout/index.tsx b/x-pack/plugins/fleet/public/components/settings_flyout/index.tsx similarity index 98% rename from x-pack/plugins/fleet/public/applications/fleet/components/settings_flyout/index.tsx rename to x-pack/plugins/fleet/public/components/settings_flyout/index.tsx index d741874a7504c5b..9173280f543cef7 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/settings_flyout/index.tsx +++ b/x-pack/plugins/fleet/public/components/settings_flyout/index.tsx @@ -35,9 +35,10 @@ import { useGetSettings, useInput, sendPutSettings, -} from '../../hooks'; -import { useGetOutputs, sendPutOutput } from '../../hooks/use_request/outputs'; -import { isDiffPathProtocol } from '../../../../../common/'; + useGetOutputs, + sendPutOutput, +} from '../../applications/fleet/hooks'; +import { isDiffPathProtocol } from '../../../common'; import { SettingsConfirmModal } from './confirm_modal'; import type { SettingsConfirmModalProps } from './confirm_modal'; diff --git a/x-pack/plugins/fleet/public/constants/index.ts b/x-pack/plugins/fleet/public/constants/index.ts new file mode 100644 index 000000000000000..a7cc2726eace1d9 --- /dev/null +++ b/x-pack/plugins/fleet/public/constants/index.ts @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { + PLUGIN_ID, + INTEGRATIONS_PLUGIN_ID, + EPM_API_ROUTES, + AGENT_API_ROUTES, + SO_SEARCH_LIMIT, + AGENT_POLICY_SAVED_OBJECT_TYPE, + AGENT_SAVED_OBJECT_TYPE, + ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE, + PACKAGE_POLICY_SAVED_OBJECT_TYPE, + FLEET_SERVER_PACKAGE, + // Fleet Server index + AGENTS_INDEX, + ENROLLMENT_API_KEYS_INDEX, +} from '../../common/constants'; + +export * from './page_paths'; + +export const INDEX_NAME = '.kibana'; diff --git a/x-pack/plugins/fleet/public/constants/page_paths.ts b/x-pack/plugins/fleet/public/constants/page_paths.ts new file mode 100644 index 000000000000000..58987ef8d1284ee --- /dev/null +++ b/x-pack/plugins/fleet/public/constants/page_paths.ts @@ -0,0 +1,134 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export type StaticPage = + | 'base' + | 'overview' + | 'integrations' + | 'integrations_all' + | 'integrations_installed' + | 'policies' + | 'policies_list' + | 'fleet' + | 'fleet_enrollment_tokens' + | 'data_streams'; + +export type DynamicPage = + | 'integration_details_overview' + | 'integration_details_policies' + | 'integration_details_settings' + | 'integration_details_custom' + | 'integration_policy_edit' + | 'policy_details' + | 'add_integration_from_policy' + | 'add_integration_to_policy' + | 'edit_integration' + | 'fleet_agent_list' + | 'fleet_agent_details'; + +export type Page = StaticPage | DynamicPage; + +export interface DynamicPagePathValues { + [key: string]: string; +} + +export const FLEET_BASE_PATH = '/app/fleet'; +export const INTEGRATIONS_BASE_PATH = '/app/integrations'; + +// If routing paths are changed here, please also check to see if +// `pagePathGetters()`, below, needs any modifications +export const FLEET_ROUTING_PATHS = { + overview: '/', + policies: '/policies', + policies_list: '/policies', + policy_details: '/policies/:policyId/:tabId?', + policy_details_settings: '/policies/:policyId/settings', + add_integration_from_policy: '/policies/:policyId/add-integration', + // TODO: Should this be in Integrations or Fleet? + add_integration_to_policy: '/:pkgkey/add-integration/:integration?', + edit_integration: '/policies/:policyId/edit-integration/:packagePolicyId', + fleet: '/fleet', + fleet_agent_list: '/fleet/agents', + fleet_agent_details: '/fleet/agents/:agentId/:tabId?', + fleet_agent_details_logs: '/fleet/agents/:agentId/logs', + fleet_enrollment_tokens: '/fleet/enrollment-tokens', + data_streams: '/data-streams', +}; + +export const INTEGRATIONS_ROUTING_PATHS = { + integrations: '/integrations/:tabId?', + integrations_all: '/integrations', + integrations_installed: '/integrations/installed', + integration_details: '/integrations/detail/:pkgkey/:panel?', + integration_details_overview: '/integrations/detail/:pkgkey/overview', + integration_details_policies: '/integrations/detail/:pkgkey/policies', + integration_details_settings: '/integrations/detail/:pkgkey/settings', + integration_details_custom: '/integrations/detail/:pkgkey/custom', + integration_policy_edit: '/integrations/edit-integration/:packagePolicyId', +}; + +export const pagePathGetters: { + [key in StaticPage]: () => [string, string]; +} & + { + [key in DynamicPage]: (values: DynamicPagePathValues) => [string, string]; + } = { + base: () => [FLEET_BASE_PATH, '/'], + overview: () => [FLEET_BASE_PATH, '/'], + integrations: () => [INTEGRATIONS_BASE_PATH, '/'], + integrations_all: () => [INTEGRATIONS_BASE_PATH, '/'], + integrations_installed: () => [INTEGRATIONS_BASE_PATH, '/installed'], + integration_details_overview: ({ pkgkey, integration }) => [ + INTEGRATIONS_BASE_PATH, + `/detail/${pkgkey}/overview${integration ? `?integration=${integration}` : ''}`, + ], + integration_details_policies: ({ pkgkey, integration }) => [ + INTEGRATIONS_BASE_PATH, + `/detail/${pkgkey}/policies${integration ? `?integration=${integration}` : ''}`, + ], + integration_details_settings: ({ pkgkey, integration }) => [ + INTEGRATIONS_BASE_PATH, + `/detail/${pkgkey}/settings${integration ? `?integration=${integration}` : ''}`, + ], + integration_details_custom: ({ pkgkey, integration }) => [ + INTEGRATIONS_BASE_PATH, + `/detail/${pkgkey}/custom${integration ? `?integration=${integration}` : ''}`, + ], + integration_policy_edit: ({ packagePolicyId }) => [ + INTEGRATIONS_BASE_PATH, + `/edit-integration/${packagePolicyId}`, + ], + policies: () => [FLEET_BASE_PATH, '/policies'], + policies_list: () => [FLEET_BASE_PATH, '/policies'], + policy_details: ({ policyId, tabId }) => [ + FLEET_BASE_PATH, + `/policies/${policyId}${tabId ? `/${tabId}` : ''}`, + ], + add_integration_from_policy: ({ policyId }) => [ + FLEET_BASE_PATH, + `/policies/${policyId}/add-integration`, + ], + add_integration_to_policy: ({ pkgkey, integration }) => [ + FLEET_BASE_PATH, + `/${pkgkey}/add-integration${integration ? `/${integration}` : ''}`, + ], + edit_integration: ({ policyId, packagePolicyId }) => [ + FLEET_BASE_PATH, + `/policies/${policyId}/edit-integration/${packagePolicyId}`, + ], + fleet: () => [FLEET_BASE_PATH, '/fleet'], + fleet_agent_list: ({ kuery }) => [ + FLEET_BASE_PATH, + `/fleet/agents${kuery ? `?kuery=${kuery}` : ''}`, + ], + fleet_agent_details: ({ agentId, tabId, logQuery }) => [ + FLEET_BASE_PATH, + `/fleet/agents/${agentId}${tabId ? `/${tabId}` : ''}${logQuery ? `?_q=${logQuery}` : ''}`, + ], + fleet_enrollment_tokens: () => [FLEET_BASE_PATH, '/fleet/enrollment-tokens'], + data_streams: () => [FLEET_BASE_PATH, '/data-streams'], +}; diff --git a/x-pack/plugins/fleet/public/hooks/index.ts b/x-pack/plugins/fleet/public/hooks/index.ts new file mode 100644 index 000000000000000..0b413f72094d9db --- /dev/null +++ b/x-pack/plugins/fleet/public/hooks/index.ts @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { useCapabilities } from './use_capabilities'; +export { useStartServices } from './use_core'; +export { useConfig, ConfigContext } from './use_config'; +export { useKibanaVersion, KibanaVersionContext } from './use_kibana_version'; +export { licenseService, useLicense } from './use_license'; +export { useLink } from './use_link'; +export { useKibanaLink } from './use_kibana_link'; +export { usePackageIconType, UsePackageIconType } from './use_package_icon_type'; +export { usePagination, Pagination, PAGE_SIZE_OPTIONS } from './use_pagination'; +export { useUrlPagination } from './use_url_pagination'; +export { useSorting } from './use_sorting'; +export { useDebounce } from './use_debounce'; +export { useUrlModal } from './use_url_modal'; +export * from './use_request'; +export * from './use_input'; +export * from './use_url_params'; +export * from './use_fleet_status'; +export * from './use_ui_extension'; +export * from './use_intra_app_state'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_capabilities.ts b/x-pack/plugins/fleet/public/hooks/use_capabilities.ts similarity index 85% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_capabilities.ts rename to x-pack/plugins/fleet/public/hooks/use_capabilities.ts index a0449ee8ab0cd40..ccaed566458ac6e 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_capabilities.ts +++ b/x-pack/plugins/fleet/public/hooks/use_capabilities.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { useStartServices } from './'; +import { useStartServices } from '../applications/fleet/hooks'; export function useCapabilities() { const core = useStartServices(); diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_config.ts b/x-pack/plugins/fleet/public/hooks/use_config.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_config.ts rename to x-pack/plugins/fleet/public/hooks/use_config.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_core.ts b/x-pack/plugins/fleet/public/hooks/use_core.ts similarity index 77% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_core.ts rename to x-pack/plugins/fleet/public/hooks/use_core.ts index 30b3a5da94e1c4f..be4a21a094bd44e 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_core.ts +++ b/x-pack/plugins/fleet/public/hooks/use_core.ts @@ -5,8 +5,8 @@ * 2.0. */ -import type { FleetStartServices } from '../../../plugin'; -import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import type { FleetStartServices } from '../plugin'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; export function useStartServices(): FleetStartServices { const { services } = useKibana(); diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_debounce.tsx b/x-pack/plugins/fleet/public/hooks/use_debounce.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_debounce.tsx rename to x-pack/plugins/fleet/public/hooks/use_debounce.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_fleet_status.tsx b/x-pack/plugins/fleet/public/hooks/use_fleet_status.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_fleet_status.tsx rename to x-pack/plugins/fleet/public/hooks/use_fleet_status.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_input.ts b/x-pack/plugins/fleet/public/hooks/use_input.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_input.ts rename to x-pack/plugins/fleet/public/hooks/use_input.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_intra_app_state.tsx b/x-pack/plugins/fleet/public/hooks/use_intra_app_state.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_intra_app_state.tsx rename to x-pack/plugins/fleet/public/hooks/use_intra_app_state.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_kibana_link.ts b/x-pack/plugins/fleet/public/hooks/use_kibana_link.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_kibana_link.ts rename to x-pack/plugins/fleet/public/hooks/use_kibana_link.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_kibana_version.ts b/x-pack/plugins/fleet/public/hooks/use_kibana_version.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_kibana_version.ts rename to x-pack/plugins/fleet/public/hooks/use_kibana_version.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_license.ts b/x-pack/plugins/fleet/public/hooks/use_license.ts similarity index 83% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_license.ts rename to x-pack/plugins/fleet/public/hooks/use_license.ts index fece509ed748540..f5b16c5f3aafc56 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_license.ts +++ b/x-pack/plugins/fleet/public/hooks/use_license.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { LicenseService } from '../../../../common/services/license'; +import { LicenseService } from '../../common/services'; export const licenseService = new LicenseService(); diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_link.ts b/x-pack/plugins/fleet/public/hooks/use_link.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_link.ts rename to x-pack/plugins/fleet/public/hooks/use_link.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_package_icon_type.ts b/x-pack/plugins/fleet/public/hooks/use_package_icon_type.ts similarity index 94% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_package_icon_type.ts rename to x-pack/plugins/fleet/public/hooks/use_package_icon_type.ts index 5701dd100bfed9e..6d0e957109e4780 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_package_icon_type.ts +++ b/x-pack/plugins/fleet/public/hooks/use_package_icon_type.ts @@ -9,7 +9,9 @@ import { useEffect, useState } from 'react'; import { ICON_TYPES } from '@elastic/eui'; import type { PackageInfo, PackageListItem } from '../types'; -import { useLinks } from '../sections/epm/hooks'; + +// TODO: Determine whether this can be relocated +import { useEPMLinks } from '../applications/integrations/hooks'; import { sendGetPackageInfoByKey } from './index'; @@ -32,7 +34,7 @@ export const usePackageIconType = ({ icons: paramIcons, tryApi = false, }: UsePackageIconType) => { - const { toPackageImage } = useLinks(); + const { toPackageImage } = useEPMLinks(); const [iconList, setIconList] = useState(); const [iconType, setIconType] = useState(''); // FIXME: use `empty` icon during initialization - see: https://github.com/elastic/kibana/issues/60622 const cacheKey = `${packageName}-${version}${integrationName ? `-${integrationName}` : ''}`; diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_pagination.tsx b/x-pack/plugins/fleet/public/hooks/use_pagination.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_pagination.tsx rename to x-pack/plugins/fleet/public/hooks/use_pagination.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/agent_policy.ts b/x-pack/plugins/fleet/public/hooks/use_request/agent_policy.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/agent_policy.ts rename to x-pack/plugins/fleet/public/hooks/use_request/agent_policy.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/agents.ts b/x-pack/plugins/fleet/public/hooks/use_request/agents.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/agents.ts rename to x-pack/plugins/fleet/public/hooks/use_request/agents.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/app.ts b/x-pack/plugins/fleet/public/hooks/use_request/app.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/app.ts rename to x-pack/plugins/fleet/public/hooks/use_request/app.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/data_stream.ts b/x-pack/plugins/fleet/public/hooks/use_request/data_stream.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/data_stream.ts rename to x-pack/plugins/fleet/public/hooks/use_request/data_stream.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/enrollment_api_keys.ts b/x-pack/plugins/fleet/public/hooks/use_request/enrollment_api_keys.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/enrollment_api_keys.ts rename to x-pack/plugins/fleet/public/hooks/use_request/enrollment_api_keys.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/epm.ts b/x-pack/plugins/fleet/public/hooks/use_request/epm.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/epm.ts rename to x-pack/plugins/fleet/public/hooks/use_request/epm.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/index.ts b/x-pack/plugins/fleet/public/hooks/use_request/index.ts similarity index 88% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/index.ts rename to x-pack/plugins/fleet/public/hooks/use_request/index.ts index 23358e0397e11ac..2973d2dcd3fc8e2 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/index.ts +++ b/x-pack/plugins/fleet/public/hooks/use_request/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -export { setHttpClient, sendRequest, useRequest } from './use_request'; +export * from './use_request'; export * from './agent_policy'; export * from './package_policy'; export * from './data_stream'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/outputs.ts b/x-pack/plugins/fleet/public/hooks/use_request/outputs.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/outputs.ts rename to x-pack/plugins/fleet/public/hooks/use_request/outputs.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/package_policy.ts b/x-pack/plugins/fleet/public/hooks/use_request/package_policy.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/package_policy.ts rename to x-pack/plugins/fleet/public/hooks/use_request/package_policy.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/settings.ts b/x-pack/plugins/fleet/public/hooks/use_request/settings.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/settings.ts rename to x-pack/plugins/fleet/public/hooks/use_request/settings.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/setup.ts b/x-pack/plugins/fleet/public/hooks/use_request/setup.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/setup.ts rename to x-pack/plugins/fleet/public/hooks/use_request/setup.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/use_request.ts b/x-pack/plugins/fleet/public/hooks/use_request/use_request.ts similarity index 92% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/use_request.ts rename to x-pack/plugins/fleet/public/hooks/use_request/use_request.ts index b42c6e68fb499c4..138c291a7226e27 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_request/use_request.ts +++ b/x-pack/plugins/fleet/public/hooks/use_request/use_request.ts @@ -11,16 +11,16 @@ import type { HttpSetup } from 'src/core/public'; import { sendRequest as _sendRequest, useRequest as _useRequest, -} from '../../../../../../../../src/plugins/es_ui_shared/public'; +} from '../../../../../../src/plugins/es_ui_shared/public'; import type { SendRequestConfig, SendRequestResponse, UseRequestConfig, -} from '../../../../../../../../src/plugins/es_ui_shared/public'; +} from '../../../../../../src/plugins/es_ui_shared/public'; let httpClient: HttpSetup; -export type { UseRequestConfig } from '../../../../../../../../src/plugins/es_ui_shared/public'; +export type { UseRequestConfig } from '../../../../../../src/plugins/es_ui_shared/public'; /** * @internal diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_sorting.tsx b/x-pack/plugins/fleet/public/hooks/use_sorting.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_sorting.tsx rename to x-pack/plugins/fleet/public/hooks/use_sorting.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_ui_extension.ts b/x-pack/plugins/fleet/public/hooks/use_ui_extension.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_ui_extension.ts rename to x-pack/plugins/fleet/public/hooks/use_ui_extension.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_url_modal.ts b/x-pack/plugins/fleet/public/hooks/use_url_modal.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_url_modal.ts rename to x-pack/plugins/fleet/public/hooks/use_url_modal.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_url_pagination.ts b/x-pack/plugins/fleet/public/hooks/use_url_pagination.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_url_pagination.ts rename to x-pack/plugins/fleet/public/hooks/use_url_pagination.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_url_params.ts b/x-pack/plugins/fleet/public/hooks/use_url_params.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/hooks/use_url_params.ts rename to x-pack/plugins/fleet/public/hooks/use_url_params.ts diff --git a/x-pack/plugins/fleet/public/index.ts b/x-pack/plugins/fleet/public/index.ts index 0304b7b56181c89..f563f008dbeb604 100644 --- a/x-pack/plugins/fleet/public/index.ts +++ b/x-pack/plugins/fleet/public/index.ts @@ -15,9 +15,9 @@ export const plugin = (initializerContext: PluginInitializerContext) => { return new FleetPlugin(initializerContext); }; -export type { NewPackagePolicy } from './applications/fleet/types'; -export * from './applications/fleet/types/intra_app_route_state'; -export * from './applications/fleet/types/ui_extensions'; +export type { NewPackagePolicy } from './types'; +export * from './types/intra_app_route_state'; +export * from './types/ui_extensions'; -export { pagePathGetters } from './applications/fleet/constants'; -export { pkgKeyFromPackageInfo } from './applications/fleet/services/pkg_key_from_package_info'; +export { pagePathGetters } from './constants'; +export { pkgKeyFromPackageInfo } from './services'; diff --git a/x-pack/plugins/fleet/public/layouts/index.ts b/x-pack/plugins/fleet/public/layouts/index.ts new file mode 100644 index 000000000000000..e6e366654a866b1 --- /dev/null +++ b/x-pack/plugins/fleet/public/layouts/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { WithHeaderLayout, WithHeaderLayoutProps } from './with_header'; +export { WithoutHeaderLayout } from './without_header'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/layouts/with_header.tsx b/x-pack/plugins/fleet/public/layouts/with_header.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/layouts/with_header.tsx rename to x-pack/plugins/fleet/public/layouts/with_header.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/layouts/without_header.tsx b/x-pack/plugins/fleet/public/layouts/without_header.tsx similarity index 96% rename from x-pack/plugins/fleet/public/applications/fleet/layouts/without_header.tsx rename to x-pack/plugins/fleet/public/layouts/without_header.tsx index 38b6198e088c535..0ee1637e3013410 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/layouts/without_header.tsx +++ b/x-pack/plugins/fleet/public/layouts/without_header.tsx @@ -13,8 +13,7 @@ export const Page = styled(EuiPage)` background: ${(props) => props.theme.eui.euiColorEmptyShade}; width: 100%; align-self: center; - margin-left: 0; - margin-right: 0; + margin: auto; flex: 1; `; diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/create_test_renderer.tsx b/x-pack/plugins/fleet/public/mock/create_test_renderer.tsx similarity index 64% rename from x-pack/plugins/fleet/public/applications/fleet/mock/create_test_renderer.tsx rename to x-pack/plugins/fleet/public/mock/create_test_renderer.tsx index c1fa1422fa8aba0..71c9650709ee2cd 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/mock/create_test_renderer.tsx +++ b/x-pack/plugins/fleet/public/mock/create_test_renderer.tsx @@ -11,9 +11,10 @@ import React, { memo } from 'react'; import type { RenderOptions, RenderResult } from '@testing-library/react'; import { render as reactRender, act } from '@testing-library/react'; -import { ScopedHistory } from '../../../../../../../src/core/public'; -import { FleetAppContext } from '../app'; -import type { FleetConfigType } from '../../../plugin'; +import { ScopedHistory } from '../../../../../src/core/public'; +import { FleetAppContext } from '../applications/fleet/app'; +import { IntegrationsAppContext } from '../applications/integrations/app'; +import type { FleetConfigType } from '../plugin'; import type { UIExtensionsStorage } from '../types'; import { createConfigurationMock } from './plugin_configuration'; @@ -42,7 +43,7 @@ export interface TestRenderer { render: UiRender; } -export const createTestRendererMock = (): TestRenderer => { +export const createFleetTestRendererMock = (): TestRenderer => { const basePath = '/mock'; const extensions: UIExtensionsStorage = {}; const startServices = createStartServices(basePath); @@ -82,3 +83,44 @@ export const createTestRendererMock = (): TestRenderer => { return testRendererMocks; }; + +export const createIntegrationsTestRendererMock = (): TestRenderer => { + const basePath = '/mock'; + const extensions: UIExtensionsStorage = {}; + const startServices = createStartServices(basePath); + const testRendererMocks: TestRenderer = { + history: createHashHistory(), + mountHistory: new ScopedHistory(createMemoryHistory({ initialEntries: [basePath] }), basePath), + startServices, + config: createConfigurationMock(), + startInterface: createStartMock(extensions), + kibanaVersion: '8.0.0', + AppWrapper: memo(({ children }) => { + return ( + + {children} + + ); + }), + render: (ui, options) => { + let renderResponse: RenderResult; + act(() => { + renderResponse = reactRender(ui, { + wrapper: testRendererMocks.AppWrapper, + ...options, + }); + }); + return renderResponse!; + }, + }; + + return testRendererMocks; +}; diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/fleet_start_services.tsx b/x-pack/plugins/fleet/public/mock/fleet_start_services.tsx similarity index 89% rename from x-pack/plugins/fleet/public/applications/fleet/mock/fleet_start_services.tsx rename to x-pack/plugins/fleet/public/mock/fleet_start_services.tsx index ab75962c344df79..675eaaa1905eac2 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/mock/fleet_start_services.tsx +++ b/x-pack/plugins/fleet/public/mock/fleet_start_services.tsx @@ -9,9 +9,9 @@ import React from 'react'; import { I18nProvider } from '@kbn/i18n/react'; import type { MockedKeys } from '@kbn/utility-types/jest'; -import { coreMock } from '../../../../../../../src/core/public/mocks'; -import type { IStorage } from '../../../../../../../src/plugins/kibana_utils/public'; -import { Storage } from '../../../../../../../src/plugins/kibana_utils/public'; +import { coreMock } from '../../../../../src/core/public/mocks'; +import type { IStorage } from '../../../../../src/plugins/kibana_utils/public'; +import { Storage } from '../../../../../src/plugins/kibana_utils/public'; import { setHttpClient } from '../hooks/use_request'; import { createStartDepsMock } from './plugin_dependencies'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/index.ts b/x-pack/plugins/fleet/public/mock/index.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/mock/index.ts rename to x-pack/plugins/fleet/public/mock/index.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_configuration.ts b/x-pack/plugins/fleet/public/mock/plugin_configuration.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/mock/plugin_configuration.ts rename to x-pack/plugins/fleet/public/mock/plugin_configuration.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_dependencies.ts b/x-pack/plugins/fleet/public/mock/plugin_dependencies.ts similarity index 74% rename from x-pack/plugins/fleet/public/applications/fleet/mock/plugin_dependencies.ts rename to x-pack/plugins/fleet/public/mock/plugin_dependencies.ts index d7725830afb41c7..16fa34e2d0b3d74 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_dependencies.ts +++ b/x-pack/plugins/fleet/public/mock/plugin_dependencies.ts @@ -5,9 +5,9 @@ * 2.0. */ -import { dataPluginMock } from '../../../../../../../src/plugins/data/public/mocks'; -import { licensingMock } from '../../../../../licensing/public/mocks'; -import { homePluginMock } from '../../../../../../../src/plugins/home/public/mocks'; +import { dataPluginMock } from '../../../../../src/plugins/data/public/mocks'; +import { licensingMock } from '../../../licensing/public/mocks'; +import { homePluginMock } from '../../../../../src/plugins/home/public/mocks'; import type { MockedFleetSetupDeps, MockedFleetStartDeps } from './types'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/plugin_interfaces.ts b/x-pack/plugins/fleet/public/mock/plugin_interfaces.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/mock/plugin_interfaces.ts rename to x-pack/plugins/fleet/public/mock/plugin_interfaces.ts diff --git a/x-pack/plugins/fleet/public/applications/fleet/mock/types.ts b/x-pack/plugins/fleet/public/mock/types.ts similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/mock/types.ts rename to x-pack/plugins/fleet/public/mock/types.ts diff --git a/x-pack/plugins/fleet/public/plugin.ts b/x-pack/plugins/fleet/public/plugin.ts index f7951191f891466..f9515ca925a4aba 100644 --- a/x-pack/plugins/fleet/public/plugin.ts +++ b/x-pack/plugins/fleet/public/plugin.ts @@ -24,24 +24,21 @@ import type { HomePublicPluginSetup } from '../../../../src/plugins/home/public' import { Storage } from '../../../../src/plugins/kibana_utils/public'; import type { LicensingPluginSetup } from '../../licensing/public'; import type { CloudSetup } from '../../cloud/public'; -import { PLUGIN_ID, setupRouteService, appRoutesService } from '../common'; +import { PLUGIN_ID, INTEGRATIONS_PLUGIN_ID, setupRouteService, appRoutesService } from '../common'; import type { CheckPermissionsResponse, PostIngestSetupResponse } from '../common'; import type { FleetConfigType } from '../common/types'; -import { BASE_PATH } from './applications/fleet/constants'; -import { licenseService } from './applications/fleet/hooks/use_license'; -import { setHttpClient } from './applications/fleet/hooks/use_request/use_request'; +import { FLEET_BASE_PATH } from './constants'; +import { licenseService } from './hooks'; +import { setHttpClient } from './hooks/use_request'; import { TutorialDirectoryNotice, TutorialDirectoryHeaderLink, TutorialModuleNotice, -} from './applications/fleet/components/home_integration'; -import { createExtensionRegistrationCallback } from './applications/fleet/services/ui_extensions'; -import type { - UIExtensionRegistrationCallback, - UIExtensionsStorage, -} from './applications/fleet/types'; +} from './components/home_integration'; +import { createExtensionRegistrationCallback } from './services/ui_extensions'; +import type { UIExtensionRegistrationCallback, UIExtensionsStorage } from './types'; export { FleetConfigType } from '../common/types'; @@ -96,6 +93,36 @@ export class FleetPlugin implements Plugin { + const [coreStartServices, startDepsServices] = (await core.getStartServices()) as [ + CoreStart, + FleetStartDeps, + FleetStart + ]; + const startServices: FleetStartServices = { + ...coreStartServices, + ...startDepsServices, + storage: this.storage, + }; + const { renderApp, teardownIntegrations } = await import('./applications/integrations'); + const unmount = renderApp(startServices, params, config, kibanaVersion, extensions); + + return () => { + unmount(); + teardownIntegrations(startServices); + }; + }, + }); + // Register main Fleet app core.application.register({ id: PLUGIN_ID, @@ -156,7 +183,7 @@ export class FleetPlugin implements Plugin