mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Add "Reset Bump Date" action to topic admin wrench (#6246)
This commit is contained in:
@@ -930,6 +930,10 @@ export default Ember.Controller.extend(BufferedContent, {
|
||||
|
||||
removeFeaturedLink() {
|
||||
this.set("buffered.featured_link", null);
|
||||
},
|
||||
|
||||
resetBumpDate() {
|
||||
this.get("content").resetBumpDate();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -565,6 +565,12 @@ const Topic = RestModel.extend({
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
},
|
||||
|
||||
resetBumpDate() {
|
||||
return ajax(`/t/${this.get("id")}/reset-bump-date`, { type: "PUT" }).catch(
|
||||
popupAjaxError
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
showTopicStatusUpdate=showTopicStatusUpdate
|
||||
showFeatureTopic=showFeatureTopic
|
||||
showChangeTimestamp=showChangeTimestamp
|
||||
resetBumpDate=resetBumpDate
|
||||
convertToPublicTopic=convertToPublicTopic
|
||||
convertToPrivateMessage=convertToPrivateMessage}}
|
||||
{{/if}}
|
||||
|
||||
@@ -94,6 +94,7 @@
|
||||
showTopicStatusUpdate=(action "topicRouteAction" "showTopicStatusUpdate")
|
||||
showFeatureTopic=(action "topicRouteAction" "showFeatureTopic")
|
||||
showChangeTimestamp=(action "topicRouteAction" "showChangeTimestamp")
|
||||
resetBumpDate=(action "resetBumpDate")
|
||||
convertToPublicTopic=(action "convertToPublicTopic")
|
||||
convertToPrivateMessage=(action "convertToPrivateMessage")}}
|
||||
{{/if}}
|
||||
@@ -121,6 +122,7 @@
|
||||
showTopicStatusUpdate=(action "topicRouteAction" "showTopicStatusUpdate")
|
||||
showFeatureTopic=(action "topicRouteAction" "showFeatureTopic")
|
||||
showChangeTimestamp=(action "topicRouteAction" "showChangeTimestamp")
|
||||
resetBumpDate=(action "resetBumpDate")
|
||||
convertToPublicTopic=(action "convertToPublicTopic")
|
||||
convertToPrivateMessage=(action "convertToPrivateMessage")}}
|
||||
{{else}}
|
||||
@@ -144,6 +146,7 @@
|
||||
showTopicStatusUpdate=(action "topicRouteAction" "showTopicStatusUpdate")
|
||||
showFeatureTopic=(action "topicRouteAction" "showFeatureTopic")
|
||||
showChangeTimestamp=(action "topicRouteAction" "showChangeTimestamp")
|
||||
resetBumpDate=(action "resetBumpDate")
|
||||
convertToPublicTopic=(action "convertToPublicTopic")
|
||||
convertToPrivateMessage=(action "convertToPrivateMessage")}}
|
||||
{{/if}}
|
||||
@@ -256,6 +259,7 @@
|
||||
showTopicStatusUpdate=(action "topicRouteAction" "showTopicStatusUpdate")
|
||||
showFeatureTopic=(action "topicRouteAction" "showFeatureTopic")
|
||||
showChangeTimestamp=(action "topicRouteAction" "showChangeTimestamp")
|
||||
resetBumpDate=(action "resetBumpDate")
|
||||
convertToPublicTopic=(action "convertToPublicTopic")
|
||||
convertToPrivateMessage=(action "convertToPrivateMessage")
|
||||
toggleBookmark=(action "toggleBookmark")
|
||||
|
||||
@@ -203,6 +203,15 @@ export default createWidget("topic-admin-menu", {
|
||||
});
|
||||
}
|
||||
|
||||
if (this.currentUser.get("staff")) {
|
||||
buttons.push({
|
||||
className: "topic-admin-reset-bump-date",
|
||||
action: "resetBumpDate",
|
||||
icon: "anchor",
|
||||
label: "actions.reset_bump_date"
|
||||
});
|
||||
}
|
||||
|
||||
if (!isPrivateMessage) {
|
||||
buttons.push({
|
||||
className: "topic-admin-archive",
|
||||
|
||||
@@ -33,7 +33,8 @@ class TopicsController < ApplicationController
|
||||
:move_to_inbox,
|
||||
:convert_topic,
|
||||
:bookmark,
|
||||
:publish
|
||||
:publish,
|
||||
:reset_bump_date
|
||||
]
|
||||
|
||||
before_action :consider_user_for_promotion, only: :show
|
||||
@@ -720,6 +721,17 @@ class TopicsController < ApplicationController
|
||||
render_json_error(ex)
|
||||
end
|
||||
|
||||
def reset_bump_date
|
||||
params.require(:id)
|
||||
guardian.ensure_can_update_bumped_at!
|
||||
|
||||
topic = Topic.find_by(id: params[:id])
|
||||
raise Discourse::NotFound.new unless topic
|
||||
|
||||
topic.reset_bumped_at
|
||||
render body: nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def topic_params
|
||||
|
||||
@@ -1381,6 +1381,16 @@ class Topic < ActiveRecord::Base
|
||||
@is_category_topic ||= Category.exists?(topic_id: self.id.to_i)
|
||||
end
|
||||
|
||||
def reset_bumped_at
|
||||
post = ordered_posts.where(
|
||||
user_deleted: false,
|
||||
hidden: false,
|
||||
post_type: Topic.visible_post_types
|
||||
).last
|
||||
|
||||
update!(bumped_at: post.created_at)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_category_topic_count_by(num)
|
||||
|
||||
Reference in New Issue
Block a user