From 8291c84cc3a201d495de8ef770f645b496d446cd Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Tue, 18 Mar 2025 15:09:10 +0530 Subject: [PATCH] feat: Use new compose conversation in conversation sidebar (#11085) # Pull Request Template ## Description This PR includes the implementation of the new Compose Conversation form in the conversation sidebar, replacing the old one. ## Type of change - [x] New feature (non-breaking change which adds functionality) ## How Has This Been Tested? ### Loom video https://www.loom.com/share/4312e20a63714eb892d7b5cd0dcda893?sid=9bd5254e-2b1f-462c-b2c1-a3048a111683 ## 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 --- .../NewConversation/ComposeConversation.vue | 79 ++- .../components/ActionButtons.vue | 16 + .../components/ComposeNewConversationForm.vue | 2 +- .../components/ContactSelector.vue | 4 +- .../components/InboxSelector.vue | 2 +- .../components/WhatsAppOptions.vue | 2 +- .../components/WhatsappTemplateParser.vue | 2 +- .../components/widgets/InboxDropdownItem.vue | 76 --- .../conversation/contact/ContactInfo.vue | 60 +- .../conversation/contact/ConversationForm.vue | 638 ------------------ .../conversation/contact/NewConversation.vue | 71 -- .../contact/WhatsappTemplates.vue | 54 -- 12 files changed, 113 insertions(+), 893 deletions(-) delete mode 100644 app/javascript/dashboard/components/widgets/InboxDropdownItem.vue delete mode 100644 app/javascript/dashboard/routes/dashboard/conversation/contact/ConversationForm.vue delete mode 100644 app/javascript/dashboard/routes/dashboard/conversation/contact/NewConversation.vue delete mode 100644 app/javascript/dashboard/routes/dashboard/conversation/contact/WhatsappTemplates.vue diff --git a/app/javascript/dashboard/components-next/NewConversation/ComposeConversation.vue b/app/javascript/dashboard/components-next/NewConversation/ComposeConversation.vue index 93b0baa3d..610d11dab 100644 --- a/app/javascript/dashboard/components-next/NewConversation/ComposeConversation.vue +++ b/app/javascript/dashboard/components-next/NewConversation/ComposeConversation.vue @@ -27,8 +27,14 @@ const props = defineProps({ type: String, default: null, }, + isModal: { + type: Boolean, + default: false, + }, }); +const emit = defineEmits(['close']); + const store = useStore(); const { t } = useI18n(); @@ -61,6 +67,8 @@ const directUploadsEnabled = computed( const activeContact = computed(() => contactById.value(props.contactId)); const composePopoverClass = computed(() => { + if (props.isModal) return ''; + return props.alignPosition === 'right' ? 'absolute ltr:left-0 ltr:right-[unset] rtl:right-0 rtl:left-[unset]' : 'absolute rtl:left-0 rtl:right-[unset] ltr:right-0 ltr:left-[unset]'; @@ -131,9 +139,14 @@ const clearSelectedContact = () => { const closeCompose = () => { showComposeNewConversation.value = false; - selectedContact.value = null; + if (!props.contactId) { + // If contactId is passed as prop + // Then don't allow to remove the selected contact + selectedContact.value = null; + } targetInbox.value = null; resetContacts(); + emit('close'); }; const createConversation = async ({ payload, isFromWhatsApp }) => { @@ -182,7 +195,15 @@ watch( ); const handleClickOutside = () => { + if (!showComposeNewConversation.value) return; + showComposeNewConversation.value = false; + emit('close'); +}; + +const onModalBackdropClick = () => { + if (!props.isModal) return; + handleClickOutside(); }; onMounted(() => resetContacts()); @@ -205,7 +226,7 @@ useKeyboardEvents(keyboardEvents); v-on-click-outside="[ handleClickOutside, // Fixed and edge case https://github.com/chatwoot/chatwoot/issues/10785 - // This will prevent closing the compose conversation modal when the editor Create link popup is open. + // This will prevent closing the compose conversation modal when the editor Create link popup is open { ignore: ['div.ProseMirror-prompt'] }, ]" class="relative" @@ -218,29 +239,37 @@ useKeyboardEvents(keyboardEvents); :is-open="showComposeNewConversation" :toggle="toggle" /> - + :class="{ + 'fixed z-50 bg-n-alpha-black1 backdrop-blur-[4px] flex items-start pt-[clamp(3rem,15vh,12rem)] justify-center inset-0': + isModal, + }" + @click.self="onModalBackdropClick" + > + + diff --git a/app/javascript/dashboard/components-next/NewConversation/components/ActionButtons.vue b/app/javascript/dashboard/components-next/NewConversation/components/ActionButtons.vue index 8d421a5aa..90cb67c4f 100644 --- a/app/javascript/dashboard/components-next/NewConversation/components/ActionButtons.vue +++ b/app/javascript/dashboard/components-next/NewConversation/components/ActionButtons.vue @@ -232,4 +232,20 @@ useKeyboardEvents(keyboardEvents); .emoji-dialog::before { @apply hidden; } + +// The