-
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.
[Obs AI Assistant] Sharing conversations (new context menu for chat a…
…nd other updates) (#206590)
- Loading branch information
Showing
7 changed files
with
361 additions
and
109 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
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
83 changes: 83 additions & 0 deletions
83
x-pack/platform/packages/shared/kbn-ai-assistant/src/chat/chat_context_menu.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,83 @@ | ||
/* | ||
* 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, { useState } from 'react'; | ||
import { | ||
EuiButtonIcon, | ||
EuiPopover, | ||
EuiContextMenuItem, | ||
EuiContextMenuPanel, | ||
EuiToolTip, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
export function ChatContextMenu({ | ||
onCopyConversationClick, | ||
disabled, | ||
}: { | ||
onCopyConversationClick: () => void; | ||
disabled: boolean; | ||
}) { | ||
const [isPopoverOpen, setIsPopoverOpen] = useState(false); | ||
|
||
return ( | ||
<EuiPopover | ||
button={ | ||
<EuiToolTip | ||
content={i18n.translate('xpack.aiAssistant.chatHeader.contextMenu.chatActionsTooltip', { | ||
defaultMessage: 'Chat actions', | ||
})} | ||
display="block" | ||
> | ||
<EuiButtonIcon | ||
data-test-subj="observabilityAiAssistantChatContextMenuButtonIcon" | ||
iconType="boxesHorizontal" | ||
disabled={disabled} | ||
aria-label={i18n.translate('xpack.aiAssistant.chatHeader.contextMenu.iconAreaLabel', { | ||
defaultMessage: 'Chat context menu', | ||
})} | ||
onClick={() => setIsPopoverOpen(!isPopoverOpen)} | ||
/> | ||
</EuiToolTip> | ||
} | ||
isOpen={isPopoverOpen} | ||
closePopover={() => setIsPopoverOpen(false)} | ||
anchorPosition="downCenter" | ||
panelPaddingSize="xs" | ||
> | ||
<EuiContextMenuPanel | ||
size="s" | ||
items={[ | ||
<EuiContextMenuItem | ||
key="copyConversation" | ||
icon="copyClipboard" | ||
onClick={() => { | ||
onCopyConversationClick(); | ||
setIsPopoverOpen(false); | ||
}} | ||
> | ||
{i18n.translate('xpack.aiAssistant.chatHeader.contextMenu.copyConversation', { | ||
defaultMessage: 'Copy conversation', | ||
})} | ||
</EuiContextMenuItem>, | ||
<EuiContextMenuItem | ||
key="copyURL" | ||
icon="link" | ||
onClick={() => { | ||
navigator.clipboard.writeText(window.location.href); | ||
setIsPopoverOpen(false); | ||
}} | ||
> | ||
{i18n.translate('xpack.aiAssistant.chatHeader.contextMenu.copyURL', { | ||
defaultMessage: 'Copy URL', | ||
})} | ||
</EuiContextMenuItem>, | ||
]} | ||
/> | ||
</EuiPopover> | ||
); | ||
} |
Oops, something went wrong.