Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

4.4 KB
Raw Blame
<%# Notification message content %>
<div class="notification-message-content">
  <% case notification.event_type %>
  <% when event_type_ticket_commented %>
    <% if notification.actor %>
      <strong><%= viewer_display_name(notification.actor) %></strong> commented on
      <strong><%= notification.notifiable.respond_to?(:title) ? notification.notifiable.title : (notification.notifiable&.name || 'a ticket') %></strong>
    <% else %>
      New comment on <strong><%= notification.notifiable.respond_to?(:title) ? notification.notifiable.title : (notification.notifiable&.name || 'a ticket') %></strong>
    <% end %>
    
    <% if notification.payload['post_excerpt'].present? %>
      <div class="message-excerpt">
        "<%= truncate(notification.payload['post_excerpt'], length: 120) %>"
      </div>
    <% end %>
    
  <% when event_type_ticket_assigned %>
    <% if notification.actor %>
      <strong><%= viewer_display_name(notification.actor) %></strong> assigned you to 
      <strong><%= notification.notifiable&.title || 'a ticket' %></strong>
    <% else %>
      You were assigned to <strong><%= notification.notifiable&.title || 'a ticket' %></strong>
    <% end %>
    
  <% when event_type_ticket_unassigned %>
    <% if notification.actor %>
      <strong><%= viewer_display_name(notification.actor) %></strong> removed your assignment from 
      <strong><%= notification.notifiable&.title || 'a ticket' %></strong>
    <% else %>
      You were unassigned from <strong><%= notification.notifiable&.title || 'a ticket' %></strong>
    <% end %>
    
  <% when event_type_ticket_status_changed %>
    <% if notification.actor %>
      <strong><%= viewer_display_name(notification.actor) %></strong> changed the status of 
      <strong><%= notification.notifiable&.title || 'a ticket' %></strong>
    <% else %>
      Status changed for <strong><%= notification.notifiable&.title || 'a ticket' %></strong>
    <% end %>
    
    <% if notification.payload['old_status'] && notification.payload['new_status'] %>
      <div class="status-change">
        <%= notification.payload['old_status'] %> → <%= notification.payload['new_status'] %>
      </div>
    <% end %>
    
  <% when event_type_ticket_blocker %>
    <% if notification.actor %>
      <strong><%= viewer_display_name(notification.actor) %></strong> changed the priority of 
      <strong><%= notification.notifiable&.title || 'a ticket' %></strong>
    <% else %>
      Priority changed for <strong><%= notification.notifiable&.title || 'a ticket' %></strong>
    <% end %>
    
  <% when event_type_project_announcement %>
    <% if notification.actor %>
      <strong><%= viewer_display_name(notification.actor) %></strong> made an announcement in 
      <strong><%= notification.notifiable&.name || 'a project' %></strong>
    <% else %>
      New announcement in <strong><%= notification.notifiable&.name || 'a project' %></strong>
    <% end %>
    
    <% if notification.payload['announcement_content'].present? %>
      <div class="message-excerpt">
        <%= truncate(notification.payload['announcement_content'], length: 120) %>
      </div>
    <% end %>
    
  <% when event_type_document_added %>
    <% if notification.actor %>
      <strong><%= viewer_display_name(notification.actor) %></strong> added a new document: 
      <strong><%= notification.notifiable&.title || 'Untitled' %></strong>
    <% else %>
      New document: <strong><%= notification.notifiable&.title || 'Untitled' %></strong>
    <% end %>
    
  <% when event_type_mention %>
    <% if notification.actor %>
      <strong><%= viewer_display_name(notification.actor) %></strong> mentioned you in 
      <strong><%= notification.notifiable&.title || 'a discussion' %></strong>
    <% else %>
      You were mentioned in <strong><%= notification.notifiable&.title || 'a discussion' %></strong>
    <% end %>
    
    <% if notification.payload['mention_context'].present? %>
      <div class="message-excerpt">
        "<%= truncate(notification.payload['mention_context'], length: 120) %>"
      </div>
    <% end %>
    
  <% else %>
    <%# Generic message for unknown event types %>
    <% if notification.actor %>
      <strong><%= viewer_display_name(notification.actor) %></strong> performed an action
    <% else %>
      System notification
    <% end %>
    
    <% if notification.payload['action'].present? %>
      <div class="message-excerpt">
        <%= notification.payload['action'].humanize %>
      </div>
    <% end %>
  <% end %>
</div>