diff --git a/x-pack/plugins/fleet/common/types/models/epm.ts b/x-pack/plugins/fleet/common/types/models/epm.ts index ffcc8361c1235..b2742b0d36886 100644 --- a/x-pack/plugins/fleet/common/types/models/epm.ts +++ b/x-pack/plugins/fleet/common/types/models/epm.ts @@ -48,7 +48,13 @@ export type InstallSource = 'registry' | 'upload' | 'bundled'; export type EpmPackageInstallStatus = 'installed' | 'installing' | 'install_failed'; -export type DetailViewPanelName = 'overview' | 'policies' | 'assets' | 'settings' | 'custom'; +export type DetailViewPanelName = + | 'overview' + | 'policies' + | 'assets' + | 'settings' + | 'custom' + | 'api-reference'; export type ServiceName = 'kibana' | 'elasticsearch'; export type AgentAssetType = typeof agentAssetTypes; export type DocAssetType = 'doc' | 'notice'; diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/documentation/index.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/documentation/index.tsx new file mode 100644 index 0000000000000..d90067d3f591d --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/documentation/index.tsx @@ -0,0 +1,270 @@ +/* + * 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, { useMemo } from 'react'; +import { + EuiAccordion, + EuiBasicTable, + EuiCode, + EuiFlexGroup, + EuiFlexItem, + EuiTitle, + EuiSpacer, + EuiText, + EuiLink, + EuiBetaBadge, +} from '@elastic/eui'; +import type { EuiInMemoryTableProps } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n-react'; + +import type { + PackageInfo, + RegistryVarsEntry, + RegistryStream, + RegistryInput, +} from '../../../../../types'; +import { useStartServices } from '../../../../../../../hooks'; +import { getStreamsForInputType } from '../../../../../../../../common/services'; + +interface Props { + packageInfo: PackageInfo; + integration?: string | null; +} + +export const DocumentationPage: React.FunctionComponent = ({ packageInfo, integration }) => { + const { docLinks } = useStartServices(); + + const content = ( + <> + + + + + + + ), + }} + /> + + + + + + + + + + + + + ); + + return ( + + + {content} + + ); +}; + +type RegistryInputWithStreams = RegistryInput & { + key: string; + streams: Array; +}; + +const Inputs: React.FunctionComponent<{ + packageInfo: PackageInfo; + integration?: string | null; +}> = ({ packageInfo, integration }) => { + const inputs = useMemo( + () => + packageInfo.policy_templates?.reduce((acc, policyTemplate) => { + if (integration && policyTemplate.name !== integration) { + return acc; + } + if ('inputs' in policyTemplate && policyTemplate.inputs) { + return [ + ...acc, + ...policyTemplate.inputs.map((input) => ({ + key: `${policyTemplate.name}-${input.type}`, + ...input, + streams: getStreamsForInputType(input.type, packageInfo, []), + })), + ]; + } + return acc; + }, [] as RegistryInputWithStreams[]), + [packageInfo, integration] + ); + return ( + <> + + +

+ +

+
+ + {inputs?.map((input) => { + return ( + + {input.key}({input.title}) + + } + initialIsOpen={false} + paddingSize={'m'} + > + {input.description} + {input.vars ? ( + <> + + + + ) : null} + + +
+ +
+
+ + {input.streams.map((dataStream) => ( + + {dataStream.data_stream.dataset}({dataStream.title}) + + } + initialIsOpen={false} + paddingSize={'m'} + > + {dataStream.description} + {dataStream.vars ? ( + <> + + + + ) : null} + + ))} +
+ ); + }) ?? null} + + ); +}; + +const PackageVars: React.FunctionComponent<{ vars: PackageInfo['vars'] }> = ({ vars }) => { + if (!vars) { + return null; + } + + return ( + <> + +

+ +

+
+ + + + + ); +}; + +const VarsTable: React.FunctionComponent<{ vars: RegistryVarsEntry[] }> = ({ vars }) => { + const columns = useMemo((): EuiInMemoryTableProps['columns'] => { + return [ + { + field: 'name', + name: ( + + ), + render: (name: string) => {name}, + }, + { + field: 'title', + name: ( + + ), + }, + { + field: 'type', + name: ( + + ), + }, + { + field: 'required', + width: '70px', + name: ( + + ), + }, + { + field: 'multi', + width: '70px', + name: ( + + ), + }, + ]; + }, []); + + return ( + <> + +
+ +
+
+ + + ); +}; diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx index dfe1c6001cede..c55adfe4768d1 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx @@ -59,6 +59,7 @@ import { OverviewPage } from './overview'; import { PackagePoliciesPage } from './policies'; import { SettingsPage } from './settings'; import { CustomViewPage } from './custom'; +import { DocumentationPage } from './documentation'; import './index.scss'; @@ -489,6 +490,22 @@ export function Detail() { }); } + tabs.push({ + id: 'api-reference', + name: ( + + ), + isSelected: panel === 'api-reference', + 'data-test-subj': `tab-api-reference`, + href: getHref('integration_details_api_reference', { + pkgkey: packageInfoKey, + ...(integration ? { integration } : {}), + }), + }); + return tabs; }, [ packageInfo, @@ -575,6 +592,9 @@ export function Detail() { + + + )} diff --git a/x-pack/plugins/fleet/public/constants/page_paths.ts b/x-pack/plugins/fleet/public/constants/page_paths.ts index 479110f2f0142..d24496603f32d 100644 --- a/x-pack/plugins/fleet/public/constants/page_paths.ts +++ b/x-pack/plugins/fleet/public/constants/page_paths.ts @@ -30,6 +30,7 @@ export type DynamicPage = | 'integration_details_assets' | 'integration_details_settings' | 'integration_details_custom' + | 'integration_details_api_reference' | 'integration_policy_edit' | 'integration_policy_upgrade' | 'policy_details' @@ -90,6 +91,7 @@ export const INTEGRATIONS_ROUTING_PATHS = { integration_details_assets: '/detail/:pkgkey/assets', integration_details_settings: '/detail/:pkgkey/settings', integration_details_custom: '/detail/:pkgkey/custom', + integration_details_api_reference: '/detail/:pkgkey/api-reference', integration_policy_edit: '/edit-integration/:packagePolicyId', integration_policy_upgrade: '/edit-integration/:packagePolicyId', }; @@ -143,6 +145,10 @@ export const pagePathGetters: { INTEGRATIONS_BASE_PATH, `/detail/${pkgkey}/custom${integration ? `?integration=${integration}` : ''}`, ], + integration_details_api_reference: ({ pkgkey, integration }) => [ + INTEGRATIONS_BASE_PATH, + `/detail/${pkgkey}/api-reference${integration ? `?integration=${integration}` : ''}`, + ], integration_policy_edit: ({ packagePolicyId }) => [ INTEGRATIONS_BASE_PATH, `/edit-integration/${packagePolicyId}`,