mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 02:57:57 +00:00 
			
		
		
		
	 280bc58963
			
		
	
	280bc58963
	
	
	
		
			
			# Pull Request Template ### Changes includes * Update send message and add note button <img width="151" alt="image" src="https://github.com/user-attachments/assets/646d1d22-07be-4f2f-9090-6642556aa761" /> <img width="151" alt="image" src="https://github.com/user-attachments/assets/b5651420-c48b-4932-aff9-911788b9eabc" /> <img width="165" alt="image" src="https://github.com/user-attachments/assets/f1ace171-2115-4eba-9055-e568d1b73c5e" /> <img width="165" alt="image" src="https://github.com/user-attachments/assets/0c818461-ccdb-46ab-b7d3-3917e4ee4e74" /> <img width="165" alt="image" src="https://github.com/user-attachments/assets/eef1545b-1bed-47a1-8b83-ed5d5da3f24f" /> <img width="165" alt="image" src="https://github.com/user-attachments/assets/429de6e6-1263-4216-9222-4eaece95da81" /> <img width="165" alt="image" src="https://github.com/user-attachments/assets/59a69867-4da1-4695-b88c-329142a693a8" /> <img width="165" alt="image" src="https://github.com/user-attachments/assets/7114745c-836f-4c5a-b5d6-e200e1343a73" /> * Remove Unused component `AnnouncementPopup.vue` * Updated button for custom attributes in conversation sidebar. <img width="225" alt="image" src="https://github.com/user-attachments/assets/a71f6c31-aca9-4e1b-bf63-6b9d5ed183c8" /> <img width="310" alt="image" src="https://github.com/user-attachments/assets/8d847e1b-4a13-4108-a487-ce3d36257afa" /> * Update button in custom snooze modal buttons <img width="207" alt="image" src="https://github.com/user-attachments/assets/78315ce6-9734-467b-a4d3-e753d3eca384" /> * Update modal component close button <img width="80" alt="image" src="https://github.com/user-attachments/assets/643e9ef0-b781-47ce-a66b-a9ee4760c952" /> * Update AI assistant modal and AICTA modal <img width="319" alt="image" src="https://github.com/user-attachments/assets/8d0986ec-ec7a-4abb-9327-f73df8b4d942" /> <img width="565" alt="image" src="https://github.com/user-attachments/assets/1e02ddd1-7f51-4d8a-bb57-558b9a50c938" /> * Update remove attachment button <img width="301" alt="image" src="https://github.com/user-attachments/assets/90c93eee-0b4d-4839-9db5-edc4b023df4b" /> * Update the conversation header buttons <img width="256" alt="image" src="https://github.com/user-attachments/assets/abac5d7e-dd83-40ae-b548-76bbafaa2231" /> * Update the retry button in old message bubbles. --------- Co-authored-by: Pranav <pranav@chatwoot.com>
		
			
				
	
	
		
			397 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
			
		
		
	
	
			397 lines
		
	
	
		
			10 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,
 | |
| } 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,
 | |
|     },
 | |
|   },
 | |
|   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;
 | |
|     },
 | |
|     allowedFileTypes() {
 | |
|       if (this.isATwilioWhatsAppChannel) {
 | |
|         return ALLOWED_FILE_TYPES_FOR_TWILIO_WHATSAPP;
 | |
|       }
 | |
|       if (this.isALineChannel) {
 | |
|         return ALLOWED_FILE_TYPES_FOR_LINE;
 | |
|       }
 | |
|       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"
 | |
|         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-slate-900 dark:text-slate-50 bg-modal-backdrop-light dark:bg-modal-backdrop-dark"
 | |
|         >
 | |
|           <fluent-icon icon="cloud-backup" size="40" />
 | |
|           <h4 class="text-2xl break-words text-slate-900 dark:text-slate-50">
 | |
|             {{ $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 dark:bg-slate-800 bg-slate-100;
 | |
|   }
 | |
| }
 | |
| </style>
 |