diff --git a/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue b/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue
index dc5a8887f..4a1713165 100644
--- a/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue
+++ b/app/javascript/dashboard/components/widgets/conversation/contextMenu/Index.vue
@@ -141,9 +141,19 @@ export default {
assignableAgentsUiFlags: 'inboxAssignableAgents/getUIFlags',
}),
assignableAgents() {
- return this.$store.getters['inboxAssignableAgents/getAssignableAgents'](
- this.inboxId
- );
+ return [
+ {
+ confirmed: true,
+ name: 'None',
+ id: null,
+ role: 'agent',
+ account_id: 0,
+ email: 'None',
+ },
+ ...this.$store.getters['inboxAssignableAgents/getAssignableAgents'](
+ this.inboxId
+ ),
+ ];
},
},
mounted() {
diff --git a/app/javascript/dashboard/components/widgets/conversation/conversationBulkActions/AgentSelector.vue b/app/javascript/dashboard/components/widgets/conversation/conversationBulkActions/AgentSelector.vue
index caee88392..518aac2f6 100644
--- a/app/javascript/dashboard/components/widgets/conversation/conversationBulkActions/AgentSelector.vue
+++ b/app/javascript/dashboard/components/widgets/conversation/conversationBulkActions/AgentSelector.vue
@@ -57,7 +57,7 @@
-
+
{{
$t('BULK_ACTION.ASSIGN_CONFIRMATION_LABEL', {
conversationCount,
@@ -67,6 +67,15 @@
{{ selectedAgent.name }}
+ ?
+
+
+ {{
+ $t('BULK_ACTION.UNASSIGN_CONFIRMATION_LABEL', {
+ conversationCount,
+ conversationLabel,
+ })
+ }}
- {{ $t('BULK_ACTION.ASSIGN_LABEL') }}
+ {{ $t('BULK_ACTION.YES') }}
@@ -131,7 +140,17 @@ export default {
agent.name.toLowerCase().includes(this.query.toLowerCase())
);
}
- return this.assignableAgents;
+ return [
+ {
+ confirmed: true,
+ name: 'None',
+ id: null,
+ role: 'agent',
+ account_id: 0,
+ email: 'None',
+ },
+ ...this.assignableAgents,
+ ];
},
assignableAgents() {
return this.$store.getters['inboxAssignableAgents/getAssignableAgents'](
diff --git a/app/javascript/dashboard/i18n/locale/en/bulkActions.json b/app/javascript/dashboard/i18n/locale/en/bulkActions.json
index 7061e5e70..c42b50013 100644
--- a/app/javascript/dashboard/i18n/locale/en/bulkActions.json
+++ b/app/javascript/dashboard/i18n/locale/en/bulkActions.json
@@ -2,9 +2,11 @@
"BULK_ACTION": {
"CONVERSATIONS_SELECTED": "%{conversationCount} conversations selected",
"AGENT_SELECT_LABEL": "Select Agent",
- "ASSIGN_CONFIRMATION_LABEL": "Are you sure you want to assign %{conversationCount} %{conversationLabel} to",
+ "ASSIGN_CONFIRMATION_LABEL": "Are you sure to assign %{conversationCount} %{conversationLabel} to",
+ "UNASSIGN_CONFIRMATION_LABEL": "Are you sure to unassign %{conversationCount} %{conversationLabel}?",
"GO_BACK_LABEL": "Go back",
"ASSIGN_LABEL": "Assign",
+ "YES": "Yes",
"ASSIGN_AGENT_TOOLTIP": "Assign Agent",
"ASSIGN_SUCCESFUL": "Conversations assigned successfully",
"ASSIGN_FAILED": "Failed to assign conversations, please try again",
diff --git a/app/jobs/bulk_actions_job.rb b/app/jobs/bulk_actions_job.rb
index 75b834308..bc68b2b36 100644
--- a/app/jobs/bulk_actions_job.rb
+++ b/app/jobs/bulk_actions_job.rb
@@ -36,7 +36,7 @@ class BulkActionsJob < ApplicationJob
def available_params(params)
return unless params[:fields]
- params[:fields].delete_if { |_k, v| v.nil? }
+ params[:fields].delete_if { |key, value| value.nil? && key == 'status' }
end
def bulk_add_labels(conversation)
diff --git a/spec/controllers/api/v1/accounts/bulk_actions_controller_spec.rb b/spec/controllers/api/v1/accounts/bulk_actions_controller_spec.rb
index 434ae86d7..c7bb494c2 100644
--- a/spec/controllers/api/v1/accounts/bulk_actions_controller_spec.rb
+++ b/spec/controllers/api/v1/accounts/bulk_actions_controller_spec.rb
@@ -75,6 +75,46 @@ RSpec.describe 'Api::V1::Accounts::BulkActionsController', type: :request do
expect(Conversation.first.status).to eq('open')
end
+ it 'Bulk remove assignee id from conversations' do
+ Conversation.first.update(assignee_id: agent_1.id)
+ Conversation.second.update(assignee_id: agent_2.id)
+ params = { type: 'Conversation', fields: { assignee_id: nil }, ids: Conversation.first(3).pluck(:display_id) }
+
+ expect(Conversation.first.status).to eq('open')
+ expect(Conversation.first.assignee_id).to eq(agent_1.id)
+ expect(Conversation.second.assignee_id).to eq(agent_2.id)
+
+ perform_enqueued_jobs do
+ post "/api/v1/accounts/#{account.id}/bulk_actions",
+ headers: agent.create_new_auth_token,
+ params: params
+
+ expect(response).to have_http_status(:success)
+ end
+
+ expect(Conversation.first.assignee_id).to be_nil
+ expect(Conversation.second.assignee_id).to be_nil
+ expect(Conversation.first.status).to eq('open')
+ end
+
+ it 'Do not bulk update status to nil' do
+ Conversation.first.update(assignee_id: agent_1.id)
+ Conversation.second.update(assignee_id: agent_2.id)
+ params = { type: 'Conversation', fields: { status: nil }, ids: Conversation.first(3).pluck(:display_id) }
+
+ expect(Conversation.first.status).to eq('open')
+
+ perform_enqueued_jobs do
+ post "/api/v1/accounts/#{account.id}/bulk_actions",
+ headers: agent.create_new_auth_token,
+ params: params
+
+ expect(response).to have_http_status(:success)
+ end
+
+ expect(Conversation.first.status).to eq('open')
+ end
+
it 'Bulk update conversation status and assignee id' do
params = { type: 'Conversation', fields: { assignee_id: agent_1.id, status: 'snoozed' }, ids: Conversation.first(3).pluck(:display_id) }