From 9220afce6e75b528cca85e7cd5764e0bc1e616da Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:13:16 +0530 Subject: [PATCH] feat: Insert captain response to reply editor (#10581) --- .../components-next/copilot/Copilot.vue | 9 +++-- .../copilot/CopilotAssistantMessage.vue | 35 ++++++++++++++++++- .../components/copilot/CopilotContainer.vue | 5 +++ .../conversation/ConversationSidebar.vue | 9 +++-- .../widgets/conversation/ReplyBox.vue | 2 ++ .../i18n/locale/en/integrations.json | 3 +- app/javascript/shared/constants/busEvents.js | 1 + 7 files changed, 57 insertions(+), 7 deletions(-) diff --git a/app/javascript/dashboard/components-next/copilot/Copilot.vue b/app/javascript/dashboard/components-next/copilot/Copilot.vue index 3839532f2..2fcb15bcc 100644 --- a/app/javascript/dashboard/components-next/copilot/Copilot.vue +++ b/app/javascript/dashboard/components-next/copilot/Copilot.vue @@ -18,6 +18,10 @@ const props = defineProps({ type: Boolean, default: false, }, + conversationInboxType: { + type: String, + required: true, + }, }); const emit = defineEmits(['sendMessage']); @@ -47,7 +51,7 @@ watch( diff --git a/app/javascript/dashboard/components-next/copilot/CopilotAssistantMessage.vue b/app/javascript/dashboard/components-next/copilot/CopilotAssistantMessage.vue index a14508150..dd9d1defd 100644 --- a/app/javascript/dashboard/components-next/copilot/CopilotAssistantMessage.vue +++ b/app/javascript/dashboard/components-next/copilot/CopilotAssistantMessage.vue @@ -1,12 +1,36 @@ diff --git a/app/javascript/dashboard/components/copilot/CopilotContainer.vue b/app/javascript/dashboard/components/copilot/CopilotContainer.vue index 940408ef8..443a79ebf 100644 --- a/app/javascript/dashboard/components/copilot/CopilotContainer.vue +++ b/app/javascript/dashboard/components/copilot/CopilotContainer.vue @@ -8,6 +8,10 @@ const props = defineProps({ type: [Number, String], required: true, }, + conversationInboxType: { + type: String, + required: true, + }, }); const currentUser = useMapGetter('getCurrentUser'); const messages = ref([]); @@ -53,6 +57,7 @@ const sendMessage = async message => { :messages="messages" :support-agent="currentUser" :is-captain-typing="isCaptainTyping" + :conversation-inbox-type="conversationInboxType" @send-message="sendMessage" /> diff --git a/app/javascript/dashboard/components/widgets/conversation/ConversationSidebar.vue b/app/javascript/dashboard/components/widgets/conversation/ConversationSidebar.vue index 3d2509686..a0b07d44b 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ConversationSidebar.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ConversationSidebar.vue @@ -6,7 +6,7 @@ import ContactPanel from 'dashboard/routes/dashboard/conversation/ContactPanel.v import TabBar from 'dashboard/components-next/tabbar/TabBar.vue'; import { useI18n } from 'vue-i18n'; -defineProps({ +const props = defineProps({ currentChat: { required: true, type: Object, @@ -16,11 +16,13 @@ defineProps({ const emit = defineEmits(['toggleContactPanel']); const getters = useStoreGetters(); +const { t } = useI18n(); const captainIntegration = computed(() => getters['integrations/getIntegration'].value('captain', null) ); -const { t } = useI18n(); + +const channelType = computed(() => props.currentChat?.meta?.channel || ''); const CONTACT_TABS_OPTIONS = [ { key: 'CONTACT', value: 'contact' }, @@ -61,7 +63,7 @@ const showCopilotTab = computed(() => { @tab-changed="handleTabChange" /> -
+
{ diff --git a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue index 3d490894a..235dfdae3 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue @@ -459,11 +459,13 @@ export default { BUS_EVENTS.NEW_CONVERSATION_MODAL, this.onNewConversationModalActive ); + emitter.on(BUS_EVENTS.INSERT_INTO_NORMAL_EDITOR, this.addIntoEditor); }, unmounted() { document.removeEventListener('paste', this.onPaste); document.removeEventListener('keydown', this.handleKeyEvents); emitter.off(BUS_EVENTS.TOGGLE_REPLY_TO_MESSAGE, this.fetchAndSetReplyTo); + emitter.off(BUS_EVENTS.INSERT_INTO_NORMAL_EDITOR, this.addIntoEditor); emitter.off( BUS_EVENTS.NEW_CONVERSATION_MODAL, this.onNewConversationModalActive diff --git a/app/javascript/dashboard/i18n/locale/en/integrations.json b/app/javascript/dashboard/i18n/locale/en/integrations.json index e04164902..c96735ab8 100644 --- a/app/javascript/dashboard/i18n/locale/en/integrations.json +++ b/app/javascript/dashboard/i18n/locale/en/integrations.json @@ -305,7 +305,8 @@ "COPILOT": { "SEND_MESSAGE": "Send message...", "LOADER": "Captain is thinking", - "YOU": "You" + "YOU": "You", + "USE": "Use this" } } } diff --git a/app/javascript/shared/constants/busEvents.js b/app/javascript/shared/constants/busEvents.js index 2229a8b4c..8ae15c3f8 100644 --- a/app/javascript/shared/constants/busEvents.js +++ b/app/javascript/shared/constants/busEvents.js @@ -14,4 +14,5 @@ export const BUS_EVENTS = { SHOW_TOAST: 'newToastMessage', NEW_CONVERSATION_MODAL: 'newConversationModal', INSERT_INTO_RICH_EDITOR: 'insertIntoRichEditor', + INSERT_INTO_NORMAL_EDITOR: 'insertIntoNormalEditor', };