UX: Link directly to the post, not to the topic

UX: Link directly to the post, not to the topic

diff --git a/app/assets/javascripts/discourse/templates/components/reviewable-flagged-post.hbs b/app/assets/javascripts/discourse/templates/components/reviewable-flagged-post.hbs
index b25387a..047da85 100644
--- a/app/assets/javascripts/discourse/templates/components/reviewable-flagged-post.hbs
+++ b/app/assets/javascripts/discourse/templates/components/reviewable-flagged-post.hbs
@@ -2,7 +2,7 @@
 
 <div class='post-contents'>
   {{reviewable-created-by-name user=reviewable.target_created_by tagName=''}}
-  {{reviewable-topic-link topic=reviewable.topic}}
+  {{reviewable-topic-link reviewable=reviewable}}
 
   <div class='post-body'>
     {{{reviewable.cooked}}}
diff --git a/app/assets/javascripts/discourse/templates/components/reviewable-queued-post.hbs b/app/assets/javascripts/discourse/templates/components/reviewable-queued-post.hbs
index 5c5279a..5cf27df 100644
--- a/app/assets/javascripts/discourse/templates/components/reviewable-queued-post.hbs
+++ b/app/assets/javascripts/discourse/templates/components/reviewable-queued-post.hbs
@@ -3,7 +3,7 @@
 <div class='post-contents'>
   {{reviewable-created-by-name user=reviewable.created_by tagName=''}}
 
-  {{#reviewable-topic-link topic=reviewable.topic}}
+  {{#reviewable-topic-link reviewable=reviewable}}
     {{i18n "review.new_topic"}}
     {{reviewable.payload.title}}
   {{/reviewable-topic-link}}
diff --git a/app/assets/javascripts/discourse/templates/components/reviewable-topic-link.hbs b/app/assets/javascripts/discourse/templates/components/reviewable-topic-link.hbs
index d13f72a..f19fc01 100644
--- a/app/assets/javascripts/discourse/templates/components/reviewable-topic-link.hbs
+++ b/app/assets/javascripts/discourse/templates/components/reviewable-topic-link.hbs
@@ -1,14 +1,12 @@
-{{#if topic}}
-  <div class='post-topic'>
-    {{#if topic}}
-      {{i18n "review.topic"}}
-      {{topic-status topic=topic}}
-      {{topic-link topic}}
-      {{i18n "review.topic_replies" count=topic.reply_count}}
-    {{else}}
-      {{yield}}
-    {{/if}}
-  </div>
-{{else}}
-  {{i18n "topic.deleted"}}
-{{/if}}
+<div class='post-topic'>
+  {{#if reviewable.topic}}
+    {{i18n "review.topic"}}
+    {{topic-status topic=reviewable.topic}}
+    <a href={{reviewable.topic_url}} class='title'>{{reviewable.topic.title}}</a>
+    {{i18n "review.topic_replies" count=reviewable.topic.reply_count}}
+  {{else if (has-block)}}
+    {{yield}}
+  {{else}}
+    {{i18n "topic.deleted"}}
+  {{/if}}
+</div>
diff --git a/app/serializers/reviewable_serializer.rb b/app/serializers/reviewable_serializer.rb
index 36e0e6f..f6d3f23 100644
--- a/app/serializers/reviewable_serializer.rb
+++ b/app/serializers/reviewable_serializer.rb
@@ -10,6 +10,7 @@ class ReviewableSerializer < ApplicationSerializer
     :status,
     :type,
     :topic_id,
+    :topic_url,
     :category_id,
     :created_at,
     :can_edit,
@@ -86,6 +87,15 @@ class ReviewableSerializer < ApplicationSerializer
     data
   end
 
+  def topic_url
+    return object.target.url if object.target.is_a?(Post)
+    return object.topic.url
+  end
+
+  def include_topic_url?
+    object.topic_id.present?
+  end
+
   def include_topic_id?
     object.topic_id.present?
   end
diff --git a/spec/serializers/reviewable_flagged_post_serializer_spec.rb b/spec/serializers/reviewable_flagged_post_serializer_spec.rb
new file mode 100644
index 0000000..1165fe1
--- /dev/null
+++ b/spec/serializers/reviewable_flagged_post_serializer_spec.rb
@@ -0,0 +1,16 @@
+require 'rails_helper'
+
+describe ReviewableFlaggedPostSerializer do
+
+  let(:admin) { Fabricate(:admin) }
+
+  it "includes the user fields for review" do
+    p0 = Fabricate(:post)
+    reviewable = PostActionCreator.spam(Fabricate(:user), p0).reviewable
+    json = ReviewableFlaggedPostSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_json
+    expect(json[:cooked]).to be_present
+    expect(json[:raw]).to be_present
+    expect(json[:topic_url]).to eq(p0.url)
+  end
+
+end
diff --git a/spec/serializers/reviewable_queued_post_serializer_spec.rb b/spec/serializers/reviewable_queued_post_serializer_spec.rb
index 11bc899..6e18817 100644
--- a/spec/serializers/reviewable_queued_post_serializer_spec.rb
+++ b/spec/serializers/reviewable_queued_post_serializer_spec.rb
@@ -48,6 +48,7 @@ describe ReviewableQueuedPostSerializer do
       expect(payload['raw']).to eq('hello world post contents.')
       expect(payload['title']).to be_blank
       expect(json[:topic_id]).to eq(reviewable.topic_id)
+      expect(json[:topic_url]).to eq(reviewable.topic.url)
       expect(json[:can_edit]).to eq(true)
 
       fields = json[:editable_fields]
diff --git a/spec/serializers/reviewable_user_serializer_spec.rb b/spec/serializers/reviewable_user_serializer_spec.rb
index 8e6a63e..5b117d0 100644
--- a/spec/serializers/reviewable_user_serializer_spec.rb
+++ b/spec/serializers/reviewable_user_serializer_spec.rb
@@ -11,6 +11,7 @@ describe ReviewableUserSerializer do
     expect(json[:username]).to eq(reviewable.target.username)
     expect(json[:email]).to eq(reviewable.target.email)
     expect(json[:name]).to eq(reviewable.target.name)
+    expect(json[:topic_url]).to be_blank
   end
 
 end

GitHub sha: 6470c85f

This commit has been mentioned on Discourse Meta. There might be relevant details there: