From b3180d34861085ce901730af62baa247f77ab5fa Mon Sep 17 00:00:00 2001
From: Douwe Maan <douwe@selenight.nl>
Date: Mon, 25 Jul 2016 22:49:21 -0600
Subject: [PATCH] Add resolved and last updated status to collapsed discussions

---
 app/models/discussion.rb                    |  8 ++++++
 app/views/discussions/_discussion.html.haml | 32 +++++++++++++++------
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/app/models/discussion.rb b/app/models/discussion.rb
index 50fa814b311..9a13c1aad6c 100644
--- a/app/models/discussion.rb
+++ b/app/models/discussion.rb
@@ -39,6 +39,14 @@ class Discussion
     @notes = notes
   end
 
+  def last_updated_at
+    last_note.created_at
+  end
+
+  def last_updated_by
+    last_note.author
+  end
+
   def id
     first_note.discussion_id
   end
diff --git a/app/views/discussions/_discussion.html.haml b/app/views/discussions/_discussion.html.haml
index 49702e048aa..faec785913b 100644
--- a/app/views/discussions/_discussion.html.haml
+++ b/app/views/discussions/_discussion.html.haml
@@ -7,6 +7,15 @@
     .timeline-content
       .discussion.js-toggle-container{ class: discussion.id }
         .discussion-header
+          .discussion-actions
+            = link_to "#", class: "note-action-button discussion-toggle-button js-toggle-button" do
+              - if expanded
+                = icon("chevron-up")
+              - else
+                = icon("chevron-down")
+
+              Toggle discussion
+
           = link_to_member(@project, discussion.author, avatar: false)
 
           .inline.discussion-headline-light
@@ -29,14 +38,21 @@
 
             = time_ago_with_tooltip(discussion.created_at, placement: "bottom", html_class: "note-created-ago")
 
-          .discussion-actions
-            = link_to "#", class: "note-action-button discussion-toggle-button js-toggle-button" do
-              - if expanded
-                = icon("chevron-up")
-              - else
-                = icon("chevron-down")
-
-              Toggle discussion
+          -# TODO: Live update!
+          - if discussion.resolved?
+            .discussion-headline-light
+              Resolved
+              - if discussion.resolved_by
+                by
+                = link_to_member(@project, discussion.resolved_by, avatar: false)
+              = time_ago_with_tooltip(discussion.resolved_at, placement: "bottom")
+          - elsif discussion.last_updated_at != discussion.created_at
+            .discussion-headline-light
+              Last updated
+              - if discussion.last_updated_by
+                by
+                = link_to_member(@project, discussion.last_updated_by, avatar: false)
+              = time_ago_with_tooltip(discussion.last_updated_at, placement: "bottom")
 
         .discussion-body.js-toggle-content{ class: ("hide" unless expanded) }
           - if discussion.diff_discussion? && discussion.diff_file
-- 
2.30.9