forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
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] Adds Endpoint Host Isolation Status com…
…mon component (elastic#101782) * Common component for displaying Endpoint Host Isolation status
- Loading branch information
1 parent
21e8af0
commit 4e0c889
Showing
3 changed files
with
75 additions
and
0 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
73 changes: 73 additions & 0 deletions
73
...ution/public/common/components/endpoint/host_isolation/endpoint_host_isolation_status.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,73 @@ | ||
/* | ||
* 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, useMemo } from 'react'; | ||
import { EuiBadge, EuiTextColor } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
export interface EndpointHostIsolationStatusProps { | ||
isIsolated: boolean; | ||
/** the count of pending isolate actions */ | ||
pendingIsolate?: number; | ||
/** the count of pending unisoalte actions */ | ||
pendingUnIsolate?: number; | ||
} | ||
|
||
/** | ||
* Component will display a host isoaltion status based on whether it is currently isolated or there are | ||
* isolate/unisolate actions pending. If none of these are applicable, no UI component will be rendered | ||
* (`null` is returned) | ||
*/ | ||
export const EndpointHostIsolationStatus = memo<EndpointHostIsolationStatusProps>( | ||
({ isIsolated, pendingIsolate = 0, pendingUnIsolate = 0 }) => { | ||
return useMemo(() => { | ||
// If nothing is pending and host is not currently isolated, then render nothing | ||
if (!isIsolated && !pendingIsolate && !pendingUnIsolate) { | ||
return null; | ||
} | ||
|
||
// If nothing is pending, but host is isolated, then show isolation badge | ||
if (!pendingIsolate && !pendingUnIsolate) { | ||
return ( | ||
<EuiBadge color="hollow"> | ||
<FormattedMessage | ||
id="xpack.securitySolution.endpoint.hostIsolationStatus.isolated" | ||
defaultMessage="Isolated" | ||
/> | ||
</EuiBadge> | ||
); | ||
} | ||
|
||
// If there are multiple types of pending isolation actions, then show count of actions with tooltip that displays breakdown | ||
// TODO:PT implement edge case | ||
// if () { | ||
// | ||
// } | ||
|
||
// Show 'pending [un]isolate' depending on what's pending | ||
return ( | ||
<EuiBadge color="hollow"> | ||
<EuiTextColor color="subdued"> | ||
{pendingIsolate ? ( | ||
<FormattedMessage | ||
id="xpack.securitySolution.endpoint.hostIsolationStatus.isIsolating" | ||
defaultMessage="Isolating pending" | ||
/> | ||
) : ( | ||
<FormattedMessage | ||
id="xpack.securitySolution.endpoint.hostIsolationStatus.isUnIsolating" | ||
defaultMessage="Unisolating pending" | ||
/> | ||
)} | ||
</EuiTextColor> | ||
</EuiBadge> | ||
); | ||
}, [isIsolated, pendingIsolate, pendingUnIsolate]); | ||
} | ||
); | ||
|
||
EndpointHostIsolationStatus.displayName = 'EndpointHostIsolationStatus'; |
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