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][Flyout] - fix analyzer preview loading and update…
… hover actions in rule preview (elastic#175282) ## Summary - Fixed a bug introduced by elastic#174651: analyzer preview is stuck in loading state because `_id` is not in the index for a preview alert. Added back `kibana.alert.ancestor.id` when flyout is open in alert preview. - Refactor the use of security hover actions in flyout. The hover action wrapper checks the type of document/scope (whether it is an alert, or in a preview) to determine what actions to show on hover. Most hover actions should behave consistently when flyout is in rule preview (do not show filter options) - Related: elastic#173608 - Not included in this pr: 1) hover actions in alert reason preview, 2) hover actions in left panel entity details as the component is owned by a different team and required greater refactor effort - Fixed a UI bug on assignees breaking into multiple lines ![image](https://github.com/elastic/kibana/assets/18648970/96d909e3-b6bd-4a46-bc86-fbb473ce3b62) ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- Loading branch information
1 parent
8908d1c
commit 821f531
Showing
22 changed files
with
386 additions
and
183 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
...plugins/security_solution/public/flyout/document_details/left/components/cell_actions.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,72 @@ | ||
/* | ||
* 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 { useLeftPanelContext } from '../context'; | ||
import { getSourcererScopeId } from '../../../../helpers'; | ||
import { useBasicDataFromDetailsData } from '../../../../timelines/components/side_panel/event_details/helpers'; | ||
import { SecurityCellActionType } from '../../../../actions/constants'; | ||
import { | ||
CellActionsMode, | ||
SecurityCellActions, | ||
SecurityCellActionsTrigger, | ||
} from '../../../../common/components/cell_actions'; | ||
|
||
interface CellActionsProps { | ||
/** | ||
* Field name | ||
*/ | ||
field: string; | ||
/** | ||
* Field value | ||
*/ | ||
value: string[] | string | null | undefined; | ||
/** | ||
* Boolean to indicate if value is an object array | ||
*/ | ||
isObjectArray?: boolean; | ||
/** | ||
* React components to render | ||
*/ | ||
children: React.ReactNode | string; | ||
} | ||
|
||
/** | ||
* Security cell action wrapper for document details flyout | ||
*/ | ||
export const CellActions: FC<CellActionsProps> = ({ field, value, isObjectArray, children }) => { | ||
const { dataFormattedForFieldBrowser, scopeId, isPreview } = useLeftPanelContext(); | ||
const { isAlert } = useBasicDataFromDetailsData(dataFormattedForFieldBrowser); | ||
|
||
const triggerId = isAlert | ||
? SecurityCellActionsTrigger.DETAILS_FLYOUT | ||
: SecurityCellActionsTrigger.DEFAULT; | ||
|
||
const data = useMemo(() => ({ field, value }), [field, value]); | ||
const metadata = useMemo(() => ({ scopeId, isObjectArray }), [scopeId, isObjectArray]); | ||
const disabledActionTypes = useMemo( | ||
() => (isPreview ? [SecurityCellActionType.FILTER, SecurityCellActionType.TOGGLE_COLUMN] : []), | ||
[isPreview] | ||
); | ||
|
||
return ( | ||
<SecurityCellActions | ||
data={data} | ||
mode={CellActionsMode.HOVER_RIGHT} | ||
triggerId={triggerId} | ||
visibleCellActions={6} | ||
sourcererScopeId={getSourcererScopeId(scopeId)} | ||
metadata={metadata} | ||
disabledActionTypes={disabledActionTypes} | ||
> | ||
{children} | ||
</SecurityCellActions> | ||
); | ||
}; | ||
|
||
CellActions.displayName = 'CellActions'; |
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
Oops, something went wrong.