summaryrefslogtreecommitdiff
path: root/app/helpers/namespaces_helper.rb
diff options
context:
space:
mode:
authorRubén Dávila <ruben@gitlab.com>2017-08-29 00:49:01 -0500
committerRubén Dávila <ruben@gitlab.com>2017-08-29 00:53:35 -0500
commit6f03ddcdc3af1fbb840498a0e4765458079f0b0f (patch)
tree9301cd3835e573d491dd8799533799365df996bd /app/helpers/namespaces_helper.rb
parent0a8d0924fe9a1525b92423411dc1bfcdc9760833 (diff)
downloadgitlab-ce-6f03ddcdc3af1fbb840498a0e4765458079f0b0f.tar.gz
Address some suggestions from first code review
Diffstat (limited to 'app/helpers/namespaces_helper.rb')
-rw-r--r--app/helpers/namespaces_helper.rb15
1 files changed, 7 insertions, 8 deletions
diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb
index 33d6875a704..3c784272df2 100644
--- a/app/helpers/namespaces_helper.rb
+++ b/app/helpers/namespaces_helper.rb
@@ -6,7 +6,6 @@ module NamespacesHelper
def namespaces_options(selected = :current_user, display_path: false, extra_group: nil)
groups = current_user.owned_groups + current_user.masters_groups
users = [current_user.namespace]
- options = []
unless extra_group.nil? || extra_group.is_a?(Group)
extra_group = Group.find(extra_group) if Namespace.find(extra_group).kind == 'group'
@@ -16,8 +15,9 @@ module NamespacesHelper
groups |= [extra_group]
end
- options << options_for_group(groups, display_path)
- options << options_for_group(users, display_path)
+ options = []
+ options << options_for_group(groups, display_path: display_path, type: 'group')
+ options << options_for_group(users, display_path: display_path, type: 'user')
if selected == :current_user && current_user.namespace
selected = current_user.namespace.id
@@ -36,13 +36,12 @@ module NamespacesHelper
private
- def options_for_group(namespaces, display_path)
- type = namespaces.first.is_a?(Group) ? 'group' : 'users'
-
+ def options_for_group(namespaces, display_path:, type:)
+ group_label = type.pluralize
elements = namespaces.sort_by(&:human_name).map! do |n|
[display_path ? n.full_path : n.human_name, n.id,
data: {
- options_parent: type,
+ options_parent: group_label,
visibility_level: n.visibility_level_value,
visibility: n.visibility,
name: n.name,
@@ -51,6 +50,6 @@ module NamespacesHelper
}]
end
- [type.camelize, elements]
+ [group_label.camelize, elements]
end
end