-
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.
Browse files
Browse the repository at this point in the history
…04084) ## Summary [Internal link](elastic/security-team#10820) to the feature details These changes add a "Summary" tab within the migration rule details flyout which will show the AI assistant comments about the translation process of the rule. ## Screenshot <img width="1675" alt="Screenshot 2024-12-12 at 17 39 30" src="https://github.com/user-attachments/assets/213c3e80-70df-482a-8dfd-09fc1e2e54c8" />
- Loading branch information
Showing
12 changed files
with
132 additions
and
13 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
9 changes: 9 additions & 0 deletions
9
...urity_solution/public/siem_migrations/rules/components/rule_details_flyout/tabs/index.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,9 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export * from './summary'; | ||
export * from './translation'; |
54 changes: 54 additions & 0 deletions
54
...lution/public/siem_migrations/rules/components/rule_details_flyout/tabs/summary/index.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,54 @@ | ||
/* | ||
* 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, { useMemo } from 'react'; | ||
import type { EuiCommentProps } from '@elastic/eui'; | ||
import { EuiAvatar, EuiCommentList, EuiMarkdownFormat, EuiSpacer } from '@elastic/eui'; | ||
import moment from 'moment'; | ||
import { AssistantAvatar } from '@kbn/elastic-assistant'; | ||
import { | ||
RuleMigrationStatusEnum, | ||
type RuleMigration, | ||
} from '../../../../../../../common/siem_migrations/model/rule_migration.gen'; | ||
import * as i18n from './translations'; | ||
|
||
interface SummaryTabProps { | ||
ruleMigration: RuleMigration; | ||
} | ||
|
||
export const SummaryTab: React.FC<SummaryTabProps> = React.memo(({ ruleMigration }) => { | ||
const timestamp = useMemo( | ||
// Date formats https://momentjs.com/docs/#/displaying/format/ | ||
() => moment(ruleMigration['@timestamp']).format('ll'), | ||
[ruleMigration] | ||
); | ||
const comments: EuiCommentProps[] | undefined = useMemo(() => { | ||
return ruleMigration.comments?.map((comment) => { | ||
return { | ||
username: i18n.ASSISTANT_USERNAME, | ||
timelineAvatarAriaLabel: i18n.ASSISTANT_USERNAME, | ||
timelineAvatar: ( | ||
<EuiAvatar name="machine" size="l" color="subdued" iconType={AssistantAvatar} /> | ||
), | ||
event: | ||
ruleMigration.status === RuleMigrationStatusEnum.failed | ||
? i18n.COMMENT_EVENT_FAILED | ||
: i18n.COMMENT_EVENT_TRANSLATED, | ||
timestamp, | ||
children: <EuiMarkdownFormat textSize="s">{comment}</EuiMarkdownFormat>, | ||
}; | ||
}); | ||
}, [ruleMigration, timestamp]); | ||
|
||
return ( | ||
<> | ||
<EuiSpacer size="m" /> | ||
<EuiCommentList comments={comments} aria-label={i18n.ASSISTANT_COMMENTS} /> | ||
</> | ||
); | ||
}); | ||
SummaryTab.displayName = 'SummaryTab'; |
36 changes: 36 additions & 0 deletions
36
.../public/siem_migrations/rules/components/rule_details_flyout/tabs/summary/translations.ts
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,36 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
|
||
export const ASSISTANT_USERNAME = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.translationDetails.summaryTab.assistantUsername', | ||
{ | ||
defaultMessage: 'Assistant', | ||
} | ||
); | ||
|
||
export const ASSISTANT_COMMENTS = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.translationDetails.summaryTab.commentsLabel', | ||
{ | ||
defaultMessage: 'Assistant comments', | ||
} | ||
); | ||
|
||
export const COMMENT_EVENT_TRANSLATED = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.translationDetails.summaryTab.commentEvent.translatedLabel', | ||
{ | ||
defaultMessage: 'created a final translation', | ||
} | ||
); | ||
|
||
export const COMMENT_EVENT_FAILED = i18n.translate( | ||
'xpack.securitySolution.siemMigrations.rules.translationDetails.summaryTab.commentEvent.failedLabel', | ||
{ | ||
defaultMessage: 'failed to translate', | ||
} | ||
); |
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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