-
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.
Showing
6 changed files
with
303 additions
and
6 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
.../public/management/pages/endpoint_hosts/view/details/components/endpoint_details_tabs.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,78 @@ | ||
/* | ||
* 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, { useCallback, useMemo, useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import { EuiTabbedContent, EuiTabbedContentTab } from '@elastic/eui'; | ||
|
||
export enum EndpointDetailsTabsTypes { | ||
overview = 'overview', | ||
activityLog = 'activity-log', | ||
} | ||
|
||
export type EndpointDetailsTabsId = | ||
| EndpointDetailsTabsTypes.overview | ||
| EndpointDetailsTabsTypes.activityLog; | ||
|
||
interface EndpointDetailsTabs { | ||
id: string; | ||
name: string; | ||
content: JSX.Element; | ||
} | ||
|
||
const StyledEuiTabbedContent = styled(EuiTabbedContent)` | ||
display: flex; | ||
flex: 1; | ||
flex-direction: column; | ||
overflow: hidden; | ||
> [role='tabpanel'] { | ||
padding: 12px 0; | ||
display: flex; | ||
flex: 1; | ||
flex-direction: column; | ||
overflow: hidden; | ||
overflow-y: auto; | ||
::-webkit-scrollbar { | ||
-webkit-appearance: none; | ||
width: 7px; | ||
} | ||
::-webkit-scrollbar-thumb { | ||
border-radius: 4px; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
-webkit-box-shadow: 0 0 1px rgba(255, 255, 255, 0.5); | ||
} | ||
} | ||
`; | ||
|
||
export const EndpointDetailsFlyoutTabs = ({ tabs }: { tabs: EndpointDetailsTabs[] }) => { | ||
const [selectedTabId, setSelectedTabId] = useState<EndpointDetailsTabsId>( | ||
EndpointDetailsTabsTypes.overview | ||
); | ||
|
||
const handleTabClick = useCallback( | ||
(tab: EuiTabbedContentTab) => setSelectedTabId(tab.id as EndpointDetailsTabsId), | ||
[setSelectedTabId] | ||
); | ||
|
||
const selectedTab = useMemo(() => tabs.find((tab) => tab.id === selectedTabId), [ | ||
tabs, | ||
selectedTabId, | ||
]); | ||
|
||
return ( | ||
<StyledEuiTabbedContent | ||
data-test-subj="endpointDetailsTabs" | ||
tabs={tabs} | ||
selectedTab={selectedTab} | ||
onTabClick={handleTabClick} | ||
key="endpoint-details-tabs" | ||
/> | ||
); | ||
}; | ||
|
||
EndpointDetailsFlyoutTabs.displayName = 'EndpointDetailsFlyoutTabs'; |
59 changes: 59 additions & 0 deletions
59
...olution/public/management/pages/endpoint_hosts/view/details/components/timeline_entry.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,59 @@ | ||
/* | ||
* 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 styled from 'styled-components'; | ||
|
||
import { EuiComment, EuiPanel, EuiSpacer, EuiText } from '@elastic/eui'; | ||
import { EndpointAction } from '../../../../../../../common/endpoint/types'; | ||
|
||
const TimelineItem = styled(EuiComment)` | ||
figure { | ||
border: 0; | ||
} | ||
figcaption.euiCommentEvent__header { | ||
background-color: transparent; | ||
border: 0; | ||
} | ||
`; | ||
|
||
const CommentItem = styled.div` | ||
max-width: 85%; | ||
> div { | ||
display: inline-flex; | ||
} | ||
`; | ||
|
||
export const TimelineEntry = ({ endpointAction }: { endpointAction: EndpointAction }) => { | ||
const isIsolated = endpointAction?.data.command === 'isolate'; | ||
const timelineIcon = isIsolated ? 'lock' : 'lockOpen'; | ||
const event = `${isIsolated ? 'isolated' : 'unisolated'} the endpoint`; | ||
const hasComment = !!endpointAction.data.comment; | ||
return ( | ||
<TimelineItem | ||
type="regular" | ||
username={endpointAction.user_id} | ||
event={event} | ||
timelineIcon={timelineIcon} | ||
data-test-subj="timelineEntry" | ||
> | ||
<EuiText size="s">{endpointAction['@timestamp']}</EuiText> | ||
<EuiSpacer size="m" /> | ||
{hasComment ? ( | ||
<CommentItem> | ||
<EuiPanel hasBorder={true} paddingSize="s"> | ||
<EuiText size="s"> | ||
<p>{endpointAction.data.comment}</p> | ||
</EuiText> | ||
</EuiPanel> | ||
</CommentItem> | ||
) : undefined} | ||
</TimelineItem> | ||
); | ||
}; | ||
|
||
TimelineEntry.displayName = 'TimelineEntry'; |
24 changes: 24 additions & 0 deletions
24
...ty_solution/public/management/pages/endpoint_hosts/view/details/endpoint_activity_log.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,24 @@ | ||
/* | ||
* 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 { EuiFieldSearch, EuiSpacer } from '@elastic/eui'; | ||
import { TimelineEntry } from './components/timeline_entry'; | ||
import { EndpointAction } from '../../../../../../common/endpoint/types'; | ||
|
||
export const EndpointActivityLog = ({ endpointActions }: { endpointActions: EndpointAction[] }) => ( | ||
<> | ||
<EuiFieldSearch compressed fullWidth placeholder="Search activity log" /> | ||
<EuiSpacer size="l" /> | ||
{endpointActions.map((endpointAction) => ( | ||
<TimelineEntry key={endpointAction['@timestamp']} endpointAction={endpointAction} /> | ||
))} | ||
</> | ||
); | ||
|
||
EndpointActivityLog.displayName = 'EndpointActivityLog'; |
46 changes: 46 additions & 0 deletions
46
...curity_solution/public/management/pages/endpoint_hosts/view/details/endpoints.stories.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,46 @@ | ||
/* | ||
* 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, { ComponentType } from 'react'; | ||
|
||
import { EndpointDetailsFlyoutTabs } from './components/endpoint_details_tabs'; | ||
import { EndpointActivityLog } from './endpoint_activity_log'; | ||
import { EndpointDetailsFlyout } from '.'; | ||
import { EuiThemeProvider } from '../../../../../../../../../src/plugins/kibana_react/common'; | ||
|
||
import { dummyEndpointActions } from './'; | ||
|
||
export default { | ||
title: 'Endpoints/Endpoint Details', | ||
component: EndpointDetailsFlyout, | ||
decorators: [ | ||
(Story: ComponentType) => ( | ||
<EuiThemeProvider> | ||
<Story /> | ||
</EuiThemeProvider> | ||
), | ||
], | ||
}; | ||
|
||
export const Tabs = () => ( | ||
<EndpointDetailsFlyoutTabs | ||
tabs={[ | ||
{ | ||
id: 'overview', | ||
name: 'Overview', | ||
content: <>{'Endpoint Details'}</>, | ||
}, | ||
{ | ||
id: 'activity-log', | ||
name: 'Activity Log', | ||
content: ActivityLog(), | ||
}, | ||
]} | ||
/> | ||
); | ||
|
||
export const ActivityLog = () => <EndpointActivityLog endpointActions={dummyEndpointActions} />; |
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
16 changes: 16 additions & 0 deletions
16
x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/translations.ts
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,16 @@ | ||
/* | ||
* 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'; | ||
|
||
export const OVERVIEW = i18n.translate('xpack.securitySolution.endpointDetails.overview', { | ||
defaultMessage: 'Overview', | ||
}); | ||
|
||
export const ACTIVITY_LOG = i18n.translate('xpack.securitySolution.endpointDetails.activityLog', { | ||
defaultMessage: 'Activity Log', | ||
}); |