diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/new_chat_by_title/index.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/new_chat_by_title/index.tsx index 3cdfebaf0a118..d9f64ed9d083f 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/new_chat_by_title/index.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/new_chat_by_title/index.tsx @@ -14,6 +14,8 @@ export interface Props { /** Optionally render new chat as a link */ asLink?: boolean; children?: React.ReactNode; + /** Optionally specify color of empty button */ + color?: 'text' | 'accent' | 'primary' | 'success' | 'warning' | 'danger'; showAssistantOverlay: (show: boolean) => void; /** Defaults to `discuss`. If null, the button will not have an icon */ iconType?: string | null; @@ -24,6 +26,7 @@ export interface Props { const NewChatByTitleComponent: React.FC = ({ asLink = false, children = i18n.NEW_CHAT, + color = 'primary', showAssistantOverlay, iconType, iconOnly = false, @@ -44,7 +47,7 @@ const NewChatByTitleComponent: React.FC = ({ return useMemo( () => asLink ? ( - + {children} ) : iconOnly ? ( @@ -59,6 +62,7 @@ const NewChatByTitleComponent: React.FC = ({ ) : ( = ({ {children} ), - [children, icon, showOverlay, iconOnly] + [asLink, color, showOverlay, children, iconOnly, icon] ); }; diff --git a/x-pack/solutions/security/packages/ecs-data-quality-dashboard/impl/data_quality_panel/actions/chat/index.tsx b/x-pack/solutions/security/packages/ecs-data-quality-dashboard/impl/data_quality_panel/actions/chat/index.tsx index 76199debddf44..67dc79ea7a507 100644 --- a/x-pack/solutions/security/packages/ecs-data-quality-dashboard/impl/data_quality_panel/actions/chat/index.tsx +++ b/x-pack/solutions/security/packages/ecs-data-quality-dashboard/impl/data_quality_panel/actions/chat/index.tsx @@ -52,7 +52,7 @@ const ChatActionComponent: FC = ({ indexName, markdownComment, chatTitle isAssistantEnabled ); return ( - + {ASK_ASSISTANT} diff --git a/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx b/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx index 5a5fa5e10795a..8fd01a090c919 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx @@ -433,6 +433,7 @@ const RuleDetailsPageComponent: React.FC = ({ ) : ( { () => rules.filter((rule) => selectedRuleIds.includes(rule.id)), [rules, selectedRuleIds] ); + + const selectedRuleNames = useMemo(() => selectedRules.map((rule) => rule.name), [selectedRules]); const getPromptContext = useCallback( async () => getPromptContextFromDetectionRules(selectedRules), [selectedRules] ); + const chatTitle = useMemo(() => { + return `${i18nAssistant.DETECTION_RULES_CONVERSATION_ID} - ${selectedRuleNames.join(', ')}`; + }, [selectedRuleNames]); + + const { showAssistantOverlay } = useAssistantOverlay( + 'detection-rules', + chatTitle, + i18nAssistant.RULE_MANAGEMENT_CONTEXT_DESCRIPTION, + getPromptContext, + null, + i18nAssistant.EXPLAIN_THEN_SUMMARIZE_RULE_DETAILS, + i18nAssistant.RULE_MANAGEMENT_CONTEXT_TOOLTIP, + isAssistantEnabled + ); + return ( @@ -98,15 +115,7 @@ export const RulesTableToolbar = React.memo(() => { {hasAssistantPrivilege && selectedRules.length > 0 && ( - + )} diff --git a/x-pack/solutions/security/plugins/security_solution/public/detections/components/rules/rule_execution_status/rule_status_failed_callout.tsx b/x-pack/solutions/security/plugins/security_solution/public/detections/components/rules/rule_execution_status/rule_status_failed_callout.tsx index 353a5bd0636f7..4602d2f56bb56 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/detections/components/rules/rule_execution_status/rule_status_failed_callout.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/detections/components/rules/rule_execution_status/rule_status_failed_callout.tsx @@ -5,21 +5,21 @@ * 2.0. */ -import React, { useCallback } from 'react'; +import React, { useCallback, useMemo } from 'react'; import { css } from '@emotion/react'; import { EuiCallOut, EuiCodeBlock } from '@elastic/eui'; -import { NewChat } from '@kbn/elastic-assistant'; +import { NewChatByTitle, useAssistantOverlay } from '@kbn/elastic-assistant'; import { FormattedDate } from '../../../../common/components/formatted_date'; import type { RuleExecutionStatus } from '../../../../../common/api/detection_engine/rule_monitoring'; import { RuleExecutionStatusEnum } from '../../../../../common/api/detection_engine/rule_monitoring'; import * as i18n from './translations'; -import * as i18nAssistant from '../../../pages/detection_engine/rules/translations'; import { useAssistantAvailability } from '../../../../assistant/use_assistant_availability'; interface RuleStatusFailedCallOutProps { + ruleNameForChat: string; ruleName?: string | undefined; dataSources?: string[] | undefined; date: string; @@ -29,6 +29,7 @@ interface RuleStatusFailedCallOutProps { const RuleStatusFailedCallOutComponent: React.FC = ({ ruleName, + ruleNameForChat, dataSources, date, message, @@ -43,6 +44,20 @@ const RuleStatusFailedCallOutComponent: React.FC = : `Error message: ${message}`, [message, ruleName, dataSources] ); + + const chatTitle = useMemo(() => { + return `${ruleNameForChat} - ${title} ${date}`; + }, [date, title, ruleNameForChat]); + const { showAssistantOverlay } = useAssistantOverlay( + 'detection-rules', + chatTitle, + i18n.ASK_ASSISTANT_DESCRIPTION, + getPromptContext, + null, + i18n.ASK_ASSISTANT_USER_PROMPT, + i18n.ASK_ASSISTANT_TOOLTIP, + isAssistantEnabled + ); if (!shouldBeDisplayed) { return null; } @@ -77,18 +92,9 @@ const RuleStatusFailedCallOutComponent: React.FC = {message} {hasAssistantPrivilege && ( - + {i18n.ASK_ASSISTANT_ERROR_BUTTON} - + )}