* feat: add customizable signature position and separator options * fix: correct default value note for signatureSeparator and ensure reactivity * fix: correct watcher boolean conversion and add immediate ui_settings updates - Fix watchers to convert string props to boolean values for reactive refs - Add immediate event handlers for switch changes to update ui_settings in real-time - Ensure proper synchronization between switch states and user.ui_settings Co-Authored-By: cayo@fazer.ai <cayoproliveira@gmail.com> * fix: split signature content and ui_settings updates to resolve persistence bug - Use updateUISettings store action for signature_position and signature_separator - Keep updateProfile for message_signature content only - Fixes FormData serialization issue that corrupted nested ui_settings object - Add diagnostic logging to verify data flow Co-Authored-By: cayo@fazer.ai <cayoproliveira@gmail.com> * clean: remove diagnostic console logging from updateSignature method - Remove temporary console.log statements added for verification - Keep core implementation that splits signature content and ui_settings updates - Keep console.error for proper error handling with eslint-disable comment - Implementation now ready for production use Co-Authored-By: cayo@fazer.ai <cayoproliveira@gmail.com> * fix: updateUISettings call in updateSignature method * chore: move signature application to send-time and add button highlighting (#79) * fix: move signature application from editor manipulation to send-time - Remove addSignature/removeSignature/toggleSignatureInEditor from WootWriter - Remove signature logic from draft handling and canned response insertion - Apply signatures only in getMessagePayload during message sending - Add button highlighting for signature toggle when activated - Prevents signature duplication and persistence in editor content - Fixes signature position toggle bug Co-Authored-By: cayo@fazer.ai <cayoproliveira@gmail.com> * fix: escape signature separator to prevent markdown setext heading interpretation - Escape '--' separator as '\--' in appendSignature to prevent H2 heading creation - Update removeSignature to handle escaped separators correctly - Fixes signature separator being rendered as markdown instead of plain text - Refactor nested ternary to fix ESLint error Co-Authored-By: cayo@fazer.ai <cayoproliveira@gmail.com> * fix: prevent signature separator markdown interpretation in message processing - Add fix_signature_separator_markdown method to escape '--' separators - Update ensure_processed_message_content to fix separators before saving - Prevents signature separators from being interpreted as setext headings - Ensures correct message display in channels and email notifications Co-Authored-By: cayo@fazer.ai <cayoproliveira@gmail.com> * fix: update separator format to use \n--\n instead of escaping - Change separator delimiter from '\--' to '\n--\n' format - Update removeSignature function to handle new separator format correctly - Simplify message processing since separators are already properly formatted - Ensures consistent separator handling across frontend and backend Co-Authored-By: cayo@fazer.ai <cayoproliveira@gmail.com> * fix: update signature delimiter format to include extra new lines * chore: remove comment about signature application logic * refactor: remove unused method and comments related to signature separator markdown processing * chore: simplify slash command detection by using updatedMessage directly * refactor: remove signature logic from draft message handling * refactor: simplify body empty check by removing signature manipulation logic --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: cayo@fazer.ai <cayoproliveira@gmail.com> * refactor: extract signature settings logic into a separate method * fix: handle nil ui_settings in signature position and separator methods * fix: update return value of findSignatureInBody to include position information * fix: update signature handling in findSignatureInBody and related methods * fix: adjust delimiter length handling in removeSignature function * test: add cases for appending, removing, and replacing signatures with various separators * test: add cases for signature position and separator handling * test: add cases for updating signature position and separator in ui_settings * fix: correct typo in comment for findSignatureInBody function * refactor: simplify translation function calls in MessageSignature component * chore: refactoring * chore: refactor * feat: switch -> select * chore: refactor and undo changes * chore: refactor and undo changes * chore: refactor * fix: remove old select component usage * chore: remove useless style --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: gabrieljablonski <contact@gabrieljablonski.com>
409 lines
11 KiB
Vue
409 lines
11 KiB
Vue
<script>
|
|
import { ref } from 'vue';
|
|
import { useUISettings } from 'dashboard/composables/useUISettings';
|
|
import { useKeyboardEvents } from 'dashboard/composables/useKeyboardEvents';
|
|
import FileUpload from 'vue-upload-component';
|
|
import * as ActiveStorage from 'activestorage';
|
|
import inboxMixin from 'shared/mixins/inboxMixin';
|
|
import { FEATURE_FLAGS } from 'dashboard/featureFlags';
|
|
import {
|
|
ALLOWED_FILE_TYPES,
|
|
ALLOWED_FILE_TYPES_FOR_TWILIO_WHATSAPP,
|
|
ALLOWED_FILE_TYPES_FOR_LINE,
|
|
ALLOWED_FILE_TYPES_FOR_INSTAGRAM,
|
|
} from 'shared/constants/messages';
|
|
import VideoCallButton from '../VideoCallButton.vue';
|
|
import AIAssistanceButton from '../AIAssistanceButton.vue';
|
|
import { REPLY_EDITOR_MODES } from './constants';
|
|
import { mapGetters } from 'vuex';
|
|
import NextButton from 'dashboard/components-next/button/Button.vue';
|
|
|
|
export default {
|
|
name: 'ReplyBottomPanel',
|
|
components: { NextButton, FileUpload, VideoCallButton, AIAssistanceButton },
|
|
mixins: [inboxMixin],
|
|
props: {
|
|
mode: {
|
|
type: String,
|
|
default: REPLY_EDITOR_MODES.REPLY,
|
|
},
|
|
onSend: {
|
|
type: Function,
|
|
default: () => {},
|
|
},
|
|
sendButtonText: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
recordingAudioDurationText: {
|
|
type: String,
|
|
default: '00:00',
|
|
},
|
|
// inbox prop is used in /mixins/inboxMixin,
|
|
// remove this props when refactoring to composable if not needed
|
|
// eslint-disable-next-line vue/no-unused-properties
|
|
inbox: {
|
|
type: Object,
|
|
default: () => ({}),
|
|
},
|
|
showFileUpload: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
showAudioRecorder: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
onFileUpload: {
|
|
type: Function,
|
|
default: () => {},
|
|
},
|
|
toggleEmojiPicker: {
|
|
type: Function,
|
|
default: () => {},
|
|
},
|
|
toggleAudioRecorder: {
|
|
type: Function,
|
|
default: () => {},
|
|
},
|
|
toggleAudioRecorderPlayPause: {
|
|
type: Function,
|
|
default: () => {},
|
|
},
|
|
isRecordingAudio: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
recordingAudioState: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
isSendDisabled: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
showEditorToggle: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
isOnPrivateNote: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
enableMultipleFileUpload: {
|
|
type: Boolean,
|
|
default: true,
|
|
},
|
|
hasWhatsappTemplates: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
conversationId: {
|
|
type: Number,
|
|
required: true,
|
|
},
|
|
message: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
newConversationModalActive: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
portalSlug: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
conversationType: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
},
|
|
emits: [
|
|
'replaceText',
|
|
'toggleInsertArticle',
|
|
'toggleEditor',
|
|
'selectWhatsappTemplate',
|
|
],
|
|
setup() {
|
|
const { setSignatureFlagForInbox, fetchSignatureFlagFromUISettings } =
|
|
useUISettings();
|
|
|
|
const uploadRef = ref(false);
|
|
|
|
const keyboardEvents = {
|
|
'$mod+Alt+KeyA': {
|
|
action: () => {
|
|
// TODO: This is really hacky, we need to replace the file picker component with
|
|
// a custom one, where the logic and the component markup is isolated.
|
|
// Once we have the custom component, we can remove the hacky logic below.
|
|
|
|
const uploadTriggerButton = document.querySelector(
|
|
'#conversationAttachment'
|
|
);
|
|
uploadTriggerButton.click();
|
|
},
|
|
allowOnFocusedInput: true,
|
|
},
|
|
};
|
|
|
|
useKeyboardEvents(keyboardEvents);
|
|
|
|
return {
|
|
setSignatureFlagForInbox,
|
|
fetchSignatureFlagFromUISettings,
|
|
uploadRef,
|
|
};
|
|
},
|
|
computed: {
|
|
...mapGetters({
|
|
accountId: 'getCurrentAccountId',
|
|
isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount',
|
|
uiFlags: 'integrations/getUIFlags',
|
|
}),
|
|
isNote() {
|
|
return this.mode === REPLY_EDITOR_MODES.NOTE;
|
|
},
|
|
wrapClass() {
|
|
return {
|
|
'is-note-mode': this.isNote,
|
|
};
|
|
},
|
|
showAttachButton() {
|
|
return this.showFileUpload || this.isNote;
|
|
},
|
|
showAudioRecorderButton() {
|
|
if (this.isALineChannel) {
|
|
return false;
|
|
}
|
|
// Disable audio recorder for safari browser as recording is not supported
|
|
// const isSafari = /^((?!chrome|android|crios|fxios).)*safari/i.test(
|
|
// navigator.userAgent
|
|
// );
|
|
|
|
return (
|
|
this.isFeatureEnabledonAccount(
|
|
this.accountId,
|
|
FEATURE_FLAGS.VOICE_RECORDER
|
|
) && this.showAudioRecorder
|
|
// !isSafari
|
|
);
|
|
},
|
|
showAudioPlayStopButton() {
|
|
return this.showAudioRecorder && this.isRecordingAudio;
|
|
},
|
|
isInstagramDM() {
|
|
return this.conversationType === 'instagram_direct_message';
|
|
},
|
|
allowedFileTypes() {
|
|
if (this.isATwilioWhatsAppChannel) {
|
|
return ALLOWED_FILE_TYPES_FOR_TWILIO_WHATSAPP;
|
|
}
|
|
if (this.isALineChannel) {
|
|
return ALLOWED_FILE_TYPES_FOR_LINE;
|
|
}
|
|
if (this.isAnInstagramChannel || this.isInstagramDM) {
|
|
return ALLOWED_FILE_TYPES_FOR_INSTAGRAM;
|
|
}
|
|
|
|
return ALLOWED_FILE_TYPES;
|
|
},
|
|
enableDragAndDrop() {
|
|
return !this.newConversationModalActive;
|
|
},
|
|
audioRecorderPlayStopIcon() {
|
|
switch (this.recordingAudioState) {
|
|
// playing paused recording stopped inactive destroyed
|
|
case 'playing':
|
|
return 'i-ph-pause';
|
|
case 'paused':
|
|
return 'i-ph-play';
|
|
case 'stopped':
|
|
return 'i-ph-play';
|
|
default:
|
|
return 'i-ph-stop';
|
|
}
|
|
},
|
|
showMessageSignatureButton() {
|
|
return !this.isOnPrivateNote;
|
|
},
|
|
sendWithSignature() {
|
|
// channelType is sourced from inboxMixin
|
|
return this.fetchSignatureFlagFromUISettings(this.channelType);
|
|
},
|
|
signatureToggleTooltip() {
|
|
return this.sendWithSignature
|
|
? this.$t('CONVERSATION.FOOTER.DISABLE_SIGN_TOOLTIP')
|
|
: this.$t('CONVERSATION.FOOTER.ENABLE_SIGN_TOOLTIP');
|
|
},
|
|
enableInsertArticleInReply() {
|
|
return this.portalSlug;
|
|
},
|
|
isFetchingAppIntegrations() {
|
|
return this.uiFlags.isFetching;
|
|
},
|
|
},
|
|
mounted() {
|
|
ActiveStorage.start();
|
|
},
|
|
methods: {
|
|
toggleMessageSignature() {
|
|
this.setSignatureFlagForInbox(this.channelType, !this.sendWithSignature);
|
|
},
|
|
replaceText(text) {
|
|
this.$emit('replaceText', text);
|
|
},
|
|
toggleInsertArticle() {
|
|
this.$emit('toggleInsertArticle');
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div class="flex justify-between p-3" :class="wrapClass">
|
|
<div class="left-wrap">
|
|
<NextButton
|
|
v-tooltip.top-end="$t('CONVERSATION.REPLYBOX.TIP_EMOJI_ICON')"
|
|
icon="i-ph-smiley-sticker"
|
|
slate
|
|
faded
|
|
sm
|
|
@click="toggleEmojiPicker"
|
|
/>
|
|
<FileUpload
|
|
ref="uploadRef"
|
|
v-tooltip.top-end="$t('CONVERSATION.REPLYBOX.TIP_ATTACH_ICON')"
|
|
input-id="conversationAttachment"
|
|
:size="4096 * 4096"
|
|
:accept="allowedFileTypes"
|
|
:multiple="enableMultipleFileUpload"
|
|
:drop="enableDragAndDrop"
|
|
:drop-directory="false"
|
|
:data="{
|
|
direct_upload_url: '/rails/active_storage/direct_uploads',
|
|
direct_upload: true,
|
|
}"
|
|
@input-file="onFileUpload"
|
|
>
|
|
<NextButton
|
|
v-if="showAttachButton"
|
|
v-tooltip.top-end="$t('CONVERSATION.REPLYBOX.TIP_ATTACH_ICON')"
|
|
icon="i-ph-paperclip"
|
|
slate
|
|
faded
|
|
sm
|
|
/>
|
|
</FileUpload>
|
|
<NextButton
|
|
v-if="showAudioRecorderButton"
|
|
v-tooltip.top-end="$t('CONVERSATION.REPLYBOX.TIP_AUDIORECORDER_ICON')"
|
|
:icon="!isRecordingAudio ? 'i-ph-microphone' : 'i-ph-microphone-slash'"
|
|
slate
|
|
faded
|
|
sm
|
|
@click="toggleAudioRecorder"
|
|
/>
|
|
<NextButton
|
|
v-if="showEditorToggle"
|
|
v-tooltip.top-end="$t('CONVERSATION.REPLYBOX.TIP_FORMAT_ICON')"
|
|
icon="i-ph-quotes"
|
|
slate
|
|
faded
|
|
sm
|
|
@click="$emit('toggleEditor')"
|
|
/>
|
|
<NextButton
|
|
v-if="showAudioPlayStopButton"
|
|
v-tooltip.top-end="$t('CONVERSATION.REPLYBOX.TIP_FORMAT_ICON')"
|
|
:icon="audioRecorderPlayStopIcon"
|
|
slate
|
|
faded
|
|
sm
|
|
:label="recordingAudioDurationText"
|
|
@click="toggleAudioRecorderPlayPause"
|
|
/>
|
|
<NextButton
|
|
v-if="showMessageSignatureButton"
|
|
v-tooltip.top-end="signatureToggleTooltip"
|
|
icon="i-ph-signature"
|
|
:color="sendWithSignature ? 'blue' : 'slate'"
|
|
faded
|
|
sm
|
|
@click="toggleMessageSignature"
|
|
/>
|
|
<NextButton
|
|
v-if="hasWhatsappTemplates"
|
|
v-tooltip.top-end="$t('CONVERSATION.FOOTER.WHATSAPP_TEMPLATES')"
|
|
icon="i-ph-whatsapp-logo"
|
|
slate
|
|
faded
|
|
sm
|
|
@click="$emit('selectWhatsappTemplate')"
|
|
/>
|
|
<VideoCallButton
|
|
v-if="(isAWebWidgetInbox || isAPIInbox) && !isOnPrivateNote"
|
|
:conversation-id="conversationId"
|
|
/>
|
|
<AIAssistanceButton
|
|
v-if="!isFetchingAppIntegrations"
|
|
:conversation-id="conversationId"
|
|
:is-private-note="isOnPrivateNote"
|
|
:message="message"
|
|
@replace-text="replaceText"
|
|
/>
|
|
<transition name="modal-fade">
|
|
<div
|
|
v-show="uploadRef && uploadRef.dropActive"
|
|
class="fixed top-0 bottom-0 left-0 right-0 z-20 flex flex-col items-center justify-center w-full h-full gap-2 text-n-slate-12 bg-modal-backdrop-light dark:bg-modal-backdrop-dark"
|
|
>
|
|
<fluent-icon icon="cloud-backup" size="40" />
|
|
<h4 class="text-2xl break-words text-n-slate-12">
|
|
{{ $t('CONVERSATION.REPLYBOX.DRAG_DROP') }}
|
|
</h4>
|
|
</div>
|
|
</transition>
|
|
<NextButton
|
|
v-if="enableInsertArticleInReply"
|
|
v-tooltip.top-end="$t('HELP_CENTER.ARTICLE_SEARCH.OPEN_ARTICLE_SEARCH')"
|
|
icon="i-ph-article-ny-times"
|
|
slate
|
|
faded
|
|
sm
|
|
@click="toggleInsertArticle"
|
|
/>
|
|
</div>
|
|
<div class="right-wrap">
|
|
<NextButton
|
|
:label="sendButtonText"
|
|
type="submit"
|
|
sm
|
|
:color="isNote ? 'amber' : 'blue'"
|
|
:disabled="isSendDisabled"
|
|
class="flex-shrink-0"
|
|
@click="onSend"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
.left-wrap {
|
|
@apply items-center flex gap-2;
|
|
}
|
|
|
|
.right-wrap {
|
|
@apply flex;
|
|
}
|
|
|
|
::v-deep .file-uploads {
|
|
label {
|
|
@apply cursor-pointer;
|
|
}
|
|
|
|
&:hover button {
|
|
@apply enabled:bg-n-slate-9/20;
|
|
}
|
|
}
|
|
</style>
|