summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-09-19 12:29:49 +0200
committerJames Lopez <james@jameslopez.es>2016-09-20 10:15:20 +0200
commit254c5aaa92c336d8e17beae546b34a056a954c17 (patch)
tree2575c3c93bdb7e6123e40afa1ab9f9cfd4a80c71
parent173b1128ff485d6614b8a785796d575d4d84dd68 (diff)
downloadgitlab-ce-254c5aaa92c336d8e17beae546b34a056a954c17.tar.gz
few fixes based on MR feedback
-rw-r--r--app/assets/javascripts/importer_status.js10
-rw-r--r--app/helpers/namespaces_helper.rb13
-rw-r--r--app/views/import/github/status.html.haml8
3 files changed, 11 insertions, 20 deletions
diff --git a/app/assets/javascripts/importer_status.js b/app/assets/javascripts/importer_status.js
index 9fe00a0a4db..abc62de2279 100644
--- a/app/assets/javascripts/importer_status.js
+++ b/app/assets/javascripts/importer_status.js
@@ -10,24 +10,24 @@
ImporterStatus.prototype.initStatusPage = function() {
$('.js-add-to-import').off('click').on('click', (function(_this) {
return function(e) {
- var $btn, $namespace_input, $target_field, $tr, id, target_namespace;
+ var $btn, $namespace_input, $target_field, $tr, id, target_namespace, newName;
$btn = $(e.currentTarget);
$tr = $btn.closest('tr');
$target_field = $tr.find('.import-target');
$namespace_input = $target_field.find('.js-select-namespace option:selected');
id = $tr.attr('id').replace('repo_', '');
target_namespace = null;
- new_name = null;
+ newName = null;
if ($namespace_input.length > 0) {
target_namespace = $namespace_input[0].innerHTML;
- new_name = $target_field.find('#path').prop('value');
- $target_field.empty().append(target_namespace + "/" + new_name);
+ newName = $target_field.find('#path').prop('value');
+ $target_field.empty().append(target_namespace + "/" + newName);
}
$btn.disable().addClass('is-loading');
return $.post(_this.import_url, {
repo_id: id,
target_namespace: target_namespace,
- new_name: new_name
+ new_name: newName
}, {
dataType: 'script'
});
diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb
index 4641076d22c..e0b8dc1393b 100644
--- a/app/helpers/namespaces_helper.rb
+++ b/app/helpers/namespaces_helper.rb
@@ -1,8 +1,8 @@
module NamespacesHelper
- def namespaces_options(selected = :current_user, extra_groups = [], display_path: false)
+ def namespaces_options(selected = :current_user, display_path: false, extra_group: nil)
groups = current_user.owned_groups + current_user.masters_groups
- groups += process_extra_groups(extra_groups) if extra_groups.any?
+ groups << extra_group if extra_group && !Group.exists?(name: extra_group.name)
users = [current_user.namespace]
@@ -28,15 +28,6 @@ module NamespacesHelper
grouped_options_for_select(options, selected)
end
- def process_extra_groups(extra_groups)
- # Remove duplicate groups - we either keep the ones that exist for the user
- # (already in groups) or ignore those that do not belong to the user.
- duplicated_groups = extra_groups.map { |name| Namespace.where(name: name).pluck(:name) }
- extra_groups = extra_groups - duplicated_groups.flatten
-
- extra_groups.map { |name| Group.new(name: name) }
- end
-
def namespace_icon(namespace, size = 40)
if namespace.kind_of?(Group)
group_icon(namespace)
diff --git a/app/views/import/github/status.html.haml b/app/views/import/github/status.html.haml
index 8e552fbd005..6d7193599f4 100644
--- a/app/views/import/github/status.html.haml
+++ b/app/views/import/github/status.html.haml
@@ -48,10 +48,10 @@
%fieldset.row
.input-group
.col-xs-11.col-sm-5.project-path
- - if current_user.can_select_namespace? && !current_user.can_create_group?
- = select_tag :namespace_id, namespaces_options(params[:namespace_id] || :current_user, display_path: true), {class: 'project-path select2 js-select-namespace', tabindex: 1}
- - elsif current_user.can_create_group?
- = select_tag :namespace_id, namespaces_options(params[:namespace_id] || :current_user, [repo.owner.login]), {class: 'project-path select2 js-select-namespace', tabindex: 1}
+ - if current_user.can_select_namespace?
+ - selected = params[:namespace_id] || :current_user
+ - opts = current_user.can_create_group? ? { extra_groups: [repo.owner.login] } : { display_path: true }
+ = select_tag :namespace_id, namespaces_options(selected, opts), {class: 'project-path select2 js-select-namespace', tabindex: 1}
- else
= text_field_tag :path, current_user.namespace_path, class: "form-control", tabindex: 2, autofocus: true, disabled: true