Show link to the original topic when it was deleted (#7319)
* Moved i18n keys to core. We show a links that points to the original topic when it was deleted * Use link-to since it's more idiomatic
This commit is contained in:
parent
b5008586c5
commit
82e051077d
|
@ -7,6 +7,9 @@
|
||||||
{{else if (has-block)}}
|
{{else if (has-block)}}
|
||||||
{{yield}}
|
{{yield}}
|
||||||
{{else}}
|
{{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}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -72,7 +72,8 @@ class ReviewableSerializer < ApplicationSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def attributes
|
def attributes
|
||||||
data = super
|
super.tap do |data|
|
||||||
|
data[:removed_topic_id] = object.topic_id unless object.topic
|
||||||
|
|
||||||
if object.target.present?
|
if object.target.present?
|
||||||
# Automatically add the target id as a "good name" for example a target_type of `User`
|
# Automatically add the target id as a "good name" for example a target_type of `User`
|
||||||
|
@ -83,8 +84,7 @@ class ReviewableSerializer < ApplicationSerializer
|
||||||
if self.class._payload_for_serialization.present?
|
if self.class._payload_for_serialization.present?
|
||||||
data[:payload] = (object.payload || {}).slice(*self.class._payload_for_serialization)
|
data[:payload] = (object.payload || {}).slice(*self.class._payload_for_serialization)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
data
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def topic_tags
|
def topic_tags
|
||||||
|
|
|
@ -404,6 +404,8 @@ en:
|
||||||
topic: "Topic"
|
topic: "Topic"
|
||||||
reviewable_count: "Count"
|
reviewable_count: "Count"
|
||||||
reported_by: "Reported by"
|
reported_by: "Reported by"
|
||||||
|
deleted: "[Topic Deleted]"
|
||||||
|
original: '(original topic)'
|
||||||
details: "details"
|
details: "details"
|
||||||
unique_users:
|
unique_users:
|
||||||
one: "1 user"
|
one: "1 user"
|
||||||
|
|
|
@ -6,7 +6,7 @@ describe ReviewableSerializer do
|
||||||
let(:admin) { Fabricate(:admin) }
|
let(:admin) { Fabricate(:admin) }
|
||||||
|
|
||||||
it "serializes all the fields" do
|
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_json
|
||||||
|
|
||||||
expect(json[:id]).to eq(reviewable.id)
|
expect(json[:id]).to eq(reviewable.id)
|
||||||
expect(json[:status]).to eq(reviewable.status)
|
expect(json[:status]).to eq(reviewable.status)
|
||||||
|
@ -15,6 +15,15 @@ describe ReviewableSerializer do
|
||||||
expect(json[:category_id]).to eq(reviewable.category_id)
|
expect(json[:category_id]).to eq(reviewable.category_id)
|
||||||
expect(json[:can_edit]).to eq(true)
|
expect(json[:can_edit]).to eq(true)
|
||||||
expect(json[:version]).to eq(0)
|
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_id
|
||||||
end
|
end
|
||||||
|
|
||||||
it "will not throw an error when the payload is `nil`" do
|
it "will not throw an error when the payload is `nil`" do
|
||||||
|
@ -22,5 +31,4 @@ describe ReviewableSerializer do
|
||||||
json = ReviewableQueuedPostSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_json
|
json = ReviewableQueuedPostSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_json
|
||||||
expect(json['payload']).to be_blank
|
expect(json['payload']).to be_blank
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue