From 270f26e47194f6a74bae59b3514d1c4f7b52293b Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Tue, 5 Aug 2025 03:52:20 +0530 Subject: [PATCH] chore: Add new tab and copy link to conversation context menu (#12089) # Pull Request Template ## Description This PR includes the following enhancements to the conversation card context menu: 1. **Added "Open in New Tab" and "Copy Conversation Link" options.** * "Open in New Tab" allows users to quickly open a conversation in a separate browser tab. * "Copy Conversation Link" copies the conversation URL to the clipboard for easy sharing. 2. **Enabled the context menu in Previous Conversations card** with support for these two options. Fixes https://linear.app/chatwoot/issue/CW-4722/cannot-open-previous-conversations-in-a-new-tab ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? ### Loom video https://www.loom.com/share/37b45d23c6804db292568d093b645ac0?sid=c3105971-f938-41bd-9f52-0f00d419d1b3 ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --------- Co-authored-by: Pranav --- .../widgets/conversation/ConversationCard.vue | 31 ++- .../conversation/contextMenu/Index.vue | 239 ++++++++++++------ .../conversation/contextMenu/menuItem.vue | 34 ++- .../i18n/locale/en/conversation.json | 3 + .../conversation/ContactConversations.vue | 2 + 5 files changed, 206 insertions(+), 103 deletions(-) diff --git a/app/javascript/dashboard/components/widgets/conversation/ConversationCard.vue b/app/javascript/dashboard/components/widgets/conversation/ConversationCard.vue index 30e99ca9d..e87bea268 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ConversationCard.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ConversationCard.vue @@ -68,6 +68,10 @@ export default { type: Boolean, default: false, }, + allowedContextMenuOptions: { + type: Array, + default: () => [], + }, }, emits: [ 'contextMenuToggle', @@ -151,11 +155,9 @@ export default { hasSlaPolicyId() { return this.chat?.sla_policy_id; }, - }, - methods: { - onCardClick(e) { + conversationPath() { const { activeInbox, chat } = this; - const path = frontendURL( + return frontendURL( conversationUrl({ accountId: this.accountId, activeInbox, @@ -166,18 +168,26 @@ export default { conversationType: this.conversationType, }) ); + }, + }, + methods: { + onCardClick(e) { + const path = this.conversationPath; + if (!path) return; + // Handle Ctrl/Cmd + Click for new tab if (e.metaKey || e.ctrlKey) { + e.preventDefault(); window.open( - window.chatwootConfig.hostURL + path, + `${window.chatwootConfig.hostURL}${path}`, '_blank', - 'noopener noreferrer nofollow' + 'noopener,noreferrer' ); return; } - if (this.isActiveChat) { - return; - } + + // Skip if already active + if (this.isActiveChat) return; router.push({ path }); }, @@ -359,6 +369,8 @@ export default { :priority="chat.priority" :chat-id="chat.id" :has-unread-messages="hasUnread" + :conversation-url="conversationPath" + :allowed-options="allowedContextMenuOptions" @update-conversation="onUpdateConversation" @assign-agent="onAssignAgent" @assign-label="onAssignLabel" @@ -367,6 +379,7 @@ export default { @mark-as-read="markAsRead" @assign-priority="assignPriority" @delete-conversation="deleteConversation" + @close="closeContextMenu" /> diff --git a/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue b/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue index 6c788bbd2..a6f79500a 100644 --- a/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue +++ b/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue @@ -1,5 +1,8 @@