From 439e064d900baab93af2781b06a4394d22ee8056 Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Wed, 1 Jan 2020 22:30:43 +0530 Subject: [PATCH 1/2] Feature: Contact Panel with conversation details (#397) * Add Contact panel changes * Fix parent iframe blocked * Add Conversation Panel, Contact messages * Update contact panel with conversation details * Update designs in sidebar * Fix specs * Specs: Add specs for conversationMetadata and contact modules * Fix currentUrl issues * Fix spelling * Set default to empty string --- .../api/v1/widget/messages_controller.rb | 12 +- app/javascript/dashboard/api/contacts.js | 9 + .../dashboard/assets/scss/_mixins.scss | 6 + .../conversation/ConversationHeader.vue | 10 +- .../dashboard/i18n/locale/en/contact.json | 8 + .../dashboard/i18n/locale/en/index.js | 2 + .../conversation/ContactDetailsItem.vue | 47 +++++ .../dashboard/conversation/ContactPanel.vue | 189 ++++++++++++++++-- .../conversation/ConversationView.vue | 5 +- app/javascript/dashboard/store/index.js | 4 + .../dashboard/store/modules/contacts.js | 85 ++++++++ .../store/modules/conversationMetadata.js | 28 +++ .../store/modules/conversations/actions.js | 15 +- .../store/modules/conversations/index.js | 1 - .../modules/specs/agents/mutations.spec.js | 4 +- .../modules/specs/contacts/actions.spec.js | 72 +++++++ .../store/modules/specs/contacts/fixtures.js | 30 +++ .../modules/specs/contacts/getters.spec.js | 33 +++ .../modules/specs/contacts/mutations.spec.js | 53 +++++ .../conversationMetadata/getters.spec.js | 16 ++ .../conversationMetadata/mutations.spec.js | 17 ++ .../dashboard/store/mutation-types.js | 9 + app/javascript/packs/sdk.js | 17 +- app/javascript/widget/App.vue | 20 +- app/javascript/widget/api/endPoints.js | 2 + .../widget/api/specs/endPoints.spec.js | 6 + app/views/api/v1/contacts/index.json.jbuilder | 2 +- .../api/v1/conversations/show.json.jbuilder | 2 + 28 files changed, 662 insertions(+), 42 deletions(-) create mode 100644 app/javascript/dashboard/api/contacts.js create mode 100644 app/javascript/dashboard/i18n/locale/en/contact.json create mode 100644 app/javascript/dashboard/routes/dashboard/conversation/ContactDetailsItem.vue create mode 100644 app/javascript/dashboard/store/modules/contacts.js create mode 100644 app/javascript/dashboard/store/modules/conversationMetadata.js create mode 100644 app/javascript/dashboard/store/modules/specs/contacts/actions.spec.js create mode 100644 app/javascript/dashboard/store/modules/specs/contacts/fixtures.js create mode 100644 app/javascript/dashboard/store/modules/specs/contacts/getters.spec.js create mode 100644 app/javascript/dashboard/store/modules/specs/contacts/mutations.spec.js create mode 100644 app/javascript/dashboard/store/modules/specs/conversationMetadata/getters.spec.js create mode 100644 app/javascript/dashboard/store/modules/specs/conversationMetadata/mutations.spec.js diff --git a/app/controllers/api/v1/widget/messages_controller.rb b/app/controllers/api/v1/widget/messages_controller.rb index 69a84e31b..ae6ae7902 100644 --- a/app/controllers/api/v1/widget/messages_controller.rb +++ b/app/controllers/api/v1/widget/messages_controller.rb @@ -38,7 +38,9 @@ class Api::V1::Widget::MessagesController < ActionController::Base inbox_id: inbox.id, contact_id: cookie_params[:contact_id], additional_attributes: { - browser: browser_params + browser: browser_params, + referer: permitted_params[:message][:referer_url], + initiated_at: timestamp_params } } end @@ -53,6 +55,12 @@ class Api::V1::Widget::MessagesController < ActionController::Base } end + def timestamp_params + { + timestamp: permitted_params[:message][:timestamp] + } + end + def inbox @inbox ||= ::Inbox.find_by(id: cookie_params[:inbox_id]) end @@ -79,7 +87,7 @@ class Api::V1::Widget::MessagesController < ActionController::Base end def permitted_params - params.permit(:before, message: [:content]) + params.permit(:before, message: [:content, :referer_url, :timestamp]) end def secret_key diff --git a/app/javascript/dashboard/api/contacts.js b/app/javascript/dashboard/api/contacts.js new file mode 100644 index 000000000..2addd9ce1 --- /dev/null +++ b/app/javascript/dashboard/api/contacts.js @@ -0,0 +1,9 @@ +import ApiClient from './ApiClient'; + +class ContactAPI extends ApiClient { + constructor() { + super('contacts'); + } +} + +export default new ContactAPI(); diff --git a/app/javascript/dashboard/assets/scss/_mixins.scss b/app/javascript/dashboard/assets/scss/_mixins.scss index 0b7a73c2c..c0cf98494 100644 --- a/app/javascript/dashboard/assets/scss/_mixins.scss +++ b/app/javascript/dashboard/assets/scss/_mixins.scss @@ -217,3 +217,9 @@ border-left: $size solid transparent; } } + +@mixin text-ellipsis { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} diff --git a/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue b/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue index 39b13c579..1c4c0c869 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue @@ -8,7 +8,7 @@ :username="chat.meta.sender.name" />
-

+

{{ chat.meta.sender.name }}