Skip to content

A platform for community discussion. Free, open, simple.

UX: update topic small action post to add link for new linked topic URL (#11132)

Arpit Jalan436bd4851297
diff --git a/app/jobs/regular/create_linked_topic.rb b/app/jobs/regular/create_linked_topic.rb
index 9600e01b8f0..2e358633716 100644
--- a/app/jobs/regular/create_linked_topic.rb
+++ b/app/jobs/regular/create_linked_topic.rb
@@ -75,8 +75,12 @@ module Jobs
ON CONFLICT (topic_id, user_id) DO NOTHING
SQL
- # add moderator post to old topic
- parent_topic.add_moderator_post(system_user, I18n.t('create_linked_topic.moderator_post_raw', new_url: new_topic.url))
+ # update small action post on old topic to add new topic link
+ small_action_post = Post.where(topic_id: parent_topic_id, post_type: Post.types[:small_action], action_code: "closed.enabled").last
+ if small_action_post.present?
+ small_action_post.raw = "#{small_action_post.raw} #{I18n.t('create_linked_topic.small_action_post_raw', new_title: "[#{new_topic_title}](#{new_topic.url})")}"
+ small_action_post.save!
+ end
end
@post_creator.enqueue_jobs if @post_creator
end
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 5c29c4aca41..5cc3a78e476 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -4945,4 +4945,4 @@ en:
one: "%{topic_title} (Part %{count})"
other: "%{topic_title} (Part %{count})"
post_raw: "Continuing the discussion from %{parent_url}.\n\nPrevious discussions:\n\n%{previous_topics}"
- moderator_post_raw: "Continue discussion here: %{new_url}"
+ small_action_post_raw: "Continue discussion at %{new_title}."
diff --git a/spec/jobs/create_linked_topic_spec.rb b/spec/jobs/create_linked_topic_spec.rb
index b74bd450893..6b48cbe400c 100644
--- a/spec/jobs/create_linked_topic_spec.rb
+++ b/spec/jobs/create_linked_topic_spec.rb
@@ -37,6 +37,7 @@ describe Jobs::CreateLinkedTopic do
end
it 'creates a linked topic' do
+ small_action_post = Fabricate(:post, topic: topic, post_type: Post.types[:small_action], action_code: "closed.enabled")
Jobs::CreateLinkedTopic.new.execute(post_id: post.id)
raw_title = topic.title
@@ -44,7 +45,7 @@ describe Jobs::CreateLinkedTopic do
new_topic = Topic.last
linked_topic = new_topic.linked_topic
expect(topic.title).to include(I18n.t("create_linked_topic.topic_title_with_sequence", topic_title: raw_title, count: 1))
- expect(topic.posts.last.raw).to eq(I18n.t('create_linked_topic.moderator_post_raw', new_url: new_topic.url))
+ expect(topic.posts.last.raw).to include(I18n.t('create_linked_topic.small_action_post_raw', new_title: "[#{new_topic.title}](#{new_topic.url})"))
expect(new_topic.title).to include(I18n.t("create_linked_topic.topic_title_with_sequence", topic_title: raw_title, count: 2))
expect(new_topic.first_post.raw).to include(topic.url)
expect(new_topic.topic_users.count).to eq(3)