mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
FEATURE: staff option to unhide a post
This commit is contained in:
parent
e8522e839b
commit
0b13f6572f
10 changed files with 63 additions and 24 deletions
|
@ -397,6 +397,10 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, {
|
|||
|
||||
rebakePost: function (post) {
|
||||
post.rebake();
|
||||
},
|
||||
|
||||
unhidePost: function (post) {
|
||||
post.unhide();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -512,30 +516,30 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, {
|
|||
}
|
||||
|
||||
var postStream = topicController.get('postStream');
|
||||
if (data.type === "revised" || data.type === "acted") {
|
||||
// TODO we could update less data for "acted"
|
||||
// (only post actions)
|
||||
postStream.triggerChangedPost(data.id, data.updated_at);
|
||||
return;
|
||||
switch (data.type) {
|
||||
case "revised":
|
||||
case "acted":
|
||||
case "rebaked": {
|
||||
// TODO we could update less data for "acted" (only post actions)
|
||||
postStream.triggerChangedPost(data.id, data.updated_at);
|
||||
return;
|
||||
}
|
||||
case "deleted": {
|
||||
postStream.triggerDeletedPost(data.id, data.post_number);
|
||||
return;
|
||||
}
|
||||
case "recovered": {
|
||||
postStream.triggerRecoveredPost(data.id, data.post_number);
|
||||
return;
|
||||
}
|
||||
case "created": {
|
||||
postStream.triggerNewPostInStream(data.id);
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
Em.Logger.warn("unknown topic bus message type", data);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === "deleted") {
|
||||
postStream.triggerDeletedPost(data.id, data.post_number);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.type === "recovered") {
|
||||
postStream.triggerRecoveredPost(data.id, data.post_number);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.type === "created") {
|
||||
postStream.triggerNewPostInStream(data.id);
|
||||
return;
|
||||
}
|
||||
|
||||
// log a warning
|
||||
Em.Logger.warn("unknown topic bus message type", data);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -404,6 +404,10 @@ Discourse.Post = Discourse.Model.extend({
|
|||
|
||||
rebake: function () {
|
||||
return Discourse.ajax("/posts/" + this.get("id") + "/rebake", { type: "PUT" });
|
||||
},
|
||||
|
||||
unhide: function () {
|
||||
return Discourse.ajax("/posts/" + this.get("id") + "/unhide", { type: "PUT" });
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -287,12 +287,16 @@ export default Discourse.View.extend({
|
|||
var rebakePostIcon = '<i class="fa fa-cog"></i>',
|
||||
rebakePostText = I18n.t('post.controls.rebake');
|
||||
|
||||
var unhidePostIcon = '<i class="fa fa-eye"></i>',
|
||||
unhidePostText = I18n.t('post.controls.unhide');
|
||||
|
||||
var html = '<div class="post-admin-menu">' +
|
||||
'<h3>' + I18n.t('admin_title') + '</h3>' +
|
||||
'<ul>' +
|
||||
'<li class="btn btn-admin" data-action="toggleWiki">' + wikiIcon + wikiText + '</li>' +
|
||||
'<li class="btn btn-admin" data-action="togglePostType">' + postTypeIcon + postTypeText + '</li>' +
|
||||
'<li class="btn btn-admin" data-action="rebakePost">' + rebakePostIcon + rebakePostText + '</li>' +
|
||||
(post.hidden ? '<li class="btn btn-admin" data-action="unhidePost">' + unhidePostIcon + unhidePostText + '</li>' : '') +
|
||||
'</ul>' +
|
||||
'</div>';
|
||||
|
||||
|
@ -317,6 +321,10 @@ export default Discourse.View.extend({
|
|||
this.get("controller").send("rebakePost", this.get("post"));
|
||||
},
|
||||
|
||||
clickUnhidePost: function () {
|
||||
this.get("controller").send("unhidePost", this.get("post"));
|
||||
},
|
||||
|
||||
buttonForShowMoreActions: function() {
|
||||
return new Button('showMoreActions', 'show_more', 'ellipsis-h');
|
||||
},
|
||||
|
|
|
@ -162,4 +162,4 @@ kbd
|
|||
padding: .1em .6em;
|
||||
|
||||
* * { display: none; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,6 +261,16 @@ class PostsController < ApplicationController
|
|||
render nothing: true
|
||||
end
|
||||
|
||||
def unhide
|
||||
post = find_post_from_params
|
||||
|
||||
guardian.ensure_can_unhide!(post)
|
||||
|
||||
post.unhide!
|
||||
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
def flagged_posts
|
||||
params.permit(:offset, :limit)
|
||||
guardian.ensure_can_see_flagged_posts!
|
||||
|
|
|
@ -293,6 +293,7 @@ class Post < ActiveRecord::Base
|
|||
self.update_attributes(hidden: false, hidden_at: nil, hidden_reason_id: nil)
|
||||
self.topic.update_attributes(visible: true)
|
||||
save(validate: false)
|
||||
publish_change_to_clients!(:acted)
|
||||
end
|
||||
|
||||
def url
|
||||
|
@ -352,6 +353,8 @@ class Post < ActiveRecord::Base
|
|||
# make sure we trigger the post process
|
||||
trigger_post_process(true)
|
||||
|
||||
publish_change_to_clients!(:rebaked)
|
||||
|
||||
new_cooked != old_cooked
|
||||
end
|
||||
|
||||
|
|
|
@ -1112,6 +1112,7 @@ en:
|
|||
convert_to_moderator: "Add Staff Color"
|
||||
revert_to_regular: "Remove Staff Color"
|
||||
rebake: "Rebuild HTML"
|
||||
unhide: "Unhide"
|
||||
|
||||
actions:
|
||||
flag: 'Flag'
|
||||
|
|
|
@ -265,6 +265,7 @@ Discourse::Application.routes.draw do
|
|||
put "wiki"
|
||||
put "post_type"
|
||||
put "rebake"
|
||||
put "unhide"
|
||||
get "replies"
|
||||
get "revisions/:revision" => "posts#revisions"
|
||||
put "recover"
|
||||
|
|
|
@ -184,4 +184,8 @@ module PostGuardian
|
|||
def can_see_deleted_posts?
|
||||
is_staff?
|
||||
end
|
||||
|
||||
def can_unhide?(post)
|
||||
post.try(:hidden) && is_staff?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -823,6 +823,8 @@ describe Post do
|
|||
Post.exec_sql("UPDATE posts SET cooked = 'frogs' WHERE id = ?", post.id)
|
||||
post.reload
|
||||
|
||||
post.expects(:publish_change_to_clients!).with(:rebaked)
|
||||
|
||||
result = post.rebake!
|
||||
|
||||
post.baked_at.should_not == first_baked
|
||||
|
@ -857,6 +859,8 @@ describe Post do
|
|||
|
||||
post.hidden.should == true
|
||||
|
||||
post.expects(:publish_change_to_clients!).with(:acted)
|
||||
|
||||
post.unhide!
|
||||
post.reload
|
||||
|
||||
|
|
Loading…
Reference in a new issue