From c19cfeaa81ead7e96ef29fbc92f030d823e2f132 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Tue, 3 Oct 2023 13:45:28 +0530 Subject: [PATCH] feat: Adds message signature for new email conversations (#7946) Co-authored-by: Shivam Mishra --- .../components/widgets/WootWriter/Editor.vue | 1 + .../MessageSignatureMissingAlert.vue | 28 ++++++++ .../widgets/conversation/ReplyBox.vue | 35 ++-------- .../conversation/contact/ConversationForm.vue | 68 ++++++++++++++++++- 4 files changed, 100 insertions(+), 32 deletions(-) create mode 100644 app/javascript/dashboard/components/widgets/conversation/MessageSignatureMissingAlert.vue diff --git a/app/javascript/dashboard/components/widgets/WootWriter/Editor.vue b/app/javascript/dashboard/components/widgets/WootWriter/Editor.vue index 09a256a94..f18adc418 100644 --- a/app/javascript/dashboard/components/widgets/WootWriter/Editor.vue +++ b/app/javascript/dashboard/components/widgets/WootWriter/Editor.vue @@ -23,6 +23,7 @@ @change="onFileChange" />
+
diff --git a/app/javascript/dashboard/components/widgets/conversation/MessageSignatureMissingAlert.vue b/app/javascript/dashboard/components/widgets/conversation/MessageSignatureMissingAlert.vue new file mode 100644 index 000000000..81e4531af --- /dev/null +++ b/app/javascript/dashboard/components/widgets/conversation/MessageSignatureMissingAlert.vue @@ -0,0 +1,28 @@ + + + + + diff --git a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue index 870531444..dbe70c979 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue @@ -90,17 +90,9 @@ :remove-attachment="removeAttachment" /> -
-

- {{ $t('CONVERSATION.FOOTER.MESSAGE_SIGNATURE_NOT_CONFIGURED') }} - - {{ $t('CONVERSATION.FOOTER.CLICK_HERE') }} - -

-
+ /> + > + + {{ $t('NEW_CONVERSATION.FORM.MESSAGE.ERROR') }} @@ -162,6 +182,7 @@ import Thumbnail from 'dashboard/components/widgets/Thumbnail.vue'; import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor.vue'; import ReplyEmailHead from 'dashboard/components/widgets/conversation/ReplyEmailHead.vue'; import CannedResponse from 'dashboard/components/widgets/conversation/CannedResponse.vue'; +import MessageSignatureMissingAlert from 'dashboard/components/widgets/conversation/MessageSignatureMissingAlert'; import InboxDropdownItem from 'dashboard/components/widgets/InboxDropdownItem.vue'; import WhatsappTemplates from './WhatsappTemplates.vue'; import alertMixin from 'shared/mixins/alertMixin'; @@ -169,6 +190,11 @@ import { INBOX_TYPES } from 'shared/mixins/inboxMixin'; import { ExceptionWithMessage } from 'shared/helpers/CustomErrors'; import { getInboxSource } from 'dashboard/helper/inbox'; import { required, requiredIf } from 'vuelidate/lib/validators'; +import { + appendSignature, + removeSignature, +} from 'dashboard/helper/editorHelper'; +import uiSettingsMixin from 'dashboard/mixins/uiSettings'; export default { components: { @@ -178,8 +204,9 @@ export default { CannedResponse, WhatsappTemplates, InboxDropdownItem, + MessageSignatureMissingAlert, }, - mixins: [alertMixin], + mixins: [alertMixin, uiSettingsMixin], props: { contact: { type: Object, @@ -219,7 +246,15 @@ export default { uiFlags: 'contacts/getUIFlags', conversationsUiFlags: 'contactConversations/getUIFlags', currentUser: 'getCurrentUser', + messageSignature: 'getMessageSignature', }), + sendWithSignature() { + const { send_with_signature: isEnabled } = this.uiSettings; + return isEnabled; + }, + signatureToApply() { + return this.messageSignature; + }, emailMessagePayload() { const payload = { inboxId: this.targetInbox.id, @@ -259,6 +294,14 @@ export default { } return this.inboxes.length === 0 && !this.uiFlags.isFetchingInboxes; }, + isSignatureEnabledForInbox() { + return this.isAnEmailInbox && this.sendWithSignature; + }, + signatureToggleTooltip() { + return this.sendWithSignature + ? this.$t('CONVERSATION.FOOTER.DISABLE_SIGN_TOOLTIP') + : this.$t('CONVERSATION.FOOTER.ENABLE_SIGN_TOOLTIP'); + }, inboxes() { const inboxList = this.contact.contactableInboxes || []; return inboxList.map(inbox => ({ @@ -298,8 +341,23 @@ export default { this.showCannedResponseMenu = false; } }, + targetInbox() { + this.setSignature(); + }, + }, + mounted() { + this.setSignature(); }, methods: { + setSignature() { + if (this.messageSignature) { + if (this.isSignatureEnabledForInbox) { + this.message = appendSignature(this.message, this.signatureToApply); + } else { + this.message = removeSignature(this.message, this.signatureToApply); + } + } + }, onCancel() { this.$emit('cancel'); }, @@ -370,6 +428,12 @@ export default { ); return classByType; }, + toggleMessageSignature() { + this.updateUISettings({ + send_with_signature: !this.sendWithSignature, + }); + this.setSignature(); + }, }, };