[Security Solution] Fix whitespace/newlines for exception comments (#208959)

## Summary

Fixes https://github.com/elastic/kibana/issues/208956

## Before

![image](https://github.com/user-attachments/assets/aa9b00e9-da70-4ff2-be18-4073235e8a85)

## After

![image](https://github.com/user-attachments/assets/0fa2a69c-836d-4e98-8ecb-be88d1170519)
This commit is contained in:
Marshall Main 2025-02-10 18:17:49 -05:00 committed by GitHub
parent bfa945a0ea
commit 1b8bdcff67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 2 deletions

View file

@ -12,6 +12,8 @@ import { capitalize, get, omit } from 'lodash';
import type { Moment } from 'moment';
import moment from 'moment';
import { css } from '@emotion/react';
import type {
CommentsArray,
Comment,
@ -74,6 +76,10 @@ export const formatOperatingSystems = (osTypes: string[]): string => {
.join(', ');
};
const commentCss = css`
white-space: pre-wrap;
`;
/**
* Formats ExceptionItem.comments into EuiCommentList format
*
@ -85,7 +91,11 @@ export const getFormattedComments = (comments: CommentsArray): EuiCommentProps[]
timestamp: moment(commentItem.created_at).format('on MMM Do YYYY @ HH:mm:ss'),
event: i18n.COMMENT_EVENT,
timelineAvatar: <EuiAvatar size="l" name={commentItem.created_by.toUpperCase()} />,
children: <EuiText size="s">{commentItem.comment}</EuiText>,
children: (
<EuiText size="s" css={commentCss}>
{commentItem.comment}
</EuiText>
),
actions: (
<WithCopyToClipboard
data-test-subj="copy-to-clipboard"

View file

@ -11,10 +11,16 @@ import { EuiText, EuiAvatar } from '@elastic/eui';
import type { CommentsArray } from '@kbn/securitysolution-io-ts-list-types';
import { css } from '@emotion/react';
import moment from 'moment';
import * as i18n from './translations';
import { WithCopyToClipboard } from '../../common/lib/clipboard/with_copy_to_clipboard';
const commentCss = css`
white-space: pre-wrap;
`;
/**
* Formats ExceptionItem.comments into EuiCommentList format
*
@ -26,7 +32,11 @@ export const getFormattedComments = (comments: CommentsArray): EuiCommentProps[]
timestamp: moment(commentItem.created_at).format('on MMM Do YYYY @ HH:mm:ss'),
event: i18n.COMMENT_EVENT,
timelineAvatar: <EuiAvatar size="l" name={commentItem.created_by.toUpperCase()} />,
children: <EuiText size="s">{commentItem.comment}</EuiText>,
children: (
<EuiText size="s" css={commentCss}>
{commentItem.comment}
</EuiText>
),
actions: (
<WithCopyToClipboard
data-test-subj="copy-to-clipboard"