Skip to content

Commit

Permalink
[Security Solution] Fix whitespace/newlines for exception comments (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallmain authored Feb 10, 2025
1 parent bfa945a commit 1b8bdcf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -74,6 +76,10 @@ export const formatOperatingSystems = (osTypes: string[]): string => {
.join(', ');
};

const commentCss = css`
white-space: pre-wrap;
`;

/**
* Formats ExceptionItem.comments into EuiCommentList format
*
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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"
Expand Down

0 comments on commit 1b8bdcf

Please sign in to comment.