-
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.
- Loading branch information
1 parent
2e004f8
commit 4069ba9
Showing
32 changed files
with
872 additions
and
175 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
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
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/security_solution/public/flyout/document_details/session_view/content.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,37 @@ | ||
/* | ||
* 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 { FC } from 'react'; | ||
import React, { useMemo } from 'react'; | ||
import type { SessionViewPanelPaths } from '.'; | ||
import type { SessionViewPanelTabType } from './tabs'; | ||
import { FlyoutBody } from '../../shared/components/flyout_body'; | ||
|
||
export interface PanelContentProps { | ||
/** | ||
* Id of the tab selected in the parent component to display its content | ||
*/ | ||
selectedTabId: SessionViewPanelPaths; | ||
/** | ||
* Tabs display right below the flyout's header | ||
*/ | ||
tabs: SessionViewPanelTabType[]; | ||
} | ||
|
||
/** | ||
* Document details expandable flyout right section, that will display the content | ||
* of the overview, table and json tabs. | ||
*/ | ||
export const PanelContent: FC<PanelContentProps> = ({ selectedTabId, tabs }) => { | ||
const selectedTabContent = useMemo(() => { | ||
return tabs.find((tab) => tab.id === selectedTabId)?.content; | ||
}, [selectedTabId, tabs]); | ||
|
||
return <FlyoutBody>{selectedTabContent}</FlyoutBody>; | ||
}; | ||
|
||
PanelContent.displayName = 'PanelContent'; |
96 changes: 96 additions & 0 deletions
96
x-pack/plugins/security_solution/public/flyout/document_details/session_view/context.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,96 @@ | ||
/* | ||
* 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, { createContext, memo, useContext, useMemo } from 'react'; | ||
import type { Process } from '@kbn/session-view-plugin/common'; | ||
import { FlyoutError } from '../../shared/components/flyout_error'; | ||
import type { SessionViewPanelProps } from '.'; | ||
|
||
export interface SessionViewPanelContext { | ||
selectedProcess: Process | null; | ||
index: string; | ||
sessionEntityId: string; | ||
sessionStartTime: string; | ||
scopeId: string; | ||
investigatedAlertId: string; | ||
} | ||
|
||
export const SessionViewPanelContext = createContext<SessionViewPanelContext | undefined>( | ||
undefined | ||
); | ||
|
||
export type SessionViewPanelProviderProps = { | ||
/** | ||
* React components to render | ||
*/ | ||
children: React.ReactNode; | ||
} & Partial<SessionViewPanelProps['params']>; | ||
|
||
export const SessionViewPanelProvider = memo( | ||
({ | ||
selectedProcess, | ||
index, | ||
sessionEntityId, | ||
sessionStartTime, | ||
scopeId, | ||
investigatedAlertId, | ||
children, | ||
}: SessionViewPanelProviderProps) => { | ||
console.group('SessionViewPanelProvider'); | ||
console.log('selectedProcess', selectedProcess); | ||
console.log('index', index); | ||
console.log('sessionEntityId', sessionEntityId); | ||
console.log('sessionStartTime', sessionStartTime); | ||
console.log('scopeId', scopeId); | ||
console.log('investigatedAlertId', investigatedAlertId); | ||
console.groupEnd(); | ||
|
||
const contextValue = useMemo( | ||
() => | ||
selectedProcess && | ||
index && | ||
sessionEntityId && | ||
sessionStartTime && | ||
scopeId && | ||
investigatedAlertId | ||
? { | ||
selectedProcess, | ||
index, | ||
sessionEntityId, | ||
sessionStartTime, | ||
scopeId, | ||
investigatedAlertId, | ||
} | ||
: undefined, | ||
[selectedProcess, index, sessionEntityId, sessionStartTime, scopeId] | ||
); | ||
|
||
if (!contextValue) { | ||
return <FlyoutError />; | ||
} | ||
|
||
return ( | ||
<SessionViewPanelContext.Provider value={contextValue}> | ||
{children} | ||
</SessionViewPanelContext.Provider> | ||
); | ||
} | ||
); | ||
|
||
SessionViewPanelProvider.displayName = 'SessionViewPanelProvider'; | ||
|
||
export const useSessionViewPanelContext = (): SessionViewPanelContext => { | ||
const contextValue = useContext(SessionViewPanelContext); | ||
|
||
if (!contextValue) { | ||
throw new Error( | ||
'SessionViewPanelContext can only be used within SessionViewPanelContext provider' | ||
); | ||
} | ||
|
||
return contextValue; | ||
}; |
56 changes: 56 additions & 0 deletions
56
x-pack/plugins/security_solution/public/flyout/document_details/session_view/header.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,56 @@ | ||
/* | ||
* 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 { EuiFlyoutHeader } from '@elastic/eui'; | ||
import { EuiTab } from '@elastic/eui'; | ||
import type { FC } from 'react'; | ||
import React, { memo } from 'react'; | ||
import type { SessionViewPanelTabType } from './tabs'; | ||
import type { SessionViewPanelPaths } from '.'; | ||
import { FlyoutHeader } from '../../shared/components/flyout_header'; | ||
import { FlyoutHeaderTabs } from '../../shared/components/flyout_header_tabs'; | ||
|
||
export interface PanelHeaderProps extends React.ComponentProps<typeof EuiFlyoutHeader> { | ||
/** | ||
* Id of the tab selected in the parent component to display its content | ||
*/ | ||
selectedTabId: SessionViewPanelPaths; | ||
/** | ||
* Callback to set the selected tab id in the parent component | ||
* @param selected | ||
*/ | ||
setSelectedTabId: (selected: SessionViewPanelPaths) => void; | ||
/** | ||
* Tabs to display in the header | ||
*/ | ||
tabs: SessionViewPanelTabType[]; | ||
} | ||
|
||
export const PanelHeader: FC<PanelHeaderProps> = memo( | ||
({ selectedTabId, setSelectedTabId, tabs, ...flyoutHeaderProps }) => { | ||
const onSelectedTabChanged = (id: SessionViewPanelPaths) => setSelectedTabId(id); | ||
|
||
const renderTabs = tabs.map((tab, index) => ( | ||
<EuiTab | ||
onClick={() => onSelectedTabChanged(tab.id)} | ||
isSelected={tab.id === selectedTabId} | ||
key={index} | ||
data-test-subj={tab['data-test-subj']} | ||
> | ||
{tab.name} | ||
</EuiTab> | ||
)); | ||
|
||
return ( | ||
<FlyoutHeader {...flyoutHeaderProps}> | ||
<FlyoutHeaderTabs>{renderTabs}</FlyoutHeaderTabs> | ||
</FlyoutHeader> | ||
); | ||
} | ||
); | ||
|
||
PanelHeader.displayName = 'PanelHeader'; |
Oops, something went wrong.