Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Fletcher <mark@gitlab.com>2017-09-03 08:49:19 +0300
committerMark Fletcher <mark@gitlab.com>2017-09-06 05:02:04 +0300
commited43c6f1fd2c01307c4fe9fb8ba52a7c1a72f624 (patch)
tree140fffd624d2eac0697e903cf13073f0706ec060 /app/helpers/search_helper.rb
parent81002745184df28fc9d969afc524986279c653bb (diff)
Hide admin link from default search results for non-admins
Diffstat (limited to 'app/helpers/search_helper.rb')
-rw-r--r--app/helpers/search_helper.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index ae0e0aa3cf9..98e824a8c65 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -10,6 +10,7 @@ module SearchHelper
search_pattern = Regexp.new(Regexp.escape(term), "i")
generic_results = project_autocomplete + default_autocomplete + help_autocomplete
+ generic_results.concat(default_autocomplete_admin) if current_user.admin?
generic_results.select! { |result| result[:label] =~ search_pattern }
[
@@ -41,8 +42,14 @@ module SearchHelper
[
{ category: "Settings", label: "User settings", url: profile_path },
{ category: "Settings", label: "SSH Keys", url: profile_keys_path },
- { category: "Settings", label: "Dashboard", url: root_path },
- { category: "Settings", label: "Admin Section", url: admin_root_path }
+ { category: "Settings", label: "Dashboard", url: root_path }
+ ]
+ end
+
+ # Autocomplete results for settings pages, for admins
+ def default_autocomplete_admin
+ [
+ { category: "Settings", label: "Admin Section", url: admin_root_path }
]
end