FEATURE: Add site setting to disable group directory.

This commit is contained in:
Guo Xiang Tan 2016-12-22 14:14:03 +08:00
parent c531f4ded5
commit 8551d821a0
5 changed files with 22 additions and 1 deletions

View File

@ -103,7 +103,9 @@ export default createWidget('hamburger-menu', {
links.push({ route: 'users', className: 'user-directory-link', label: 'directory.title' });
}
links.push({ route: 'groups', className: 'groups-link', label: 'groups.index.title' });
if (!this.siteSettings.show_group_directory) {
links.push({ route: 'groups', className: 'groups-link', label: 'groups.index.title' });
}
if (this.siteSettings.tagging_enabled) {
links.push({ route: 'tags', label: 'tagging.tags' });

View File

@ -11,6 +11,10 @@ class GroupsController < ApplicationController
skip_before_filter :preload_json, :check_xhr, only: [:posts_feed, :mentions_feed]
def index
unless SiteSetting.enable_group_directory?
raise Discourse::InvalidAccess.new(:enable_group_directory)
end
page_size = 30
page = params[:page]&.to_i || 0

View File

@ -1315,6 +1315,7 @@ en:
public_user_custom_fields: "A whitelist of custom fields for a user that can be shown publicly."
staff_user_custom_fields: "A whitelist of custom fields for a user that can be shown to staff."
enable_user_directory: "Provide a directory of users for browsing"
enable_group_directory: "Provide a directory of groups for browsing"
allow_anonymous_posting: "Allow users to switch to anonymous mode"
anonymous_posting_min_trust_level: "Minimum trust level required to enable anonymous posting"
anonymous_account_duration_minutes: "To protect anonymity create a new anonymous account every N minutes for each user. Example: if set to 600, as soon as 600 minutes elapse from last post AND user switches to anon, a new anonymous account is created."

View File

@ -411,6 +411,11 @@ users:
default: false
client: true
groups:
enable_group_directory:
client: true
default: true
posting:
min_post_length:
client: true

View File

@ -14,6 +14,15 @@ describe "Groups" do
group.update_attributes!(automatic: true, visible: true)
end
context 'when group directory is disabled' do
site_setting(:enable_group_directory, false)
it 'should deny access' do
get "/groups.json"
expect(response).to be_forbidden
end
end
it 'should return the right response' do
get "/groups.json"