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-08-01 22:05:46 +0300
committerStan Hu <stanhu@gmail.com>2018-08-01 22:05:46 +0300
commit075ee4780e8069728d3836140e099fc5226be435 (patch)
tree2adf867d7f3735c7f31cc826f78b7bcb71b98fb1 /app/helpers/namespaces_helper.rb
parentaa5821e571620e09229721a1a235d93a554db6a3 (diff)
Fix selection of existing project key by default
Diffstat (limited to 'app/helpers/namespaces_helper.rb')
-rw-r--r--app/helpers/namespaces_helper.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb
index 3f528c42cb6..e80ac9305ff 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_id = current_user.namespace.id
unless extra_group.nil? || extra_group.is_a?(Group)
extra_group = Group.find(extra_group) if Namespace.find(extra_group).kind == 'group'
@@ -23,11 +24,11 @@ module NamespacesHelper
end
if Ability.allowed?(current_user, :read_group, extra_group)
- selected = extra_group.id if selected == :extra_group
+ # Assign the value to an invalid primary ID so that the select box works
+ extra_group.id = -1 if !extra_group.persisted?
+ selected_id = extra_group.id if selected == :extra_group
groups |= [extra_group]
end
-
- selected ||= :current_user
end
options = []
@@ -37,11 +38,11 @@ module NamespacesHelper
options << options_for_group(users, display_path: display_path, type: 'user')
if selected == :current_user && current_user.namespace
- selected = current_user.namespace.id
+ selected_id = current_user.namespace.id
end
end
- grouped_options_for_select(options, selected)
+ grouped_options_for_select(options, selected_id)
end
def namespace_icon(namespace, size = 40)