Merge branch 'develop' into chore-replace-router-mixin

This commit is contained in:
Fayaz Ahmed
2024-08-21 08:28:27 +05:30
committed by GitHub
958 changed files with 6119 additions and 3128 deletions
@@ -9,7 +9,7 @@ import FileBubble from 'widget/components/FileBubble.vue';
import Thumbnail from 'dashboard/components/widgets/Thumbnail.vue';
import { MESSAGE_TYPE } from 'widget/helpers/constants';
import configMixin from '../mixins/configMixin';
import messageMixin from '../mixins/messageMixin';
import { useMessage } from '../composables/useMessage';
import { isASubmittedFormMessage } from 'shared/helpers/MessageTypeHelper';
import darkModeMixin from 'widget/mixins/darkModeMixin.js';
import ReplyToChip from 'widget/components/ReplyToChip.vue';
@@ -28,7 +28,7 @@ export default {
MessageReplyButton,
ReplyToChip,
},
mixins: [configMixin, messageMixin, darkModeMixin],
mixins: [configMixin, darkModeMixin],
props: {
message: {
type: Object,
@@ -39,6 +39,15 @@ export default {
default: () => {},
},
},
setup(props) {
const { messageContentAttributes, hasAttachments } = useMessage(
props.message
);
return {
messageContentAttributes,
hasAttachments,
};
},
data() {
return {
hasImageError: false,
@@ -6,7 +6,7 @@ import VideoBubble from 'widget/components/VideoBubble.vue';
import FluentIcon from 'shared/components/FluentIcon/Index.vue';
import FileBubble from 'widget/components/FileBubble.vue';
import { messageStamp } from 'shared/helpers/timeHelper';
import messageMixin from '../mixins/messageMixin';
import { useMessage } from '../composables/useMessage';
import ReplyToChip from 'widget/components/ReplyToChip.vue';
import DragWrapper from 'widget/components/DragWrapper.vue';
import { BUS_EVENTS } from 'shared/constants/busEvents';
@@ -25,7 +25,6 @@ export default {
ReplyToChip,
DragWrapper,
},
mixins: [messageMixin],
props: {
message: {
type: Object,
@@ -36,6 +35,12 @@ export default {
default: () => {},
},
},
setup(props) {
const { hasAttachments } = useMessage(props.message);
return {
hasAttachments,
};
},
data() {
return {
hasImageError: false,
@@ -0,0 +1,71 @@
import { describe, it, expect } from 'vitest';
import { reactive, nextTick } from 'vue';
import { useMessage } from '../useMessage';
describe('useMessage', () => {
it('should handle deleted messages', () => {
const message = reactive({
content_attributes: { deleted: true },
attachments: [],
});
const { messageContentAttributes, hasAttachments } = useMessage(message);
expect(messageContentAttributes.value).toEqual({ deleted: true });
expect(hasAttachments.value).toBe(false);
});
it('should handle non-deleted messages with attachments', () => {
const message = reactive({
content_attributes: {},
attachments: ['attachment1', 'attachment2'],
});
const { messageContentAttributes, hasAttachments } = useMessage(message);
expect(messageContentAttributes.value).toEqual({});
expect(hasAttachments.value).toBe(true);
});
it('should handle messages without content_attributes', () => {
const message = reactive({
attachments: [],
});
const { messageContentAttributes, hasAttachments } = useMessage(message);
expect(messageContentAttributes.value).toEqual({});
expect(hasAttachments.value).toBe(false);
});
it('should handle messages with empty attachments array', () => {
const message = reactive({
content_attributes: { someAttribute: 'value' },
attachments: [],
});
const { messageContentAttributes, hasAttachments } = useMessage(message);
expect(messageContentAttributes.value).toEqual({ someAttribute: 'value' });
expect(hasAttachments.value).toBe(false);
});
it('should update reactive properties when message changes', async () => {
const message = reactive({
content_attributes: {},
attachments: [],
});
const { messageContentAttributes, hasAttachments } = useMessage(message);
expect(messageContentAttributes.value).toEqual({});
expect(hasAttachments.value).toBe(false);
message.content_attributes = { updated: true };
message.attachments.push('newAttachment');
await nextTick();
expect(messageContentAttributes.value).toEqual({ updated: true });
expect(hasAttachments.value).toBe(true);
});
});
@@ -0,0 +1,22 @@
import { computed } from 'vue';
/**
* Composable for handling message-related computations.
* @param {Object} message - The message object to be processed.
* @returns {Object} An object containing computed properties for message content and attachments.
*/
export function useMessage(message) {
const messageContentAttributes = computed(() => {
const { content_attributes: attribute = {} } = message;
return attribute;
});
const hasAttachments = computed(() => {
return !!(message.attachments && message.attachments.length > 0);
});
return {
messageContentAttributes,
hasAttachments,
};
}
+7 -2
View File
@@ -70,7 +70,8 @@
"REQUIRED_ERROR": "Phone Number is required",
"DIAL_CODE_VALID_ERROR": "Please select a country code",
"VALID_ERROR": "Please enter a valid phone number",
"DROPDOWN_EMPTY": "No results found"
"DROPDOWN_EMPTY": "No results found",
"DROPDOWN_SEARCH": "Search country"
},
"MESSAGE": {
"LABEL": "Message",
@@ -91,7 +92,8 @@
},
"EMOJI": {
"PLACEHOLDER": "Search emojis",
"NOT_FOUND": "No emoji match your search"
"NOT_FOUND": "No emoji match your search",
"ARIA_LABEL": "Emoji picker"
},
"CSAT": {
"TITLE": "Rate your conversation",
@@ -133,5 +135,8 @@
"fallback": {
"CONTENT": "has shared a url"
}
},
"FOOTER_REPLY_TO": {
"REPLY_TO": "Replying to:"
}
}
+49 -49
View File
@@ -17,38 +17,38 @@
"OFFLINE": "Trenutačno nismo online"
},
"REPLY_TIME": {
"IN_A_FEW_MINUTES": "Typically replies in a few minutes",
"IN_A_FEW_HOURS": "Typically replies in a few hours",
"IN_A_DAY": "Typically replies in a day",
"BACK_IN": "We will be back online"
"IN_A_FEW_MINUTES": "Obično odgovara za nekoliko minuta",
"IN_A_FEW_HOURS": "Obično odgovara za nekoliko sati",
"IN_A_DAY": "Obično odgovara u roku jednog dana",
"BACK_IN": "Bit ćemo ponovno online"
},
"DAY_NAMES": [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
"Nedjelja",
"Ponedjeljak",
"Utorak",
"Srijeda",
"Četvrtak",
"Petak",
"Subota"
],
"START_CONVERSATION": "Start Conversation",
"END_CONVERSATION": "End Conversation",
"CONTINUE_CONVERSATION": "Continue conversation",
"YOU": "You",
"START_NEW_CONVERSATION": "Start a new conversation",
"VIEW_UNREAD_MESSAGES": "You have unread messages",
"START_CONVERSATION": "Započnite razgovor",
"END_CONVERSATION": "Završite razgovor",
"CONTINUE_CONVERSATION": "Nastavite razgovor",
"YOU": "Vi",
"START_NEW_CONVERSATION": "Započnite novi razgovor",
"VIEW_UNREAD_MESSAGES": "Imate nepročitane poruke",
"UNREAD_VIEW": {
"VIEW_MESSAGES_BUTTON": "See new messages",
"CLOSE_MESSAGES_BUTTON": "Close",
"COMPANY_FROM": "from",
"VIEW_MESSAGES_BUTTON": "Pogledajte nove poruke",
"CLOSE_MESSAGES_BUTTON": "Zatvori",
"COMPANY_FROM": "od",
"BOT": "Bot"
},
"BUBBLE": {
"LABEL": "Chat with us"
"LABEL": "Čavrljajte s nama"
},
"POWERED_BY": "Powered by Chatwoot",
"EMAIL_PLACEHOLDER": "Please enter your email",
"CHAT_PLACEHOLDER": "Type your message",
"POWERED_BY": "Pokreće Chatwoot",
"EMAIL_PLACEHOLDER": "Unesite svoju e-mail adresu",
"CHAT_PLACEHOLDER": "Unesite svoju poruku",
"TODAY": "Danas",
"YESTERDAY": "Jučer",
"PRE_CHAT_FORM": {
@@ -78,60 +78,60 @@
"ERROR": "Poruka je prekratka"
}
},
"CAMPAIGN_HEADER": "Please provide your name and email before starting the conversation",
"IS_REQUIRED": "is required",
"REQUIRED": "Required",
"REGEX_ERROR": "Please provide a valid input"
"CAMPAIGN_HEADER": "Molimo unesite svoje ime i e-mail prije početka razgovora",
"IS_REQUIRED": "je obavezno",
"REQUIRED": "Obavezno",
"REGEX_ERROR": "Molimo unesite važeći unos"
},
"FILE_SIZE_LIMIT": "File exceeds the {MAXIMUM_FILE_UPLOAD_SIZE} attachment limit",
"FILE_SIZE_LIMIT": "Datoteka prelazi ograničenje priloga za {MAXIMUM_FILE_UPLOAD_SIZE}",
"CHAT_FORM": {
"INVALID": {
"FIELD": "Invalid field"
"FIELD": "Nevažeće polje"
}
},
"EMOJI": {
"PLACEHOLDER": "Search emojis",
"NOT_FOUND": "No emoji match your search"
"PLACEHOLDER": "Pretraži emojije",
"NOT_FOUND": "Nema emojija koji odgovaraju vašoj pretrazi"
},
"CSAT": {
"TITLE": "Rate your conversation",
"SUBMITTED_TITLE": "Thank you for submitting the rating",
"PLACEHOLDER": "Tell us more..."
"TITLE": "Ocijenite vaš razgovor",
"SUBMITTED_TITLE": "Hvala vam na ocjeni",
"PLACEHOLDER": "Recite nam više..."
},
"EMAIL_TRANSCRIPT": {
"BUTTON_TEXT": "Request a conversation transcript",
"SEND_EMAIL_SUCCESS": "The chat transcript was sent successfully",
"SEND_EMAIL_ERROR": "There was an error, please try again"
"BUTTON_TEXT": "Zatražite transkript razgovora",
"SEND_EMAIL_SUCCESS": "Transkript razgovora je uspješno poslan",
"SEND_EMAIL_ERROR": "Došlo je do pogreške, molimo pokušajte ponovo"
},
"INTEGRATIONS": {
"DYTE": {
"CLICK_HERE_TO_JOIN": "Click here to join",
"LEAVE_THE_ROOM": "Leave the call"
"CLICK_HERE_TO_JOIN": "Kliknite ovdje za pridruživanje",
"LEAVE_THE_ROOM": "Napustite poziv"
}
},
"PORTAL": {
"POPULAR_ARTICLES": "Popular Articles",
"VIEW_ALL_ARTICLES": "View all articles",
"IFRAME_LOAD_ERROR": "There was an error loading the article, please refresh the page and try again."
"POPULAR_ARTICLES": "Popularni članci",
"VIEW_ALL_ARTICLES": "Pogledajte sve članke",
"IFRAME_LOAD_ERROR": "Došlo je do pogreške pri učitavanju članka, molimo osvježite stranicu i pokušajte ponovo"
},
"ATTACHMENTS": {
"image": {
"CONTENT": "Picture message"
"CONTENT": "Poruka sa slikom"
},
"audio": {
"CONTENT": "Audio message"
"CONTENT": "Poruka sa zvukom"
},
"video": {
"CONTENT": "Video message"
"CONTENT": "Video poruka"
},
"file": {
"CONTENT": "File Attachment"
"CONTENT": "Privitak datoteke"
},
"location": {
"CONTENT": "Location"
"CONTENT": "Lokacija"
},
"fallback": {
"CONTENT": "has shared a url"
"CONTENT": "je podijelio/la url"
}
}
}
+7 -2
View File
@@ -70,7 +70,8 @@
"REQUIRED_ERROR": "Phone Number is required",
"DIAL_CODE_VALID_ERROR": "Please select a country code",
"VALID_ERROR": "Please enter a valid phone number",
"DROPDOWN_EMPTY": "Tiada dijumpa"
"DROPDOWN_EMPTY": "Tiada dijumpa",
"DROPDOWN_SEARCH": "Search country"
},
"MESSAGE": {
"LABEL": "Message",
@@ -91,7 +92,8 @@
},
"EMOJI": {
"PLACEHOLDER": "Search emojis",
"NOT_FOUND": "No emoji match your search"
"NOT_FOUND": "No emoji match your search",
"ARIA_LABEL": "Emoji picker"
},
"CSAT": {
"TITLE": "Rate your conversation",
@@ -133,5 +135,8 @@
"fallback": {
"CONTENT": "has shared a url"
}
},
"FOOTER_REPLY_TO": {
"REPLY_TO": "Replying to:"
}
}
@@ -1,13 +0,0 @@
export default {
computed: {
messageContentAttributes() {
const { content_attributes: attribute = {} } = this.message;
return attribute;
},
hasAttachments() {
return !!(
this.message.attachments && this.message.attachments.length > 0
);
},
},
};
@@ -1,37 +0,0 @@
import { shallowMount } from '@vue/test-utils';
import messageMixin from '../messageMixin';
import messages from './messageFixture';
describe('messageMixin', () => {
let Component = {
render() {},
title: 'TestComponent',
mixins: [messageMixin],
};
it('deleted messages', async () => {
const wrapper = shallowMount(Component, {
data() {
return {
message: messages.deletedMessage,
};
},
});
expect(wrapper.vm.messageContentAttributes).toEqual({
deleted: true,
});
expect(wrapper.vm.hasAttachments).toBe(false);
});
it('non-deleted messages', async () => {
const wrapper = shallowMount(Component, {
data() {
return {
message: messages.nonDeletedMessage,
};
},
});
expect(wrapper.vm.deletedMessage).toBe(undefined);
expect(wrapper.vm.messageContentAttributes).toEqual({});
expect(wrapper.vm.hasAttachments).toBe(true);
});
});