bug: Fixes Incorrect badge for Twilio SMS inbox and adds the ability to differentiate Twitter tweets and chats (#3003)
* bug: Fixes Incorrect badge in the thumbnail for Twilio SMS inbox * Minor fixes * Minor fixes * Review fixes * Minor fixes * fixes codeclimate error * Minor fixes * Minor fixes * Minor fixes * Review fixes * Minor fixes Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
parent
bba2750975
commit
a8f6eebd66
7 changed files with 151 additions and 18 deletions
BIN
app/javascript/dashboard/assets/images/twitter-chat-badge.png
Normal file
BIN
app/javascript/dashboard/assets/images/twitter-chat-badge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
|
@ -22,19 +22,33 @@
|
||||||
src="~dashboard/assets/images/fb-badge.png"
|
src="~dashboard/assets/images/fb-badge.png"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
v-if="badge === 'Channel::TwitterProfile'"
|
v-if="badge === 'twitter-tweet'"
|
||||||
id="badge"
|
id="badge"
|
||||||
class="source-badge"
|
class="source-badge"
|
||||||
:style="badgeStyle"
|
:style="badgeStyle"
|
||||||
src="~dashboard/assets/images/twitter-badge.png"
|
src="~dashboard/assets/images/twitter-badge.png"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
v-if="badge === 'Channel::TwilioSms'"
|
v-if="badge === 'twitter-chat'"
|
||||||
|
id="badge"
|
||||||
|
class="source-badge"
|
||||||
|
:style="badgeStyle"
|
||||||
|
src="~dashboard/assets/images/twitter-chat-badge.png"
|
||||||
|
/>
|
||||||
|
<img
|
||||||
|
v-if="badge === 'whatsapp'"
|
||||||
id="badge"
|
id="badge"
|
||||||
class="source-badge"
|
class="source-badge"
|
||||||
:style="badgeStyle"
|
:style="badgeStyle"
|
||||||
src="~dashboard/assets/images/channels/whatsapp.png"
|
src="~dashboard/assets/images/channels/whatsapp.png"
|
||||||
/>
|
/>
|
||||||
|
<img
|
||||||
|
v-if="badge === 'sms'"
|
||||||
|
id="badge"
|
||||||
|
class="source-badge"
|
||||||
|
:style="badgeStyle"
|
||||||
|
src="~dashboard/assets/images/channels/sms.png"
|
||||||
|
/>
|
||||||
<img
|
<img
|
||||||
v-if="badge === 'Channel::Line'"
|
v-if="badge === 'Channel::Line'"
|
||||||
id="badge"
|
id="badge"
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<Thumbnail
|
<Thumbnail
|
||||||
v-if="!hideThumbnail"
|
v-if="!hideThumbnail"
|
||||||
:src="currentContact.thumbnail"
|
:src="currentContact.thumbnail"
|
||||||
:badge="chatMetadata.channel"
|
:badge="inboxBadge"
|
||||||
class="columns"
|
class="columns"
|
||||||
:username="currentContact.name"
|
:username="currentContact.name"
|
||||||
:status="currentContact.availability_status"
|
:status="currentContact.availability_status"
|
||||||
|
@ -68,13 +68,14 @@ import conversationMixin from '../../../mixins/conversations';
|
||||||
import timeMixin from '../../../mixins/time';
|
import timeMixin from '../../../mixins/time';
|
||||||
import router from '../../../routes';
|
import router from '../../../routes';
|
||||||
import { frontendURL, conversationUrl } from '../../../helper/URLHelper';
|
import { frontendURL, conversationUrl } from '../../../helper/URLHelper';
|
||||||
|
import inboxMixin from 'shared/mixins/inboxMixin';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Thumbnail,
|
Thumbnail,
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [timeMixin, conversationMixin, messageFormatterMixin],
|
mixins: [inboxMixin, timeMixin, conversationMixin, messageFormatterMixin],
|
||||||
props: {
|
props: {
|
||||||
activeLabel: {
|
activeLabel: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -167,14 +168,14 @@ export default {
|
||||||
return this.getPlainText(subject || this.lastMessageInChat.content);
|
return this.getPlainText(subject || this.lastMessageInChat.content);
|
||||||
},
|
},
|
||||||
|
|
||||||
chatInbox() {
|
inbox() {
|
||||||
const { inbox_id: inboxId } = this.chat;
|
const { inbox_id: inboxId } = this.chat;
|
||||||
const stateInbox = this.$store.getters['inboxes/getInbox'](inboxId);
|
const stateInbox = this.$store.getters['inboxes/getInbox'](inboxId);
|
||||||
return stateInbox;
|
return stateInbox;
|
||||||
},
|
},
|
||||||
|
|
||||||
computedInboxClass() {
|
computedInboxClass() {
|
||||||
const { phone_number: phoneNumber, channel_type: type } = this.chatInbox;
|
const { phone_number: phoneNumber, channel_type: type } = this.inbox;
|
||||||
const classByType = getInboxClassByType(type, phoneNumber);
|
const classByType = getInboxClassByType(type, phoneNumber);
|
||||||
return classByType;
|
return classByType;
|
||||||
},
|
},
|
||||||
|
@ -187,11 +188,10 @@ export default {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
inboxName() {
|
inboxName() {
|
||||||
const stateInbox = this.chatInbox;
|
const stateInbox = this.inbox;
|
||||||
return stateInbox.name || '';
|
return stateInbox.name || '';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
cardClick(chat) {
|
cardClick(chat) {
|
||||||
const { activeInbox } = this;
|
const { activeInbox } = this;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<Thumbnail
|
<Thumbnail
|
||||||
:src="currentContact.thumbnail"
|
:src="currentContact.thumbnail"
|
||||||
size="40px"
|
size="40px"
|
||||||
:badge="chatMetadata.channel"
|
:badge="inboxBadge"
|
||||||
:username="currentContact.name"
|
:username="currentContact.name"
|
||||||
:status="currentContact.availability_status"
|
:status="currentContact.availability_status"
|
||||||
/>
|
/>
|
||||||
|
@ -42,6 +42,7 @@ import MoreActions from './MoreActions';
|
||||||
import Thumbnail from '../Thumbnail';
|
import Thumbnail from '../Thumbnail';
|
||||||
import agentMixin from '../../../mixins/agentMixin.js';
|
import agentMixin from '../../../mixins/agentMixin.js';
|
||||||
import eventListenerMixins from 'shared/mixins/eventListenerMixins';
|
import eventListenerMixins from 'shared/mixins/eventListenerMixins';
|
||||||
|
import inboxMixin from 'shared/mixins/inboxMixin';
|
||||||
import { hasPressedAltAndOKey } from 'shared/helpers/KeyboardHelpers';
|
import { hasPressedAltAndOKey } from 'shared/helpers/KeyboardHelpers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -49,7 +50,7 @@ export default {
|
||||||
MoreActions,
|
MoreActions,
|
||||||
Thumbnail,
|
Thumbnail,
|
||||||
},
|
},
|
||||||
mixins: [agentMixin, eventListenerMixins],
|
mixins: [inboxMixin, agentMixin, eventListenerMixins],
|
||||||
props: {
|
props: {
|
||||||
chat: {
|
chat: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
@ -78,6 +79,12 @@ export default {
|
||||||
return this.chat.meta;
|
return this.chat.meta;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
inbox() {
|
||||||
|
const { inbox_id: inboxId } = this.chat;
|
||||||
|
const stateInbox = this.$store.getters['inboxes/getInbox'](inboxId);
|
||||||
|
return stateInbox;
|
||||||
|
},
|
||||||
|
|
||||||
currentContact() {
|
currentContact() {
|
||||||
return this.$store.getters['contacts/getContact'](
|
return this.$store.getters['contacts/getContact'](
|
||||||
this.chat.meta.sender.id
|
this.chat.meta.sender.id
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
:src="selectedItem.thumbnail"
|
:src="selectedItem.thumbnail"
|
||||||
size="24px"
|
size="24px"
|
||||||
:status="selectedItem.availability_status"
|
:status="selectedItem.availability_status"
|
||||||
:badge="selectedItem.channel"
|
|
||||||
:username="selectedItem.name"
|
:username="selectedItem.name"
|
||||||
/>
|
/>
|
||||||
<div class="selector-name-wrap">
|
<div class="selector-name-wrap">
|
||||||
|
|
|
@ -36,12 +36,34 @@ export default {
|
||||||
return this.channelType === INBOX_TYPES.EMAIL;
|
return this.channelType === INBOX_TYPES.EMAIL;
|
||||||
},
|
},
|
||||||
isATwilioSMSChannel() {
|
isATwilioSMSChannel() {
|
||||||
const { phone_number: phoneNumber = '' } = this.inbox;
|
const { medium: medium = '' } = this.inbox;
|
||||||
return this.isATwilioChannel && !phoneNumber.startsWith('whatsapp');
|
return this.isATwilioChannel && medium === 'sms';
|
||||||
},
|
},
|
||||||
isATwilioWhatsappChannel() {
|
isATwilioWhatsappChannel() {
|
||||||
const { phone_number: phoneNumber = '' } = this.inbox;
|
const { medium: medium = '' } = this.inbox;
|
||||||
return this.isATwilioChannel && phoneNumber.startsWith('whatsapp');
|
return this.isATwilioChannel && medium === 'whatsapp';
|
||||||
|
},
|
||||||
|
isTwitterInboxTweet() {
|
||||||
|
return (
|
||||||
|
this.chat &&
|
||||||
|
this.chat.additional_attributes &&
|
||||||
|
this.chat.additional_attributes.type === 'tweet'
|
||||||
|
);
|
||||||
|
},
|
||||||
|
twilioBadge() {
|
||||||
|
return `${this.isATwilioSMSChannel ? 'sms' : 'whatsapp'}`;
|
||||||
|
},
|
||||||
|
twitterBadge() {
|
||||||
|
return `${this.isTwitterInboxTweet ? 'twitter-tweet' : 'twitter-chat'}`;
|
||||||
|
},
|
||||||
|
inboxBadge() {
|
||||||
|
if (this.isATwitterInbox) {
|
||||||
|
return this.twitterBadge;
|
||||||
|
}
|
||||||
|
if (this.isATwilioChannel) {
|
||||||
|
return this.twilioBadge;
|
||||||
|
}
|
||||||
|
return this.channelType;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -70,7 +70,23 @@ describe('inboxMixin', () => {
|
||||||
return {
|
return {
|
||||||
inbox: {
|
inbox: {
|
||||||
channel_type: 'Channel::TwilioSms',
|
channel_type: 'Channel::TwilioSms',
|
||||||
phone_number: '+91944444444',
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const wrapper = shallowMount(Component);
|
||||||
|
expect(wrapper.vm.isATwilioChannel).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isATwilioSMSChannel returns true if channel type is Twilio and medium is SMS', () => {
|
||||||
|
const Component = {
|
||||||
|
render() {},
|
||||||
|
mixins: [inboxMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
inbox: {
|
||||||
|
channel_type: 'Channel::TwilioSms',
|
||||||
|
medium: 'sms',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -80,7 +96,7 @@ describe('inboxMixin', () => {
|
||||||
expect(wrapper.vm.isATwilioSMSChannel).toBe(true);
|
expect(wrapper.vm.isATwilioSMSChannel).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('isATwilioWhatsappChannel returns true if channel type is Twilio and phonenumber is a whatsapp number', () => {
|
it('isATwilioWhatsappChannel returns true if channel type is Twilio and medium is whatsapp', () => {
|
||||||
const Component = {
|
const Component = {
|
||||||
render() {},
|
render() {},
|
||||||
mixins: [inboxMixin],
|
mixins: [inboxMixin],
|
||||||
|
@ -88,7 +104,7 @@ describe('inboxMixin', () => {
|
||||||
return {
|
return {
|
||||||
inbox: {
|
inbox: {
|
||||||
channel_type: 'Channel::TwilioSms',
|
channel_type: 'Channel::TwilioSms',
|
||||||
phone_number: 'whatsapp:+91944444444',
|
medium: 'whatsapp',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -111,4 +127,79 @@ describe('inboxMixin', () => {
|
||||||
const wrapper = shallowMount(Component);
|
const wrapper = shallowMount(Component);
|
||||||
expect(wrapper.vm.isAnEmailChannel).toBe(true);
|
expect(wrapper.vm.isAnEmailChannel).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('isTwitterInboxTweet returns true if Twitter channel type is tweet', () => {
|
||||||
|
const Component = {
|
||||||
|
render() {},
|
||||||
|
mixins: [inboxMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
chat: {
|
||||||
|
channel_type: 'Channel::TwitterProfile',
|
||||||
|
additional_attributes: {
|
||||||
|
type: 'tweet',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const wrapper = shallowMount(Component);
|
||||||
|
expect(wrapper.vm.isTwitterInboxTweet).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('twilioBadge returns string sms if channel type is Twilio and medium is sms', () => {
|
||||||
|
const Component = {
|
||||||
|
render() {},
|
||||||
|
mixins: [inboxMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
inbox: {
|
||||||
|
channel_type: 'Channel::TwilioSms',
|
||||||
|
medium: 'sms',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const wrapper = shallowMount(Component);
|
||||||
|
expect(wrapper.vm.isATwilioSMSChannel).toBe(true);
|
||||||
|
expect(wrapper.vm.twilioBadge).toBe('sms');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('twitterBadge returns string twitter-tweet if Twitter channel type is tweet', () => {
|
||||||
|
const Component = {
|
||||||
|
render() {},
|
||||||
|
mixins: [inboxMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
chat: {
|
||||||
|
id: 1,
|
||||||
|
additional_attributes: {
|
||||||
|
type: 'tweet',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const wrapper = shallowMount(Component);
|
||||||
|
expect(wrapper.vm.isTwitterInboxTweet).toBe(true);
|
||||||
|
expect(wrapper.vm.twitterBadge).toBe('twitter-tweet');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('inboxBadge returns string Channel::Telegram if isATwilioChannel and isATwitterInbox is false', () => {
|
||||||
|
const Component = {
|
||||||
|
render() {},
|
||||||
|
mixins: [inboxMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
inbox: {
|
||||||
|
channel_type: 'Channel::Telegram',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const wrapper = shallowMount(Component);
|
||||||
|
expect(wrapper.vm.isATwilioChannel).toBe(false);
|
||||||
|
expect(wrapper.vm.isATwitterInbox).toBe(false);
|
||||||
|
expect(wrapper.vm.channelType).toBe('Channel::Telegram');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue