add feature flag for users search

This commit is contained in:
Alexis Reigel 2018-12-19 15:24:46 +01:00
parent c36d98501b
commit 55629a2e4d
No known key found for this signature in database
GPG key ID: 55ADA7C7B683B329
5 changed files with 20 additions and 3 deletions

View file

@ -56,6 +56,8 @@ class SearchController < ApplicationController
end end
def eager_load_user_status def eager_load_user_status
return if Feature.disabled?(:users_search, default_enabled: true)
@search_objects = @search_objects.eager_load(:status) # rubocop:disable CodeReuse/ActiveRecord @search_objects = @search_objects.eager_load(:status) # rubocop:disable CodeReuse/ActiveRecord
end end

View file

@ -203,6 +203,8 @@ module SearchHelper
end end
def search_tabs?(tab) def search_tabs?(tab)
return false if Feature.disabled?(:users_search, default_enabled: true)
if @project if @project
project_search_tabs?(:members) project_search_tabs?(:members)
else else

View file

@ -23,7 +23,8 @@ module Search
def allowed_scopes def allowed_scopes
strong_memoize(:allowed_scopes) do strong_memoize(:allowed_scopes) do
%w[issues merge_requests milestones users] allowed_scopes = %w[issues merge_requests milestones]
allowed_scopes << 'users' if Feature.enabled?(:users_search, default_enabled: true)
end end
end end

View file

@ -16,7 +16,12 @@ module Search
end end
def scope def scope
@scope ||= %w[notes issues merge_requests milestones wiki_blobs commits users].delete(params[:scope]) { 'blobs' } @scope ||= begin
allowed_scopes = %w[notes issues merge_requests milestones wiki_blobs commits]
allowed_scopes << 'users' if Feature.enabled?(:users_search, default_enabled: true)
allowed_scopes.delete(params[:scope]) { 'blobs' }
end
end end
end end
end end

View file

@ -54,7 +54,14 @@ module API
end end
params :scope do |options| params :scope do |options|
values = SCOPE_ENTITY.stringify_keys.slice(*options[:values]).keys scope_entities =
if Feature.enabled?(:users_search, default_enabled: true)
SCOPE_ENTITY
else
SCOPE_ENTITY.reject { |key, value| key == :users }
end
values = scope_entities.stringify_keys.slice(*options[:values]).keys
requires :scope, requires :scope,
type: String, type: String,