2021-01-13 12:36:25 +00:00
|
|
|
<template>
|
|
|
|
<div class="bottom-box" :class="wrapClass">
|
|
|
|
<div class="left-wrap">
|
2021-06-09 08:31:43 +00:00
|
|
|
<woot-button
|
2022-02-15 05:08:24 +00:00
|
|
|
v-tooltip.top-end="$t('CONVERSATION.REPLYBOX.TIP_EMOJI_ICON')"
|
2021-01-18 05:50:19 +00:00
|
|
|
:title="$t('CONVERSATION.REPLYBOX.TIP_EMOJI_ICON')"
|
2021-12-01 05:03:18 +00:00
|
|
|
icon="emoji"
|
2021-06-09 08:31:43 +00:00
|
|
|
emoji="😊"
|
|
|
|
color-scheme="secondary"
|
|
|
|
variant="smooth"
|
|
|
|
size="small"
|
2021-01-18 05:50:19 +00:00
|
|
|
@click="toggleEmojiPicker"
|
2021-06-09 08:31:43 +00:00
|
|
|
/>
|
chore: Security Improvements to the API (#2893)
- Devise auth tokens are reset on password update
- Avatar attachment file type is limited to jpeg,gif and png
- Avatar attachment file size is limited to 15 mb
- Widget Message attachments are limited to types ['image/png', 'image/jpeg', 'image/gif', 'image/bmp', 'image/tiff', 'application/pdf', 'audio/mpeg', 'video/mp4', 'audio/ogg', 'text/csv']
- Widget Message attachments are limited to 40Mb size limit.
2021-09-01 09:38:05 +00:00
|
|
|
<!-- ensure the same validations for attachment types are implemented in backend models as well -->
|
2021-06-09 08:31:43 +00:00
|
|
|
<file-upload
|
2021-06-30 15:02:17 +00:00
|
|
|
ref="upload"
|
2022-02-15 05:08:24 +00:00
|
|
|
v-tooltip.top-end="$t('CONVERSATION.REPLYBOX.TIP_ATTACH_ICON')"
|
2021-06-09 08:31:43 +00:00
|
|
|
:size="4096 * 4096"
|
2021-12-20 18:20:37 +00:00
|
|
|
:accept="allowedFileTypes"
|
2022-01-25 02:46:58 +00:00
|
|
|
:multiple="enableMultipleFileUpload"
|
2021-06-30 15:02:17 +00:00
|
|
|
:drop="true"
|
|
|
|
:drop-directory="false"
|
2022-02-01 06:55:51 +00:00
|
|
|
:data="{
|
|
|
|
direct_upload_url: '/rails/active_storage/direct_uploads',
|
|
|
|
direct_upload: true,
|
|
|
|
}"
|
2022-02-15 10:46:54 +00:00
|
|
|
@input-file="onFileUpload"
|
2021-01-18 05:50:19 +00:00
|
|
|
>
|
2021-06-09 08:31:43 +00:00
|
|
|
<woot-button
|
|
|
|
v-if="showAttachButton"
|
|
|
|
class-names="button--upload"
|
|
|
|
:title="$t('CONVERSATION.REPLYBOX.TIP_ATTACH_ICON')"
|
2021-12-01 05:03:18 +00:00
|
|
|
icon="attach"
|
2021-06-09 08:31:43 +00:00
|
|
|
emoji="📎"
|
|
|
|
color-scheme="secondary"
|
|
|
|
variant="smooth"
|
|
|
|
size="small"
|
|
|
|
/>
|
|
|
|
</file-upload>
|
|
|
|
<woot-button
|
2021-01-26 18:34:11 +00:00
|
|
|
v-if="enableRichEditor && !isOnPrivateNote"
|
2022-02-15 05:08:24 +00:00
|
|
|
v-tooltip.top-end="$t('CONVERSATION.REPLYBOX.TIP_FORMAT_ICON')"
|
2021-12-01 05:03:18 +00:00
|
|
|
icon="quote"
|
2021-06-09 08:31:43 +00:00
|
|
|
emoji="🖊️"
|
|
|
|
color-scheme="secondary"
|
|
|
|
variant="smooth"
|
|
|
|
size="small"
|
2021-01-18 05:50:19 +00:00
|
|
|
:title="$t('CONVERSATION.REPLYBOX.TIP_FORMAT_ICON')"
|
|
|
|
@click="toggleFormatMode"
|
2021-06-09 08:31:43 +00:00
|
|
|
/>
|
2022-03-04 14:13:07 +00:00
|
|
|
<woot-button
|
|
|
|
v-if="showAudioRecorderButton"
|
|
|
|
:icon="!isRecordingAudio ? 'microphone' : 'microphone-off'"
|
|
|
|
emoji="🎤"
|
|
|
|
:color-scheme="!isRecordingAudio ? 'secondary' : 'alert'"
|
|
|
|
variant="smooth"
|
|
|
|
size="small"
|
|
|
|
:title="$t('CONVERSATION.REPLYBOX.TIP_AUDIORECORDER_ICON')"
|
|
|
|
@click="toggleAudioRecorder"
|
|
|
|
/>
|
|
|
|
<woot-button
|
|
|
|
v-if="showAudioPlayStopButton"
|
|
|
|
:icon="audioRecorderPlayStopIcon"
|
|
|
|
emoji="🎤"
|
|
|
|
color-scheme="secondary"
|
|
|
|
variant="smooth"
|
|
|
|
size="small"
|
|
|
|
@click="toggleAudioRecorderPlayPause"
|
|
|
|
>
|
|
|
|
<span>{{ recordingAudioDurationText }}</span>
|
|
|
|
</woot-button>
|
2022-02-15 05:08:24 +00:00
|
|
|
<woot-button
|
|
|
|
v-if="showMessageSignatureButton"
|
|
|
|
v-tooltip.top-end="signatureToggleTooltip"
|
|
|
|
icon="signature"
|
|
|
|
color-scheme="secondary"
|
|
|
|
variant="smooth"
|
|
|
|
size="small"
|
|
|
|
:title="signatureToggleTooltip"
|
|
|
|
@click="toggleMessageSignature"
|
|
|
|
/>
|
2022-06-07 12:03:33 +00:00
|
|
|
<woot-button
|
2022-06-14 12:35:37 +00:00
|
|
|
v-if="hasWhatsappTemplates"
|
2022-06-07 12:03:33 +00:00
|
|
|
v-tooltip.top-end="'Whatsapp Templates'"
|
|
|
|
icon="whatsapp"
|
|
|
|
color-scheme="secondary"
|
|
|
|
variant="smooth"
|
|
|
|
size="small"
|
|
|
|
:title="'Whatsapp Templates'"
|
|
|
|
@click="$emit('selectWhatsappTemplate')"
|
|
|
|
/>
|
2021-06-30 15:02:17 +00:00
|
|
|
<transition name="modal-fade">
|
|
|
|
<div
|
|
|
|
v-show="$refs.upload && $refs.upload.dropActive"
|
|
|
|
class="modal-mask"
|
|
|
|
>
|
2021-12-01 05:03:18 +00:00
|
|
|
<fluent-icon icon="cloud-backup" />
|
2021-06-30 15:02:17 +00:00
|
|
|
<h4 class="page-sub-title">
|
|
|
|
{{ $t('CONVERSATION.REPLYBOX.DRAG_DROP') }}
|
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
</transition>
|
2021-01-13 12:36:25 +00:00
|
|
|
</div>
|
|
|
|
<div class="right-wrap">
|
2021-01-19 13:58:40 +00:00
|
|
|
<div v-if="isFormatMode" class="enter-to-send--checkbox">
|
|
|
|
<input
|
|
|
|
:checked="enterToSendEnabled"
|
|
|
|
type="checkbox"
|
|
|
|
value="enterToSend"
|
|
|
|
@input="toggleEnterToSend"
|
|
|
|
/>
|
|
|
|
<label for="enterToSend">
|
|
|
|
{{ $t('CONVERSATION.REPLYBOX.ENTER_TO_SEND') }}
|
|
|
|
</label>
|
|
|
|
</div>
|
2021-06-09 08:31:43 +00:00
|
|
|
<woot-button
|
|
|
|
size="small"
|
|
|
|
:class-names="buttonClass"
|
|
|
|
:is-disabled="isSendDisabled"
|
2021-01-13 12:36:25 +00:00
|
|
|
@click="onSend"
|
|
|
|
>
|
|
|
|
{{ sendButtonText }}
|
2021-06-09 08:31:43 +00:00
|
|
|
</woot-button>
|
2021-01-13 12:36:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import FileUpload from 'vue-upload-component';
|
2022-02-01 06:55:51 +00:00
|
|
|
import * as ActiveStorage from 'activestorage';
|
2021-08-09 07:38:52 +00:00
|
|
|
import {
|
|
|
|
hasPressedAltAndWKey,
|
|
|
|
hasPressedAltAndAKey,
|
|
|
|
} from 'shared/helpers/KeyboardHelpers';
|
|
|
|
import eventListenerMixins from 'shared/mixins/eventListenerMixins';
|
2022-02-15 05:08:24 +00:00
|
|
|
import uiSettingsMixin from 'dashboard/mixins/uiSettings';
|
|
|
|
import inboxMixin from 'shared/mixins/inboxMixin';
|
|
|
|
|
2021-12-20 18:20:37 +00:00
|
|
|
import { ALLOWED_FILE_TYPES } from 'shared/constants/messages';
|
2021-01-13 12:36:25 +00:00
|
|
|
|
|
|
|
import { REPLY_EDITOR_MODES } from './constants';
|
|
|
|
export default {
|
2022-02-25 11:06:10 +00:00
|
|
|
name: 'ReplyBottomPanel',
|
2021-06-09 08:31:43 +00:00
|
|
|
components: { FileUpload },
|
2022-02-15 05:08:24 +00:00
|
|
|
mixins: [eventListenerMixins, uiSettingsMixin, inboxMixin],
|
2021-01-13 12:36:25 +00:00
|
|
|
props: {
|
|
|
|
mode: {
|
|
|
|
type: String,
|
|
|
|
default: REPLY_EDITOR_MODES.REPLY,
|
|
|
|
},
|
|
|
|
onSend: {
|
|
|
|
type: Function,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
sendButtonText: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
2022-03-04 14:13:07 +00:00
|
|
|
recordingAudioDurationText: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
2022-02-15 05:08:24 +00:00
|
|
|
inbox: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
2021-01-13 12:36:25 +00:00
|
|
|
showFileUpload: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2022-03-04 14:13:07 +00:00
|
|
|
showAudioRecorder: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2022-02-15 10:46:54 +00:00
|
|
|
onFileUpload: {
|
2021-01-13 12:36:25 +00:00
|
|
|
type: Function,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
showEmojiPicker: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
toggleEmojiPicker: {
|
|
|
|
type: Function,
|
|
|
|
default: () => {},
|
|
|
|
},
|
2022-03-04 14:13:07 +00:00
|
|
|
toggleAudioRecorder: {
|
|
|
|
type: Function,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
toggleAudioRecorderPlayPause: {
|
|
|
|
type: Function,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
isRecordingAudio: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
recordingAudioState: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
2021-01-13 12:36:25 +00:00
|
|
|
isSendDisabled: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-01-18 05:50:19 +00:00
|
|
|
setFormatMode: {
|
|
|
|
type: Function,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
isFormatMode: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-01-26 18:34:11 +00:00
|
|
|
isOnPrivateNote: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-01-18 05:50:19 +00:00
|
|
|
enableRichEditor: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-01-19 13:58:40 +00:00
|
|
|
enterToSendEnabled: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
},
|
2022-01-25 02:46:58 +00:00
|
|
|
enableMultipleFileUpload: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
},
|
2022-06-07 12:03:33 +00:00
|
|
|
hasWhatsappTemplates: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-01-13 12:36:25 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isNote() {
|
|
|
|
return this.mode === REPLY_EDITOR_MODES.NOTE;
|
|
|
|
},
|
|
|
|
wrapClass() {
|
|
|
|
return {
|
|
|
|
'is-note-mode': this.isNote,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
buttonClass() {
|
|
|
|
return {
|
2021-06-09 08:31:43 +00:00
|
|
|
warning: this.isNote,
|
2021-01-13 12:36:25 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
showAttachButton() {
|
|
|
|
return this.showFileUpload || this.isNote;
|
|
|
|
},
|
2022-03-04 14:13:07 +00:00
|
|
|
showAudioRecorderButton() {
|
|
|
|
return this.showAudioRecorder;
|
|
|
|
},
|
|
|
|
showAudioPlayStopButton() {
|
|
|
|
return this.showAudioRecorder && this.isRecordingAudio;
|
|
|
|
},
|
2021-12-20 18:20:37 +00:00
|
|
|
allowedFileTypes() {
|
|
|
|
return ALLOWED_FILE_TYPES;
|
|
|
|
},
|
2022-03-04 14:13:07 +00:00
|
|
|
audioRecorderPlayStopIcon() {
|
|
|
|
switch (this.recordingAudioState) {
|
|
|
|
// playing paused recording stopped inactive destroyed
|
|
|
|
case 'playing':
|
|
|
|
return 'microphone-pause';
|
|
|
|
case 'paused':
|
|
|
|
return 'microphone-play';
|
|
|
|
case 'stopped':
|
|
|
|
return 'microphone-play';
|
|
|
|
default:
|
|
|
|
return 'microphone-stop';
|
|
|
|
}
|
|
|
|
},
|
2022-02-15 05:08:24 +00:00
|
|
|
showMessageSignatureButton() {
|
|
|
|
return !this.isPrivate && this.isAnEmailChannel;
|
|
|
|
},
|
|
|
|
sendWithSignature() {
|
|
|
|
const { send_with_signature: isEnabled } = this.uiSettings;
|
|
|
|
return isEnabled;
|
|
|
|
},
|
|
|
|
signatureToggleTooltip() {
|
|
|
|
return this.sendWithSignature
|
|
|
|
? this.$t('CONVERSATION.FOOTER.DISABLE_SIGN_TOOLTIP')
|
|
|
|
: this.$t('CONVERSATION.FOOTER.ENABLE_SIGN_TOOLTIP');
|
|
|
|
},
|
2021-01-13 12:36:25 +00:00
|
|
|
},
|
2022-02-01 06:55:51 +00:00
|
|
|
mounted() {
|
|
|
|
ActiveStorage.start();
|
|
|
|
},
|
2021-01-18 05:50:19 +00:00
|
|
|
methods: {
|
2021-08-09 07:38:52 +00:00
|
|
|
handleKeyEvents(e) {
|
|
|
|
if (hasPressedAltAndWKey(e)) {
|
|
|
|
this.toggleFormatMode();
|
|
|
|
}
|
|
|
|
if (hasPressedAltAndAKey(e)) {
|
|
|
|
this.$refs.upload.$children[1].$el.click();
|
|
|
|
}
|
|
|
|
},
|
2021-01-18 05:50:19 +00:00
|
|
|
toggleFormatMode() {
|
|
|
|
this.setFormatMode(!this.isFormatMode);
|
|
|
|
},
|
2021-01-19 13:58:40 +00:00
|
|
|
toggleEnterToSend() {
|
|
|
|
this.$emit('toggleEnterToSend', !this.enterToSendEnabled);
|
|
|
|
},
|
2022-02-15 05:08:24 +00:00
|
|
|
toggleMessageSignature() {
|
|
|
|
this.updateUISettings({
|
|
|
|
send_with_signature: !this.sendWithSignature,
|
|
|
|
});
|
|
|
|
},
|
2021-01-18 05:50:19 +00:00
|
|
|
},
|
2021-01-13 12:36:25 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.bottom-box {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
padding: var(--space-slab) var(--space-normal);
|
|
|
|
|
|
|
|
&.is-note-mode {
|
|
|
|
background: var(--y-50);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-09 08:31:43 +00:00
|
|
|
.left-wrap .button {
|
|
|
|
margin-right: var(--space-small);
|
2021-01-13 12:36:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.left-wrap {
|
|
|
|
align-items: center;
|
2021-01-19 13:58:40 +00:00
|
|
|
display: flex;
|
2021-01-13 12:36:25 +00:00
|
|
|
}
|
|
|
|
|
2021-01-19 13:58:40 +00:00
|
|
|
.right-wrap {
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
.enter-to-send--checkbox {
|
|
|
|
align-items: center;
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
input {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
label {
|
|
|
|
color: var(--s-500);
|
2021-03-11 16:18:52 +00:00
|
|
|
font-size: var(--font-size-mini);
|
2021-01-19 13:58:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-09 08:31:43 +00:00
|
|
|
|
|
|
|
::v-deep .file-uploads {
|
|
|
|
label {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
&:hover .button {
|
|
|
|
background: var(--s-100);
|
|
|
|
}
|
|
|
|
}
|
2021-06-30 15:02:17 +00:00
|
|
|
|
|
|
|
.modal-mask {
|
|
|
|
color: var(--s-600);
|
|
|
|
background: var(--white-transparent);
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
|
|
|
.page-sub-title {
|
|
|
|
color: var(--s-600);
|
|
|
|
}
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
font-size: 8rem;
|
|
|
|
}
|
2021-01-13 12:36:25 +00:00
|
|
|
</style>
|