From cd217a3f86eb7093e0aecb9bbfc7f25772718f7f Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Mon, 13 Nov 2023 13:10:55 +0530 Subject: [PATCH] feat: allow automation rules to remove labels (#8346) --- app/javascript/dashboard/helper/automationHelper.js | 1 + .../routes/dashboard/settings/automation/constants.js | 10 ++++++++++ app/models/automation_rule.rb | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/javascript/dashboard/helper/automationHelper.js b/app/javascript/dashboard/helper/automationHelper.js index f186b0e92..d1a85570b 100644 --- a/app/javascript/dashboard/helper/automationHelper.js +++ b/app/javascript/dashboard/helper/automationHelper.js @@ -135,6 +135,7 @@ export const getActionOptions = ({ agents, teams, labels, type }) => { assign_team: teams, send_email_to_team: teams, add_label: generateConditionOptions(labels, 'title'), + remove_label: generateConditionOptions(labels, 'title'), change_priority: PRIORITY_CONDITION_VALUES, }; return actionsMap[type]; diff --git a/app/javascript/dashboard/routes/dashboard/settings/automation/constants.js b/app/javascript/dashboard/routes/dashboard/settings/automation/constants.js index 9fcee3f45..e86aa5161 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/automation/constants.js +++ b/app/javascript/dashboard/routes/dashboard/settings/automation/constants.js @@ -67,6 +67,11 @@ export const AUTOMATIONS = { name: 'Add a label', attributeI18nKey: 'ADD_LABEL', }, + { + key: 'remove_label', + name: 'Remove a label', + attributeI18nKey: 'REMOVE_LABEL', + }, { key: 'send_email_to_team', name: 'Send an email to team', @@ -556,6 +561,11 @@ export const AUTOMATION_ACTION_TYPES = [ label: 'Add a label', inputType: 'multi_select', }, + { + key: 'remove_label', + label: 'Remove a label', + inputType: 'multi_select', + }, { key: 'send_email_to_team', label: 'Send an email to team', diff --git a/app/models/automation_rule.rb b/app/models/automation_rule.rb index 7a9550bd3..5f5d59814 100644 --- a/app/models/automation_rule.rb +++ b/app/models/automation_rule.rb @@ -32,8 +32,8 @@ class AutomationRule < ApplicationRecord CONDITIONS_ATTRS = %w[content email country_code status message_type browser_language assignee_id team_id referer city company inbox_id mail_subject phone_number priority conversation_language].freeze - ACTIONS_ATTRS = %w[send_message add_label send_email_to_team assign_team assign_agent send_webhook_event mute_conversation send_attachment - change_status resolve_conversation snooze_conversation change_priority send_email_transcript].freeze + ACTIONS_ATTRS = %w[send_message add_label remove_label send_email_to_team assign_team assign_agent send_webhook_event mute_conversation + send_attachment change_status resolve_conversation snooze_conversation change_priority send_email_transcript].freeze def file_base_data files.map do |file|