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:
authorStan Hu <stanhu@gmail.com>2018-07-31 22:50:12 +0300
committerStan Hu <stanhu@gmail.com>2018-07-31 22:50:12 +0300
commit1528df0f514e8ac59d33054ef68c901eae2194eb (patch)
treef13e8a91ae196dd5237b5dc53cb6f648d6771b14 /app/helpers/namespaces_helper.rb
parent852b5613c5eda43a9dce20ca9a71301f5630b1c6 (diff)
Default to importing to the current project key
Diffstat (limited to 'app/helpers/namespaces_helper.rb')
-rw-r--r--app/helpers/namespaces_helper.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb
index 19aa630007d..1503aea4aa2 100644
--- a/app/helpers/namespaces_helper.rb
+++ b/app/helpers/namespaces_helper.rb
@@ -9,6 +9,7 @@ module NamespacesHelper
.includes(:route)
.order('routes.path')
users = [current_user.namespace]
+ selected_option = nil
unless extra_group.nil? || extra_group.is_a?(Group)
extra_group = Group.find(extra_group) if Namespace.find(extra_group).kind == 'group'
@@ -18,7 +19,11 @@ module NamespacesHelper
# Avoid duplicate groups if one already exists by that name
existing_group = Group.find_by(name: extra_group.name)
extra_group = existing_group if existing_group
- groups |= [extra_group] if Ability.allowed?(current_user, :read_group, extra_group)
+
+ if Ability.allowed?(current_user, :read_group, extra_group)
+ groups |= [extra_group]
+ selected_option = extra_group.id if selected == :extra_group
+ end
end
options = []
@@ -27,12 +32,12 @@ module NamespacesHelper
unless groups_only
options << options_for_group(users, display_path: display_path, type: 'user')
- if selected == :current_user && current_user.namespace
- selected = current_user.namespace.id
+ if (selected == :current_user || selected_option.nil?) && current_user.namespace
+ selected_option = current_user.namespace.id
end
end
- grouped_options_for_select(options, selected)
+ grouped_options_for_select(options, selected_option)
end
def namespace_icon(namespace, size = 40)