From 2b1d445003bc723d1fc4f29093cf78b5df5b9eaa Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Mon, 27 Jul 2020 22:19:26 +0530 Subject: [PATCH] feat: Use display_name instead of name of the agent (#1097) * feat: Use display_name instead of name of the agent --- app/controllers/api/v1/profiles_controller.rb | 10 +++++++++- app/javascript/dashboard/api/auth.js | 8 +++++++- .../dashboard/components/layout/Sidebar.vue | 8 ++++++-- .../widgets/conversation/ConversationHeader.vue | 4 ++-- .../components/widgets/conversation/Message.vue | 11 +++++++---- .../dashboard/i18n/locale/en/settings.json | 11 ++++++++--- .../routes/dashboard/settings/inbox/Settings.vue | 11 ++--------- .../routes/dashboard/settings/profile/Index.vue | 15 +++++++++++++++ .../store/modules/conversations/getters.js | 5 ++--- app/mailers/conversation_reply_mailer.rb | 6 +++--- app/models/conversation.rb | 4 ++-- app/models/user.rb | 3 ++- .../conversations/event_data_presenter.rb | 2 +- .../v1/accounts/inbox_members/show.json.jbuilder | 3 +-- .../partials/_conversation.json.jbuilder | 6 +++++- app/views/api/v1/models/_agent.json.jbuilder | 1 + app/views/api/v1/models/_user.json.jbuilder | 1 + .../v1/widget/inbox_members/index.json.jbuilder | 2 +- .../reply_with_summary.html.erb | 2 +- spec/mailers/conversation_reply_mailer_spec.rb | 4 ++-- spec/models/conversation_spec.rb | 4 ++-- 21 files changed, 80 insertions(+), 41 deletions(-) diff --git a/app/controllers/api/v1/profiles_controller.rb b/app/controllers/api/v1/profiles_controller.rb index 38f1a9b3b..bda3e8c90 100644 --- a/app/controllers/api/v1/profiles_controller.rb +++ b/app/controllers/api/v1/profiles_controller.rb @@ -16,6 +16,14 @@ class Api::V1::ProfilesController < Api::BaseController end def profile_params - params.require(:profile).permit(:email, :name, :password, :password_confirmation, :avatar, :availability) + params.require(:profile).permit( + :email, + :name, + :display_name, + :password, + :password_confirmation, + :avatar, + :availability + ) end end diff --git a/app/javascript/dashboard/api/auth.js b/app/javascript/dashboard/api/auth.js index 42d1fbc41..ae5031cd4 100644 --- a/app/javascript/dashboard/api/auth.js +++ b/app/javascript/dashboard/api/auth.js @@ -118,7 +118,12 @@ export default { return axios.post(urlData.url, { email }); }, - profileUpdate({ password, password_confirmation, ...profileAttributes }) { + profileUpdate({ + password, + password_confirmation, + displayName, + ...profileAttributes + }) { const formData = new FormData(); Object.keys(profileAttributes).forEach(key => { const value = profileAttributes[key]; @@ -126,6 +131,7 @@ export default { formData.append(`profile[${key}]`, value); } }); + formData.append('profile[display_name]', displayName || ''); if (password && password_confirmation) { formData.append('profile[password]', password); formData.append('profile[password_confirmation]', password_confirmation); diff --git a/app/javascript/dashboard/components/layout/Sidebar.vue b/app/javascript/dashboard/components/layout/Sidebar.vue index fbd10920c..f13fbee92 100644 --- a/app/javascript/dashboard/components/layout/Sidebar.vue +++ b/app/javascript/dashboard/components/layout/Sidebar.vue @@ -58,12 +58,12 @@

- {{ currentUser.name }} + {{ currentUserAvailableName }}

{{ currentRole }} @@ -202,6 +202,10 @@ export default { uiFlags: 'agents/getUIFlags', accountLabels: 'labels/getLabelsOnSidebar', }), + currentUserAvailableName() { + const { available_name: availableName } = this.currentUser; + return availableName; + }, showChangeAccountOption() { if (this.globalConfig.createNewAccountFromDashboard) { return true; diff --git a/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue b/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue index 7783e8c94..c5ce3d0be 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue @@ -25,7 +25,7 @@ { - const [item] = this.agentList.filter( - agent => agent.id === el.user_id - ); - if (item) { - this.selectedAgents.push(item); - } - }); + this.selectedAgents = inboxMembers; } catch (error) { console.log(error); } diff --git a/app/javascript/dashboard/routes/dashboard/settings/profile/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/profile/Index.vue index 00d8b9a35..e0575ccaa 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/profile/Index.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/profile/Index.vue @@ -26,6 +26,17 @@ {{ $t('PROFILE_SETTINGS.FORM.NAME.ERROR') }} +