feat: toggle reply to on widget based on feature flag (#8261)

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Shivam Mishra
2023-10-31 21:33:14 +05:30
committed by GitHub
parent 29f18c7f18
commit b6584ec68b
7 changed files with 25 additions and 5 deletions

View File

@@ -22,6 +22,7 @@
<drag-wrapper <drag-wrapper
class="space-y-2" class="space-y-2"
direction="right" direction="right"
:disabled="!allowReplyTo"
@dragged="toggleReply" @dragged="toggleReply"
> >
<AgentMessageBubble <AgentMessageBubble
@@ -57,6 +58,7 @@
</drag-wrapper> </drag-wrapper>
<div class="flex flex-col justify-end"> <div class="flex flex-col justify-end">
<message-reply-button <message-reply-button
v-if="allowReplyTo"
class="transition-opacity delay-75 opacity-0 group-hover:opacity-100 sm:opacity-0" class="transition-opacity delay-75 opacity-0 group-hover:opacity-100 sm:opacity-0"
@click="toggleReply" @click="toggleReply"
/> />
@@ -125,6 +127,7 @@ export default {
data() { data() {
return { return {
hasImageError: false, hasImageError: false,
allowReplyTo: window.chatwootWebChannel.allowReplyTo || false,
}; };
}, },
computed: { computed: {
@@ -214,6 +217,7 @@ export default {
}; };
}, },
hasReplyTo() { hasReplyTo() {
if (!this.allowReplyTo) return false;
return this.replyTo && (this.replyTo.content || this.replyTo.attachments); return this.replyTo && (this.replyTo.content || this.replyTo.attachments);
}, },
}, },

View File

@@ -68,6 +68,7 @@ export default {
data() { data() {
return { return {
inReplyTo: null, inReplyTo: null,
allowReplyTo: window.chatwootWebChannel.allowReplyTo || false,
}; };
}, },
computed: { computed: {
@@ -90,6 +91,8 @@ export default {
return this.currentUser && this.currentUser.email; return this.currentUser && this.currentUser.email;
}, },
hasReplyTo() { hasReplyTo() {
if (!this.allowReplyTo) return false;
return ( return (
this.inReplyTo && (this.inReplyTo.content || this.inReplyTo.attachments) this.inReplyTo && (this.inReplyTo.content || this.inReplyTo.attachments)
); );

View File

@@ -19,6 +19,10 @@ export default {
required: true, required: true,
validator: value => ['left', 'right'].includes(value), validator: value => ['left', 'right'].includes(value),
}, },
disabled: {
type: Boolean,
default: false,
},
}, },
data() { data() {
return { return {
@@ -29,9 +33,11 @@ export default {
}, },
methods: { methods: {
handleTouchStart(event) { handleTouchStart(event) {
if (this.disabled) return;
this.startX = event.touches[0].clientX; this.startX = event.touches[0].clientX;
}, },
handleTouchMove(event) { handleTouchMove(event) {
if (this.disabled) return;
const touchX = event.touches[0].clientX; const touchX = event.touches[0].clientX;
let deltaX = touchX - this.startX; let deltaX = touchX - this.startX;

View File

@@ -29,7 +29,7 @@ export default {
}, },
computed: { computed: {
replyToAttachment() { replyToAttachment() {
if (!this.inReplyTo?.attachments.length) { if (!this.inReplyTo?.attachments?.length) {
return ''; return '';
} }

View File

@@ -26,7 +26,7 @@ export default {
}, },
computed: { computed: {
replyToAttachment() { replyToAttachment() {
if (!this.replyTo?.attachments.length) { if (!this.replyTo?.attachments?.length) {
return ''; return '';
} }

View File

@@ -11,12 +11,16 @@
<div class="flex justify-end gap-1"> <div class="flex justify-end gap-1">
<div class="flex flex-col justify-end"> <div class="flex flex-col justify-end">
<message-reply-button <message-reply-button
v-if="!isInProgress && !isFailed" v-if="!isInProgress && !isFailed && allowReplyTo"
class="transition-opacity delay-75 opacity-0 group-hover:opacity-100 sm:opacity-0" class="transition-opacity delay-75 opacity-0 group-hover:opacity-100 sm:opacity-0"
@click="toggleReply" @click="toggleReply"
/> />
</div> </div>
<drag-wrapper direction="left" @dragged="toggleReply"> <drag-wrapper
direction="left"
:disabled="!allowReplyTo"
@dragged="toggleReply"
>
<user-message-bubble <user-message-bubble
v-if="showTextBubble" v-if="showTextBubble"
:message="message.content" :message="message.content"
@@ -107,6 +111,7 @@ export default {
data() { data() {
return { return {
hasImageError: false, hasImageError: false,
allowReplyTo: window.chatwootWebChannel.allowReplyTo || false,
}; };
}, },
computed: { computed: {
@@ -137,6 +142,7 @@ export default {
: this.$t('COMPONENTS.MESSAGE_BUBBLE.ERROR_MESSAGE'); : this.$t('COMPONENTS.MESSAGE_BUBBLE.ERROR_MESSAGE');
}, },
hasReplyTo() { hasReplyTo() {
if (!this.allowReplyTo) return false;
return this.replyTo && (this.replyTo.content || this.replyTo.attachments); return this.replyTo && (this.replyTo.content || this.replyTo.attachments);
}, },
}, },

View File

@@ -27,7 +27,8 @@
utcOffset: '<%= ActiveSupport::TimeZone[@web_widget.inbox.timezone].now.formatted_offset %>', utcOffset: '<%= ActiveSupport::TimeZone[@web_widget.inbox.timezone].now.formatted_offset %>',
timezone: '<%= @web_widget.inbox.timezone %>', timezone: '<%= @web_widget.inbox.timezone %>',
allowMessagesAfterResolved: <%= @web_widget.inbox.allow_messages_after_resolved %>, allowMessagesAfterResolved: <%= @web_widget.inbox.allow_messages_after_resolved %>,
disableBranding: <%= @web_widget.inbox.account.feature_enabled?('disable_branding') %> disableBranding: <%= @web_widget.inbox.account.feature_enabled?('disable_branding') %>,
allowReplyTo: <%= @web_widget.inbox.account.feature_enabled?('message_reply_to') %>
} }
window.chatwootPubsubToken = '<%= @contact_inbox.pubsub_token %>' window.chatwootPubsubToken = '<%= @contact_inbox.pubsub_token %>'
window.authToken = '<%= @token %>' window.authToken = '<%= @token %>'