Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add action to unassign tag from thread #532

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion app/models/automation/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Action < ApplicationRecord
belongs_to :action_object, polymorphic: true, optional: true
attr_accessor :delete_record

ACTION_LIST = ['Automation::AddMessageThreadTagAction', 'Automation::FireWebhookAction', 'Automation::ChangeMessageThreadTitleAction'].freeze
ACTION_LIST = ['Automation::AddMessageThreadTagAction', 'Automation::UnassignMessageThreadTagAction', 'Automation::FireWebhookAction', 'Automation::ChangeMessageThreadTitleAction'].freeze

def tag_list
automation_rule.tenant.tags.pluck(:name, :id)
Expand All @@ -28,6 +28,24 @@ def tag_list
class AddTagAction < Action
end

class UnassignMessageThreadTagAction < Action
def run!(thing, _event)
tag = action_object
return if thing.tenant != tag.tenant

object = if thing.respond_to? :thread
thing.thread
else
thing
end
object.unassign_tag(tag) if tag && object.tags.include?(tag)
end

def object_based?
true
end
end

class AddMessageThreadTagAction < Action
def run!(thing, _event)
tag = action_object
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%= form.select :action_object_id, form.object.tag_list, {}, class: "mt-2 block rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-400 ring-1 ring-inset ring-gray-400 focus:ring-2 focus:ring-indigo-600 sm:text-sm sm:leading-6", disabled: !enabled %>
<%= form.hidden_field :action_object_type, value: 'Tag' %>
1 change: 1 addition & 0 deletions config/locales/sk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ sk:
"Automation::MessageMetadataValueCondition": "správa v metadátach obsahuje"
"Automation::BoxCondition": "je"
"Automation::AddMessageThreadTagAction": "Pridaj štítok na vlákno"
"Automation::UnassignMessageThreadTagAction": "Odober štítok z vlákna"
"Automation::AddTagAction": "Pridaj štítok"
"Automation::ChangeMessageThreadTitleAction": "Premenuj vlákno na"
"Automation::FireWebhookAction": "Zavolaj integráciu"
Expand Down