feat: UI to show the SLA threshold in chat screen (#9146)

- UI will show the breach in the conversation list.
- UI will show the breach in the conversation header.

Fixes: https://linear.app/chatwoot/issue/CW-3146/update-the-ui-to-show-the-breach-in-the-conversation-list
Fixes: https://linear.app/chatwoot/issue/CW-3144/ui-update-to-show-the-breachgoing-to-breach
This commit is contained in:
Sivin Varghese
2024-04-04 15:46:46 +05:30
committed by GitHub
parent e21d7552d3
commit e49ef773d8
21 changed files with 745 additions and 106 deletions

View File

@@ -41,6 +41,8 @@ class AppliedSla < ApplicationRecord
}
scope :missed, -> { where(sla_status: :missed) }
after_update_commit :push_conversation_event
def push_event_data
{
id: id,
@@ -59,6 +61,16 @@ class AppliedSla < ApplicationRecord
private
def push_conversation_event
# right now we simply use `CONVERSATION_UPDATED` event to notify the frontend
# we can eventually start using `CONVERSATION_SLA_UPDATED` event as required later
# for now the updated event should suffice
return unless saved_change_to_sla_status?
conversation.dispatch_conversation_updated_event
end
def ensure_account_id
self.account_id ||= sla_policy&.account_id
end

View File

@@ -0,0 +1,5 @@
module Enterprise::Conversation
def list_of_keys
super + %w[sla_policy_id]
end
end

View File

@@ -3,7 +3,8 @@ module Enterprise::Conversations::EventDataPresenter
if account.feature_enabled?('sla')
super.merge(
applied_sla: applied_sla&.push_event_data,
sla_events: sla_events.map(&:push_event_data)
sla_events: sla_events.map(&:push_event_data),
sla_policy_id: sla_policy_id
)
else
super