A platform for community discussion. Free, open, simple.
Show link to the original topic when it was deleted (#7319)
Roman Rizzi82e051077d1b
diff --git a/app/assets/javascripts/discourse/templates/components/reviewable-topic-link.hbs b/app/assets/javascripts/discourse/templates/components/reviewable-topic-link.hbsindex af344e09c23..30d2dc8c642 100644--- a/app/assets/javascripts/discourse/templates/components/reviewable-topic-link.hbs+++ b/app/assets/javascripts/discourse/templates/components/reviewable-topic-link.hbs@@ -7,6 +7,9 @@{{else if (has-block)}}{{yield}}{{else}}- <span class="title-text">{{i18n "topic.deleted"}}</span>+ <span class="title-text">+ {{i18n "review.topics.deleted"}}+ {{link-to (i18n "review.topics.original") "topic" "-" reviewable.removed_topic_id}}+ </span>{{/if}}</div>diff --git a/app/serializers/reviewable_serializer.rb b/app/serializers/reviewable_serializer.rbindex 571993449ef..51775af412e 100644--- a/app/serializers/reviewable_serializer.rb+++ b/app/serializers/reviewable_serializer.rb@@ -72,19 +72,19 @@ class ReviewableSerializer < ApplicationSerializerenddef attributes- data = super+ super.tap do |data|+ data[:removed_topic_id] = object.topic_id unless object.topic- if object.target.present?- # Automatically add the target id as a "good name" for example a target_type of `User`- # becomes `user_id`- data[:"#{object.target_type.downcase}_id"] = object.target_id- end+ if object.target.present?+ # Automatically add the target id as a "good name" for example a target_type of `User`+ # becomes `user_id`+ data[:"#{object.target_type.downcase}_id"] = object.target_id+ end- if self.class._payload_for_serialization.present?- data[:payload] = (object.payload || {}).slice(*self.class._payload_for_serialization)+ if self.class._payload_for_serialization.present?+ data[:payload] = (object.payload || {}).slice(*self.class._payload_for_serialization)+ endend-- dataenddef topic_tagsdiff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 9b4c0520c79..38405a1772a 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -404,6 +404,8 @@ en:topic: "Topic"reviewable_count: "Count"reported_by: "Reported by"+ deleted: "[Topic Deleted]"+ original: '(original topic)'details: "details"unique_users:one: "1 user"diff --git a/spec/serializers/reviewable_serializer_spec.rb b/spec/serializers/reviewable_serializer_spec.rbindex 9c5558ad5e2..e2ca4c70186 100644--- a/spec/serializers/reviewable_serializer_spec.rb+++ b/spec/serializers/reviewable_serializer_spec.rb@@ -6,7 +6,7 @@ describe ReviewableSerializer dolet(:admin) { Fabricate(:admin) }it "serializes all the fields" do- json = ReviewableSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_json+ json = described_class.new(reviewable, scope: Guardian.new(admin), root: nil).as_jsonexpect(json[:id]).to eq(reviewable.id)expect(json[:status]).to eq(reviewable.status)@@ -15,6 +15,15 @@ describe ReviewableSerializer doexpect(json[:category_id]).to eq(reviewable.category_id)expect(json[:can_edit]).to eq(true)expect(json[:version]).to eq(0)+ expect(json[:removed_topic_id]).to be_nil+ end++ it 'Includes the removed topic id when the topis was deleted' do+ reviewable.topic.trash!(admin)++ json = described_class.new(reviewable.reload, scope: Guardian.new(admin), root: nil).as_json++ expect(json[:removed_topic_id]).to eq reviewable.topic_idendit "will not throw an error when the payload is `nil`" do@@ -22,5 +31,4 @@ describe ReviewableSerializer dojson = ReviewableQueuedPostSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_jsonexpect(json['payload']).to be_blankend-end