-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Security solutions][Intelligence] Upgrade ioc flyout #230593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NicholasPeretti
merged 27 commits into
elastic:main
from
NicholasPeretti:189870-convert-ioc-flyout
Sep 23, 2025
Merged
Changes from 12 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
178b865
Compress highlights table
NicholasPeretti d2fc70f
Improve flyout table
NicholasPeretti c2bce15
Update json view
NicholasPeretti 25e0b66
[CI] Auto-commit changed files from 'node scripts/eslint_all_files --…
kibanamachine 968acdf
Move options from useMemo to module's scope
NicholasPeretti 68849ff
Remove IndicatorValueActions
NicholasPeretti 0e4b7d7
Refactor JsonTab to be reusable
NicholasPeretti 504ed3f
Merge branch 'main' into 189870-convert-ioc-flyout
NicholasPeretti 57c0bca
Merge branch 'main' into 189870-convert-ioc-flyout
NicholasPeretti 18fef14
Apply PR feedback
NicholasPeretti 20e3102
Apply PR feedback
NicholasPeretti 7d4816c
Merge branch 'main' into 189870-convert-ioc-flyout
NicholasPeretti e0e0a4f
Applh PR feedback
NicholasPeretti 4e673df
Merge branch 'main' into 189870-convert-ioc-flyout
NicholasPeretti 0cd76a9
Merge branch 'main' into 189870-convert-ioc-flyout
NicholasPeretti ff711a5
Fix translations
NicholasPeretti 56cd64f
Merge branch 'main' into 189870-convert-ioc-flyout
NicholasPeretti 22e7f2f
Fix unit tests
NicholasPeretti d6f51e4
Fix cypress tests
NicholasPeretti e819899
Merge branch 'main' into 189870-convert-ioc-flyout
NicholasPeretti 204cfde
Fix cypress tests
NicholasPeretti 279cb0a
Merge branch 'main' into 189870-convert-ioc-flyout
NicholasPeretti 2093bba
Fix CI
NicholasPeretti d51f056
Fix Cypress tests
NicholasPeretti fcccfc9
Merge branch 'main' into 189870-convert-ioc-flyout
NicholasPeretti e114a5d
Merge branch 'main' into 189870-convert-ioc-flyout
NicholasPeretti a9d27f4
Merge branch 'main' into 189870-convert-ioc-flyout
NicholasPeretti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
110 changes: 110 additions & 0 deletions
110
...solutions/security/plugins/security_solution/public/flyout/shared/components/json_tab.tsx
This file contains hidden or 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,110 @@ | ||
| /* | ||
| * 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, useEffect, useRef, useState } from 'react'; | ||
| import { JsonCodeEditor } from '@kbn/unified-doc-viewer-plugin/public'; | ||
| import { EuiButtonEmpty, EuiCopy, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { FormattedMessage } from '@kbn/i18n-react'; | ||
|
|
||
| import { PREFIX } from '../test_ids'; | ||
|
|
||
| export const JSON_TAB_CONTENT_TEST_ID = 'jsonView' as const; | ||
| export const JSON_TAB_COPY_TO_CLIPBOARD_BUTTON_TEST_ID = `${PREFIX}JsonTabCopyToClipboard` as const; | ||
|
|
||
| // import { useDocumentDetailsContext } from './context'; | ||
|
|
||
| const FLYOUT_BODY_PADDING = 24; | ||
| const COPY_TO_CLIPBOARD_BUTTON_HEIGHT = 24; | ||
| const FLYOUT_FOOTER_HEIGHT = 72; | ||
|
|
||
| export interface JsonTabProps { | ||
| /** | ||
| * The data-test-subj to prefix the component one's | ||
| */ | ||
| ['data-test-subj']?: string; | ||
| /** | ||
| * Use to influence the height of the JsonCodeEditor (in some place the flyout does not have a footer). | ||
| */ | ||
| showFooterOffset: boolean; | ||
| /** | ||
| * Json value to render in the JsonCodeEditor | ||
| */ | ||
| value: Record<string, unknown>; | ||
| } | ||
|
|
||
| /** | ||
| * Json view displayed in the document details expandable flyout right section and in the indicator flyout. | ||
| */ | ||
| export const JsonTab = memo( | ||
| ({ value, showFooterOffset, 'data-test-subj': dataTestSubj }: JsonTabProps) => { | ||
| const jsonValue = JSON.stringify(value, null, 2); | ||
|
|
||
| const flexGroupElement = useRef<HTMLDivElement>(null); | ||
| const [editorHeight, setEditorHeight] = useState<number>(); | ||
|
|
||
| useEffect(() => { | ||
| const topPosition = flexGroupElement?.current?.getBoundingClientRect().top || 0; | ||
| const footerOffset = showFooterOffset ? 0 : FLYOUT_FOOTER_HEIGHT; | ||
| const height = | ||
| window.innerHeight - | ||
| topPosition - | ||
| COPY_TO_CLIPBOARD_BUTTON_HEIGHT - | ||
| FLYOUT_BODY_PADDING - | ||
| footerOffset; | ||
|
|
||
| if (height === 0) { | ||
| return; | ||
| } | ||
|
|
||
| setEditorHeight(height); | ||
| }, [setEditorHeight, showFooterOffset]); | ||
|
|
||
| return ( | ||
| <EuiFlexGroup | ||
| ref={flexGroupElement} | ||
| direction="column" | ||
| gutterSize="none" | ||
| data-test-subj={`${dataTestSubj}${JSON_TAB_CONTENT_TEST_ID}`} | ||
| > | ||
| <EuiFlexItem> | ||
| <EuiFlexGroup justifyContent={'flexEnd'}> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiCopy textToCopy={jsonValue}> | ||
| {(copy) => ( | ||
| <EuiButtonEmpty | ||
| iconType={'copyClipboard'} | ||
| size={'xs'} | ||
| aria-label={i18n.translate( | ||
| 'xpack.securitySolution.flyout.shared.jsonTab.copyToClipboardButtonAriaLabel', | ||
| { | ||
| defaultMessage: 'Copy to clipboard', | ||
| } | ||
| )} | ||
| data-test-subj={`${dataTestSubj}${JSON_TAB_COPY_TO_CLIPBOARD_BUTTON_TEST_ID}`} | ||
| onClick={copy} | ||
| onKeyDown={copy} | ||
| > | ||
| <FormattedMessage | ||
| id="xpack.securitySolution.flyout.shared.jsonTab.copyToClipboardButtonLabel" | ||
| defaultMessage="Copy to clipboard" | ||
| /> | ||
| </EuiButtonEmpty> | ||
| )} | ||
| </EuiCopy> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| </EuiFlexItem> | ||
| <EuiFlexItem> | ||
| <JsonCodeEditor json={value} height={editorHeight} hasLineNumbers={true} /> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| JsonTab.displayName = 'JsonTab'; |
NicholasPeretti marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.