-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security_Solution][Endpoint] Register Custom tab into Fleet Endpoint…
… Integration Detail (#85643) * Fleet: add component props to the Package Custom UI extension * Endpoint: Register UI Extension with fleet for endpoint custom content * Endpoint: UI for Trusted Apps custom entry
- Loading branch information
1 parent
504c873
commit f6cd264
Showing
17 changed files
with
367 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...ager_integration/endpoint_package_custom_extension/components/fleet_trusted_apps_card.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { memo, useMemo } from 'react'; | ||
import { ApplicationStart } from 'kibana/public'; | ||
import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiText } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { | ||
PackageCustomExtensionComponentProps, | ||
pagePathGetters, | ||
} from '../../../../../../../../../fleet/public'; | ||
import { useKibana } from '../../../../../../../../../../../src/plugins/kibana_react/public'; | ||
import { getTrustedAppsListPath } from '../../../../../../common/routing'; | ||
import { TrustedAppsListPageRouteState } from '../../../../../../../../common/endpoint/types'; | ||
import { PLUGIN_ID as FLEET_PLUGIN_ID } from '../../../../../../../../../fleet/common'; | ||
import { MANAGEMENT_APP_ID } from '../../../../../../common/constants'; | ||
import { LinkWithIcon } from './link_with_icon'; | ||
import { TrustedAppItemsSummary } from './trusted_app_items_summary'; | ||
|
||
export const FleetTrustedAppsCard = memo<PackageCustomExtensionComponentProps>(({ pkgkey }) => { | ||
const { | ||
services: { | ||
application: { getUrlForApp }, | ||
}, | ||
} = useKibana<{ application: ApplicationStart }>(); | ||
|
||
const trustedAppsListUrlPath = getTrustedAppsListPath(); | ||
|
||
const trustedAppRouteState = useMemo<TrustedAppsListPageRouteState>(() => { | ||
const fleetPackageCustomUrlPath = `#${pagePathGetters.integration_details({ | ||
pkgkey, | ||
panel: 'custom', | ||
})}`; | ||
return { | ||
backButtonLabel: i18n.translate( | ||
'xpack.securitySolution.endpoint.fleetCustomExtension.backButtonLabel', | ||
{ defaultMessage: 'Back to Endpoint Integration' } | ||
), | ||
onBackButtonNavigateTo: [ | ||
FLEET_PLUGIN_ID, | ||
{ | ||
path: fleetPackageCustomUrlPath, | ||
}, | ||
], | ||
backButtonUrl: getUrlForApp(FLEET_PLUGIN_ID, { | ||
path: fleetPackageCustomUrlPath, | ||
}), | ||
}; | ||
}, [getUrlForApp, pkgkey]); | ||
|
||
return ( | ||
<EuiPanel paddingSize="l"> | ||
<EuiFlexGroup alignItems="baseline"> | ||
<EuiFlexItem> | ||
<EuiText> | ||
<h4> | ||
<FormattedMessage | ||
id="xpack.securitySolution.endpoint.fleetCustomExtension.trustedAppsLabel" | ||
defaultMessage="Trusted Applications" | ||
/> | ||
</h4> | ||
</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<TrustedAppItemsSummary /> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<span> | ||
<LinkWithIcon | ||
appId={MANAGEMENT_APP_ID} | ||
href={getUrlForApp(MANAGEMENT_APP_ID, { path: trustedAppsListUrlPath })} | ||
appPath={trustedAppsListUrlPath} | ||
appState={trustedAppRouteState} | ||
data-test-subj="linkToTrustedApps" | ||
> | ||
<FormattedMessage | ||
id="xpack.securitySolution.endpoint.fleetCustomExtension.manageTrustedAppLinkLabel" | ||
defaultMessage="Manage trusted applications" | ||
/> | ||
</LinkWithIcon> | ||
</span> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiPanel> | ||
); | ||
}); | ||
|
||
FleetTrustedAppsCard.displayName = 'FleetTrustedAppsCard'; |
29 changes: 29 additions & 0 deletions
29
...ngest_manager_integration/endpoint_package_custom_extension/components/link_with_icon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import styled from 'styled-components'; | ||
import React, { FC, memo } from 'react'; | ||
import { EuiIcon } from '@elastic/eui'; | ||
import { | ||
LinkToApp, | ||
LinkToAppProps, | ||
} from '../../../../../../../common/components/endpoint/link_to_app'; | ||
|
||
const LinkLabel = styled.span` | ||
display: inline-block; | ||
padding-right: ${(props) => props.theme.eui.paddingSizes.s}; | ||
`; | ||
|
||
export const LinkWithIcon: FC<LinkToAppProps> = memo(({ children, ...props }) => { | ||
return ( | ||
<LinkToApp {...props}> | ||
<LinkLabel>{children}</LinkLabel> | ||
<EuiIcon type="popout" /> | ||
</LinkToApp> | ||
); | ||
}); | ||
|
||
LinkWithIcon.displayName = 'LinkWithIcon'; |
68 changes: 68 additions & 0 deletions
68
...er_integration/endpoint_package_custom_extension/components/trusted_app_items_summary.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { EuiBadge, EuiBadgeProps, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui'; | ||
import React, { FC, memo, useEffect, useState } from 'react'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { CoreStart } from 'kibana/public'; | ||
import { useKibana } from '../../../../../../../../../../../src/plugins/kibana_react/public'; | ||
import { TrustedAppsHttpService } from '../../../../../trusted_apps/service'; | ||
|
||
export const TrustedAppItemsSummary = memo(() => { | ||
const { | ||
services: { http }, | ||
} = useKibana<CoreStart>(); | ||
const [total, setTotal] = useState<number>(0); | ||
const [trustedAppsApi] = useState(() => new TrustedAppsHttpService(http)); | ||
|
||
useEffect(() => { | ||
trustedAppsApi | ||
.getTrustedAppsList({ | ||
page: 1, | ||
per_page: 1, | ||
}) | ||
.then((response) => { | ||
setTotal(response.total); | ||
}); | ||
}, [trustedAppsApi]); | ||
|
||
return ( | ||
<div> | ||
<SummaryStat value={total} color="primary"> | ||
<FormattedMessage | ||
id="xpack.securitySolution.endpoint.fleetCustomExtension.trustedAppItemsSummary.totalLabel" | ||
defaultMessage="Total" | ||
/> | ||
</SummaryStat> | ||
</div> | ||
); | ||
}); | ||
|
||
TrustedAppItemsSummary.displayName = 'TrustedAppItemsSummary'; | ||
|
||
const SummaryStat: FC<{ value: number; color?: EuiBadgeProps['color'] }> = memo( | ||
({ children, value, color, ...commonProps }) => { | ||
return ( | ||
<EuiText className="eui-displayInlineBlock" size="s"> | ||
<EuiFlexGroup | ||
responsive={false} | ||
justifyContent="center" | ||
direction="row" | ||
alignItems="center" | ||
> | ||
<EuiFlexItem grow={false} style={{ fontWeight: 'bold' }}> | ||
{children} | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiBadge color={color}>{value}</EuiBadge> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiText> | ||
); | ||
} | ||
); | ||
|
||
SummaryStat.displayName = 'SummaryState'; |
21 changes: 21 additions & 0 deletions
21
.../pages/policy/view/ingest_manager_integration/endpoint_package_custom_extension/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { memo } from 'react'; | ||
import { PackageCustomExtensionComponentProps } from '../../../../../../../../fleet/public'; | ||
import { FleetTrustedAppsCard } from './components/fleet_trusted_apps_card'; | ||
|
||
export const EndpointPackageCustomExtension = memo<PackageCustomExtensionComponentProps>( | ||
(props) => { | ||
return ( | ||
<div data-test-subj="fleetEndpointPackageCustomContent"> | ||
<FleetTrustedAppsCard {...props} /> | ||
</div> | ||
); | ||
} | ||
); | ||
|
||
EndpointPackageCustomExtension.displayName = 'EndpointPackageCustomExtension'; |
Oops, something went wrong.