[8.9] [Security Solution] Close the assistant dialog on add to case #6973 (#161686) (#161705)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[Security Solution] Close the assistant dialog on add to case #6973
(#161686)](https://github.com/elastic/kibana/pull/161686)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Luke","email":"11671118+lgestc@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-07-11T18:57:43Z","message":"[Security
Solution] Close the assistant dialog on add to case #6973
(#161686)","sha":"26334b5111ca2347176ac221872d3341f83205be","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v8.9.0","Feature:Elastic
Assistant","v8.10.0"],"number":161686,"url":"https://github.com/elastic/kibana/pull/161686","mergeCommit":{"message":"[Security
Solution] Close the assistant dialog on add to case #6973
(#161686)","sha":"26334b5111ca2347176ac221872d3341f83205be"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/161686","number":161686,"mergeCommit":{"message":"[Security
Solution] Close the assistant dialog on add to case #6973
(#161686)","sha":"26334b5111ca2347176ac221872d3341f83205be"}}]}]
BACKPORT-->

Co-authored-by: Luke <11671118+lgestc@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2023-07-11 16:20:30 -04:00 committed by GitHub
parent ba98a47614
commit c1d0010b77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,6 +11,7 @@ import type { Message } from '@kbn/elastic-assistant';
import React, { useCallback } from 'react';
import { useDispatch } from 'react-redux';
import { useAssistantContext } from '@kbn/elastic-assistant/impl/assistant_context';
import { useKibana, useToasts } from '../../common/lib/kibana';
import type { Note } from '../../common/lib/note';
import { appActions } from '../../common/store/actions';
@ -28,6 +29,8 @@ const CommentActionsComponent: React.FC<Props> = ({ message }) => {
const { cases } = useKibana().services;
const dispatch = useDispatch();
const { showAssistantOverlay } = useAssistantContext();
const associateNote = useCallback(
(noteId: string) => dispatch(timelineActions.addNote({ id: TimelineId.active, noteId })),
[dispatch]
@ -57,6 +60,8 @@ const CommentActionsComponent: React.FC<Props> = ({ message }) => {
});
const onAddToExistingCase = useCallback(() => {
showAssistantOverlay({ showOverlay: false });
selectCaseModal.open({
getAttachments: () => [
{
@ -66,7 +71,7 @@ const CommentActionsComponent: React.FC<Props> = ({ message }) => {
},
],
});
}, [message.content, selectCaseModal]);
}, [message.content, selectCaseModal, showAssistantOverlay]);
return (
<EuiFlexGroup alignItems="center" gutterSize="none">