mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06:00
FEATURE: Allow category group moderators to list/unlist topics (#11470)
* FEATURE: Allow categroy group moderators to list/unlist topics If enabled via SiteSettings, a user belonging to a group which has been granted category group moderator privileges should be able to list/unlist topics belonging to the appropraite category.
This commit is contained in:
parent
2d51833ca9
commit
773c51a633
@ -250,7 +250,7 @@ export default createWidget("topic-admin-menu", {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.get("currentUser.canManageTopic")) {
|
||||
if (details.get("can_toggle_topic_visibility")) {
|
||||
this.addActionButton({
|
||||
className: "topic-admin-visible",
|
||||
buttonClass: "popup-menu-btn",
|
||||
@ -258,7 +258,9 @@ export default createWidget("topic-admin-menu", {
|
||||
icon: visible ? "far-eye-slash" : "far-eye",
|
||||
label: visible ? "actions.invisible" : "actions.visible",
|
||||
});
|
||||
}
|
||||
|
||||
if (this.get("currentUser.canManageTopic")) {
|
||||
if (details.get("can_convert_topic")) {
|
||||
this.addActionButton({
|
||||
className: "topic-admin-convert",
|
||||
|
@ -2205,6 +2205,7 @@ export default {
|
||||
details: {
|
||||
can_publish_page: true,
|
||||
can_invite_via_email: true,
|
||||
can_toggle_topic_visibility: true,
|
||||
auto_close_at: null,
|
||||
auto_close_hours: null,
|
||||
auto_close_based_on_last_post: false,
|
||||
@ -5592,6 +5593,7 @@ export default {
|
||||
can_review_topic: true,
|
||||
can_close_topic: true,
|
||||
can_archive_topic: true,
|
||||
can_toggle_topic_visibility: true,
|
||||
can_split_merge_topic: true,
|
||||
can_edit_staff_notes: true,
|
||||
can_moderate_category: true,
|
||||
|
@ -420,6 +420,8 @@ class TopicsController < ApplicationController
|
||||
guardian.ensure_can_close_topic!(@topic)
|
||||
when 'archived'
|
||||
guardian.ensure_can_archive_topic!(@topic)
|
||||
when 'visible'
|
||||
guardian.ensure_can_toggle_topic_visibility!(@topic)
|
||||
else
|
||||
guardian.ensure_can_moderate!(@topic)
|
||||
end
|
||||
|
@ -20,6 +20,7 @@ class TopicViewDetailsSerializer < ApplicationSerializer
|
||||
:can_archive_topic,
|
||||
:can_split_merge_topic,
|
||||
:can_edit_staff_notes,
|
||||
:can_toggle_topic_visibility,
|
||||
:can_moderate_category]
|
||||
end
|
||||
|
||||
@ -144,6 +145,10 @@ class TopicViewDetailsSerializer < ApplicationSerializer
|
||||
!scope.can_edit?(object.topic) && scope.can_edit_tags?(object.topic)
|
||||
end
|
||||
|
||||
def include_can_toggle_topic_visibility?
|
||||
scope.can_toggle_topic_visibility?(object.topic)
|
||||
end
|
||||
|
||||
def can_perform_action_available_to_group_moderators?
|
||||
@can_perform_action_available_to_group_moderators ||= scope.can_perform_action_available_to_group_moderators?(object.topic)
|
||||
end
|
||||
|
@ -146,6 +146,10 @@ module TopicGuardian
|
||||
!Discourse.static_doc_topic_ids.include?(topic.id)
|
||||
end
|
||||
|
||||
def can_toggle_topic_visibility?(topic)
|
||||
can_moderate?(topic) || can_perform_action_available_to_group_moderators?(topic)
|
||||
end
|
||||
|
||||
def can_convert_topic?(topic)
|
||||
return false unless SiteSetting.enable_personal_messages?
|
||||
return false if topic.blank?
|
||||
|
@ -948,6 +948,28 @@ RSpec.describe TopicsController do
|
||||
expect(response.status).to eq(403)
|
||||
expect(topic.reload.pinned_at).to eq(nil)
|
||||
end
|
||||
|
||||
it 'should allow a group moderator to unlist a topic' do
|
||||
put "/t/#{topic.id}/status.json", params: {
|
||||
status: 'visible', enabled: 'false'
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(topic.reload.visible).to eq(false)
|
||||
expect(topic.posts.last.action_code).to eq('visible.disabled')
|
||||
end
|
||||
|
||||
it 'should allow a group moderator to list an unlisted topic' do
|
||||
topic.update!(visible: false)
|
||||
|
||||
put "/t/#{topic.id}/status.json", params: {
|
||||
status: 'visible', enabled: 'true'
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(topic.reload.visible).to eq(true)
|
||||
expect(topic.posts.last.action_code).to eq('visible.enabled')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user