From 24cf7af30b5aa094510c9e7f8bac8dc597857b3f Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Mon, 9 Jan 2023 11:49:27 -0800 Subject: [PATCH] feat: Add video call option with Dyte in the dashboard (#6207) Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> --- .../dashboard/api/integrations/dyte.js | 23 ++++ .../api/specs/integrations/dyte.spec.js | 35 ++++++ .../components/widgets/VideoCallButton.vue | 57 ++++++++++ .../widgets/WootWriter/ReplyBottomPanel.vue | 14 ++- .../widgets/conversation/Message.vue | 40 ++++--- .../widgets/conversation/ReplyBox.vue | 35 +++--- .../conversation/bubble/Integration.vue | 39 +++++++ .../conversation/bubble/integrations/Dyte.vue | 104 ++++++++++++++++++ .../i18n/locale/en/integrations.json | 17 +-- .../dashboard/store/modules/integrations.js | 9 +- .../specs/integrations/getters.spec.js | 34 +++++- .../FluentIcon/dashboard-icons.json | 1 + 12 files changed, 358 insertions(+), 50 deletions(-) create mode 100644 app/javascript/dashboard/api/integrations/dyte.js create mode 100644 app/javascript/dashboard/api/specs/integrations/dyte.spec.js create mode 100644 app/javascript/dashboard/components/widgets/VideoCallButton.vue create mode 100644 app/javascript/dashboard/components/widgets/conversation/bubble/Integration.vue create mode 100644 app/javascript/dashboard/components/widgets/conversation/bubble/integrations/Dyte.vue diff --git a/app/javascript/dashboard/api/integrations/dyte.js b/app/javascript/dashboard/api/integrations/dyte.js new file mode 100644 index 000000000..e22a5893a --- /dev/null +++ b/app/javascript/dashboard/api/integrations/dyte.js @@ -0,0 +1,23 @@ +/* global axios */ + +import ApiClient from '../ApiClient'; + +class DyteAPI extends ApiClient { + constructor() { + super('integrations/dyte', { accountScoped: true }); + } + + createAMeeting(conversationId) { + return axios.post(`${this.url}/create_a_meeting`, { + conversation_id: conversationId, + }); + } + + addParticipantToMeeting(messageId) { + return axios.post(`${this.url}/add_participant_to_meeting`, { + message_id: messageId, + }); + } +} + +export default new DyteAPI(); diff --git a/app/javascript/dashboard/api/specs/integrations/dyte.spec.js b/app/javascript/dashboard/api/specs/integrations/dyte.spec.js new file mode 100644 index 000000000..c89c2106e --- /dev/null +++ b/app/javascript/dashboard/api/specs/integrations/dyte.spec.js @@ -0,0 +1,35 @@ +import DyteAPIClient from '../../integrations/dyte'; +import ApiClient from '../../ApiClient'; +import describeWithAPIMock from '../apiSpecHelper'; + +describe('#accountAPI', () => { + it('creates correct instance', () => { + expect(DyteAPIClient).toBeInstanceOf(ApiClient); + expect(DyteAPIClient).toHaveProperty('createAMeeting'); + expect(DyteAPIClient).toHaveProperty('addParticipantToMeeting'); + }); + + describeWithAPIMock('createAMeeting', context => { + it('creates a valid request', () => { + DyteAPIClient.createAMeeting(1); + expect(context.axiosMock.post).toHaveBeenCalledWith( + '/api/v1/integrations/dyte/create_a_meeting', + { + conversation_id: 1, + } + ); + }); + }); + + describeWithAPIMock('addParticipantToMeeting', context => { + it('creates a valid request', () => { + DyteAPIClient.addParticipantToMeeting(1); + expect(context.axiosMock.post).toHaveBeenCalledWith( + '/api/v1/integrations/dyte/add_participant_to_meeting', + { + message_id: 1, + } + ); + }); + }); +}); diff --git a/app/javascript/dashboard/components/widgets/VideoCallButton.vue b/app/javascript/dashboard/components/widgets/VideoCallButton.vue new file mode 100644 index 000000000..12050c811 --- /dev/null +++ b/app/javascript/dashboard/components/widgets/VideoCallButton.vue @@ -0,0 +1,57 @@ + + diff --git a/app/javascript/dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue b/app/javascript/dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue index bd67011e5..6922389b0 100644 --- a/app/javascript/dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue +++ b/app/javascript/dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue @@ -87,6 +87,10 @@ :title="'Whatsapp Templates'" @click="$emit('selectWhatsappTemplate')" /> +
-
  • +
  • + diff --git a/app/javascript/dashboard/components/widgets/conversation/bubble/integrations/Dyte.vue b/app/javascript/dashboard/components/widgets/conversation/bubble/integrations/Dyte.vue new file mode 100644 index 000000000..de4b07da0 --- /dev/null +++ b/app/javascript/dashboard/components/widgets/conversation/bubble/integrations/Dyte.vue @@ -0,0 +1,104 @@ +