feat: Adds message signature for new email conversations (#7946)
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
@change="onFileChange"
|
@change="onFileChange"
|
||||||
/>
|
/>
|
||||||
<div ref="editor" />
|
<div ref="editor" />
|
||||||
|
<slot name="footer" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="my-0 mx-4 px-1 flex max-h-[8vh] items-baseline justify-between hover:bg-slate-25 dark:hover:bg-slate-800 border border-dashed border-slate-100 dark:border-slate-700 rounded-sm overflow-auto"
|
||||||
|
>
|
||||||
|
<p class="w-fit !m-0">
|
||||||
|
{{ $t('CONVERSATION.FOOTER.MESSAGE_SIGNATURE_NOT_CONFIGURED') }}
|
||||||
|
<woot-button
|
||||||
|
color-scheme="primary"
|
||||||
|
variant="link"
|
||||||
|
@click="openProfileSettings"
|
||||||
|
>
|
||||||
|
{{ $t('CONVERSATION.FOOTER.CLICK_HERE') }}
|
||||||
|
</woot-button>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
methods: {
|
||||||
|
openProfileSettings() {
|
||||||
|
return this.$router.push({ name: 'profile_settings_index' });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
@@ -90,17 +90,9 @@
|
|||||||
:remove-attachment="removeAttachment"
|
:remove-attachment="removeAttachment"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<message-signature-missing-alert
|
||||||
v-if="isSignatureEnabledForInbox && !isSignatureAvailable"
|
v-if="isSignatureEnabledForInbox && !isSignatureAvailable"
|
||||||
class="message-signature-wrap"
|
/>
|
||||||
>
|
|
||||||
<p class="message-signature">
|
|
||||||
{{ $t('CONVERSATION.FOOTER.MESSAGE_SIGNATURE_NOT_CONFIGURED') }}
|
|
||||||
<router-link :to="profilePath">
|
|
||||||
{{ $t('CONVERSATION.FOOTER.CLICK_HERE') }}
|
|
||||||
</router-link>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<reply-bottom-panel
|
<reply-bottom-panel
|
||||||
:conversation-id="conversationId"
|
:conversation-id="conversationId"
|
||||||
:enable-multiple-file-upload="enableMultipleFileUpload"
|
:enable-multiple-file-upload="enableMultipleFileUpload"
|
||||||
@@ -154,6 +146,7 @@ import AttachmentPreview from 'dashboard/components/widgets/AttachmentsPreview.v
|
|||||||
import ReplyTopPanel from 'dashboard/components/widgets/WootWriter/ReplyTopPanel.vue';
|
import ReplyTopPanel from 'dashboard/components/widgets/WootWriter/ReplyTopPanel.vue';
|
||||||
import ReplyEmailHead from './ReplyEmailHead.vue';
|
import ReplyEmailHead from './ReplyEmailHead.vue';
|
||||||
import ReplyBottomPanel from 'dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue';
|
import ReplyBottomPanel from 'dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue';
|
||||||
|
import MessageSignatureMissingAlert from './MessageSignatureMissingAlert';
|
||||||
import Banner from 'dashboard/components/ui/Banner.vue';
|
import Banner from 'dashboard/components/ui/Banner.vue';
|
||||||
import { REPLY_EDITOR_MODES } from 'dashboard/components/widgets/WootWriter/constants';
|
import { REPLY_EDITOR_MODES } from 'dashboard/components/widgets/WootWriter/constants';
|
||||||
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor.vue';
|
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor.vue';
|
||||||
@@ -171,7 +164,6 @@ import { buildHotKeys } from 'shared/helpers/KeyboardHelpers';
|
|||||||
import { MESSAGE_MAX_LENGTH } from 'shared/helpers/MessageTypeHelper';
|
import { MESSAGE_MAX_LENGTH } from 'shared/helpers/MessageTypeHelper';
|
||||||
import inboxMixin from 'shared/mixins/inboxMixin';
|
import inboxMixin from 'shared/mixins/inboxMixin';
|
||||||
import uiSettingsMixin from 'dashboard/mixins/uiSettings';
|
import uiSettingsMixin from 'dashboard/mixins/uiSettings';
|
||||||
import { frontendURL } from '../../../helper/URLHelper';
|
|
||||||
import { trimContent, debounce } from '@chatwoot/utils';
|
import { trimContent, debounce } from '@chatwoot/utils';
|
||||||
import wootConstants from 'dashboard/constants/globals';
|
import wootConstants from 'dashboard/constants/globals';
|
||||||
import { isEditorHotKeyEnabled } from 'dashboard/mixins/uiSettings';
|
import { isEditorHotKeyEnabled } from 'dashboard/mixins/uiSettings';
|
||||||
@@ -200,6 +192,7 @@ export default {
|
|||||||
WootAudioRecorder,
|
WootAudioRecorder,
|
||||||
Banner,
|
Banner,
|
||||||
WhatsappTemplates,
|
WhatsappTemplates,
|
||||||
|
MessageSignatureMissingAlert,
|
||||||
},
|
},
|
||||||
mixins: [
|
mixins: [
|
||||||
clickaway,
|
clickaway,
|
||||||
@@ -480,9 +473,6 @@ export default {
|
|||||||
const { send_with_signature: isEnabled } = this.uiSettings;
|
const { send_with_signature: isEnabled } = this.uiSettings;
|
||||||
return isEnabled;
|
return isEnabled;
|
||||||
},
|
},
|
||||||
profilePath() {
|
|
||||||
return frontendURL(`accounts/${this.accountId}/profile/settings`);
|
|
||||||
},
|
|
||||||
editorMessageKey() {
|
editorMessageKey() {
|
||||||
const { editor_message_key: isEnabled } = this.uiSettings;
|
const { editor_message_key: isEnabled } = this.uiSettings;
|
||||||
return isEnabled;
|
return isEnabled;
|
||||||
@@ -565,7 +555,7 @@ export default {
|
|||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getFromDraft();
|
this.getFromDraft();
|
||||||
// Donot use the keyboard listener mixin here as the events here are supposed to be
|
// Don't use the keyboard listener mixin here as the events here are supposed to be
|
||||||
// working even if input/textarea is focussed.
|
// working even if input/textarea is focussed.
|
||||||
document.addEventListener('paste', this.onPaste);
|
document.addEventListener('paste', this.onPaste);
|
||||||
document.addEventListener('keydown', this.handleKeyEvents);
|
document.addEventListener('keydown', this.handleKeyEvents);
|
||||||
@@ -1083,14 +1073,6 @@ export default {
|
|||||||
@apply py-2;
|
@apply py-2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-signature-wrap {
|
|
||||||
@apply my-0 mx-4 px-1 flex max-h-[8vh] items-baseline justify-between hover:bg-slate-25 dark:hover:bg-slate-800 border border-dashed border-slate-100 dark:border-slate-700 rounded-sm overflow-auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-signature {
|
|
||||||
@apply w-fit m-0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.attachment-preview-box {
|
.attachment-preview-box {
|
||||||
@apply bg-transparent py-0 px-4;
|
@apply bg-transparent py-0 px-4;
|
||||||
}
|
}
|
||||||
@@ -1136,13 +1118,6 @@ export default {
|
|||||||
@apply left-1 -bottom-2;
|
@apply left-1 -bottom-2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.message-signature {
|
|
||||||
@apply mb-0;
|
|
||||||
|
|
||||||
::v-deep p:last-child {
|
|
||||||
@apply mb-0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.normal-editor__canned-box {
|
.normal-editor__canned-box {
|
||||||
width: calc(100% - 2 * var(--space-normal));
|
width: calc(100% - 2 * var(--space-normal));
|
||||||
|
|||||||
@@ -111,10 +111,30 @@
|
|||||||
class="message-editor"
|
class="message-editor"
|
||||||
:class="{ editor_warning: $v.message.$error }"
|
:class="{ editor_warning: $v.message.$error }"
|
||||||
:enable-variables="true"
|
:enable-variables="true"
|
||||||
|
:signature="signatureToApply"
|
||||||
|
:allow-signature="true"
|
||||||
:placeholder="$t('NEW_CONVERSATION.FORM.MESSAGE.PLACEHOLDER')"
|
:placeholder="$t('NEW_CONVERSATION.FORM.MESSAGE.PLACEHOLDER')"
|
||||||
@toggle-canned-menu="toggleCannedMenu"
|
@toggle-canned-menu="toggleCannedMenu"
|
||||||
@blur="$v.message.$touch"
|
@blur="$v.message.$touch"
|
||||||
/>
|
>
|
||||||
|
<template #footer>
|
||||||
|
<message-signature-missing-alert
|
||||||
|
v-if="isSignatureEnabledForInbox && !messageSignature"
|
||||||
|
class="!mx-0 mb-1"
|
||||||
|
/>
|
||||||
|
<div v-if="isAnEmailInbox" class="mb-3 mt-px">
|
||||||
|
<woot-button
|
||||||
|
v-tooltip.top-end="signatureToggleTooltip"
|
||||||
|
icon="signature"
|
||||||
|
color-scheme="secondary"
|
||||||
|
variant="smooth"
|
||||||
|
size="small"
|
||||||
|
:title="signatureToggleTooltip"
|
||||||
|
@click.prevent="toggleMessageSignature"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</woot-message-editor>
|
||||||
<span v-if="$v.message.$error" class="editor-warning__message">
|
<span v-if="$v.message.$error" class="editor-warning__message">
|
||||||
{{ $t('NEW_CONVERSATION.FORM.MESSAGE.ERROR') }}
|
{{ $t('NEW_CONVERSATION.FORM.MESSAGE.ERROR') }}
|
||||||
</span>
|
</span>
|
||||||
@@ -162,6 +182,7 @@ import Thumbnail from 'dashboard/components/widgets/Thumbnail.vue';
|
|||||||
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor.vue';
|
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor.vue';
|
||||||
import ReplyEmailHead from 'dashboard/components/widgets/conversation/ReplyEmailHead.vue';
|
import ReplyEmailHead from 'dashboard/components/widgets/conversation/ReplyEmailHead.vue';
|
||||||
import CannedResponse from 'dashboard/components/widgets/conversation/CannedResponse.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 InboxDropdownItem from 'dashboard/components/widgets/InboxDropdownItem.vue';
|
||||||
import WhatsappTemplates from './WhatsappTemplates.vue';
|
import WhatsappTemplates from './WhatsappTemplates.vue';
|
||||||
import alertMixin from 'shared/mixins/alertMixin';
|
import alertMixin from 'shared/mixins/alertMixin';
|
||||||
@@ -169,6 +190,11 @@ import { INBOX_TYPES } from 'shared/mixins/inboxMixin';
|
|||||||
import { ExceptionWithMessage } from 'shared/helpers/CustomErrors';
|
import { ExceptionWithMessage } from 'shared/helpers/CustomErrors';
|
||||||
import { getInboxSource } from 'dashboard/helper/inbox';
|
import { getInboxSource } from 'dashboard/helper/inbox';
|
||||||
import { required, requiredIf } from 'vuelidate/lib/validators';
|
import { required, requiredIf } from 'vuelidate/lib/validators';
|
||||||
|
import {
|
||||||
|
appendSignature,
|
||||||
|
removeSignature,
|
||||||
|
} from 'dashboard/helper/editorHelper';
|
||||||
|
import uiSettingsMixin from 'dashboard/mixins/uiSettings';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -178,8 +204,9 @@ export default {
|
|||||||
CannedResponse,
|
CannedResponse,
|
||||||
WhatsappTemplates,
|
WhatsappTemplates,
|
||||||
InboxDropdownItem,
|
InboxDropdownItem,
|
||||||
|
MessageSignatureMissingAlert,
|
||||||
},
|
},
|
||||||
mixins: [alertMixin],
|
mixins: [alertMixin, uiSettingsMixin],
|
||||||
props: {
|
props: {
|
||||||
contact: {
|
contact: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -219,7 +246,15 @@ export default {
|
|||||||
uiFlags: 'contacts/getUIFlags',
|
uiFlags: 'contacts/getUIFlags',
|
||||||
conversationsUiFlags: 'contactConversations/getUIFlags',
|
conversationsUiFlags: 'contactConversations/getUIFlags',
|
||||||
currentUser: 'getCurrentUser',
|
currentUser: 'getCurrentUser',
|
||||||
|
messageSignature: 'getMessageSignature',
|
||||||
}),
|
}),
|
||||||
|
sendWithSignature() {
|
||||||
|
const { send_with_signature: isEnabled } = this.uiSettings;
|
||||||
|
return isEnabled;
|
||||||
|
},
|
||||||
|
signatureToApply() {
|
||||||
|
return this.messageSignature;
|
||||||
|
},
|
||||||
emailMessagePayload() {
|
emailMessagePayload() {
|
||||||
const payload = {
|
const payload = {
|
||||||
inboxId: this.targetInbox.id,
|
inboxId: this.targetInbox.id,
|
||||||
@@ -259,6 +294,14 @@ export default {
|
|||||||
}
|
}
|
||||||
return this.inboxes.length === 0 && !this.uiFlags.isFetchingInboxes;
|
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() {
|
inboxes() {
|
||||||
const inboxList = this.contact.contactableInboxes || [];
|
const inboxList = this.contact.contactableInboxes || [];
|
||||||
return inboxList.map(inbox => ({
|
return inboxList.map(inbox => ({
|
||||||
@@ -298,8 +341,23 @@ export default {
|
|||||||
this.showCannedResponseMenu = false;
|
this.showCannedResponseMenu = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
targetInbox() {
|
||||||
|
this.setSignature();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.setSignature();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
setSignature() {
|
||||||
|
if (this.messageSignature) {
|
||||||
|
if (this.isSignatureEnabledForInbox) {
|
||||||
|
this.message = appendSignature(this.message, this.signatureToApply);
|
||||||
|
} else {
|
||||||
|
this.message = removeSignature(this.message, this.signatureToApply);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
onCancel() {
|
onCancel() {
|
||||||
this.$emit('cancel');
|
this.$emit('cancel');
|
||||||
},
|
},
|
||||||
@@ -370,6 +428,12 @@ export default {
|
|||||||
);
|
);
|
||||||
return classByType;
|
return classByType;
|
||||||
},
|
},
|
||||||
|
toggleMessageSignature() {
|
||||||
|
this.updateUISettings({
|
||||||
|
send_with_signature: !this.sendWithSignature,
|
||||||
|
});
|
||||||
|
this.setSignature();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user