summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArinde Eniola <eniolaarinde1@gmail.com>2016-03-31 01:49:31 +0100
committerArinde Eniola <eniolaarinde1@gmail.com>2016-04-12 12:14:38 +0100
commit236b5d00466bfe876e8fabcb44e5da491adfd21f (patch)
tree58c99030fcd6a87167a2928439786a338738c26f
parent8cb41f19891e4f39c64abd6b2a273625103c5f43 (diff)
downloadgitlab-ce-hide_help_block_when_creating_project_inside_group.tar.gz
hide help block when user is creating a new project inside a grouphide_help_block_when_creating_project_inside_group
add few fixes some changes to the code style add item to CHANGELOG on changes made
-rw-r--r--CHANGELOG1
-rw-r--r--app/assets/javascripts/behaviors/requires_input.js.coffee16
-rw-r--r--app/helpers/namespaces_helper.rb12
-rw-r--r--app/views/projects/new.html.haml2
4 files changed, 27 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index c08b148c3ac..2048a02c561 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -35,6 +35,7 @@ v 8.7.0 (unreleased)
- API: Expose user location (Robert Schilling)
- ClosingIssueExtractor regex now also works with colons. e.g. "Fixes: #1234" !3591
- Update number of Todos in the sidebar when it's marked as "Done". !3600
+ - Hide `Create a group` help block when creating a new project in a group
v 8.6.5
- Fix importing from GitHub Enterprise. !3529
diff --git a/app/assets/javascripts/behaviors/requires_input.js.coffee b/app/assets/javascripts/behaviors/requires_input.js.coffee
index 79d750d1847..0faa570ce13 100644
--- a/app/assets/javascripts/behaviors/requires_input.js.coffee
+++ b/app/assets/javascripts/behaviors/requires_input.js.coffee
@@ -35,4 +35,18 @@ $.fn.requiresInput = ->
$form.on 'change input', fieldSelector, requireInput
$ ->
- $('form.js-requires-input').requiresInput()
+ $form = $('form.js-requires-input')
+ $form.requiresInput()
+
+ # Hide or Show the help block when creating a new project
+ # based on the option selected
+ hideOrShowHelpBlock = (form) ->
+ selected = $('.js-select-namespace option:selected')
+ if selected.length and selected.data('options-parent') is 'groups'
+ return form.find('.help-block').hide()
+ else if selected.length
+ form.find('.help-block').show()
+
+ hideOrShowHelpBlock($form)
+
+ $('.select2.js-select-namespace').change -> hideOrShowHelpBlock($form)
diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb
index faba418c4db..94c6b548ecd 100644
--- a/app/helpers/namespaces_helper.rb
+++ b/app/helpers/namespaces_helper.rb
@@ -3,8 +3,16 @@ module NamespacesHelper
groups = current_user.owned_groups + current_user.masters_groups
users = [current_user.namespace]
- group_opts = ["Groups", groups.sort_by(&:human_name).map {|g| [display_path ? g.path : g.human_name, g.id]} ]
- users_opts = [ "Users", users.sort_by(&:human_name).map {|u| [display_path ? u.path : u.human_name, u.id]} ]
+ data_attr_group = { 'data-options-parent' => 'groups' }
+ data_attr_users = { 'data-options-parent' => 'users' }
+
+ group_opts = [
+ "Groups", groups.sort_by(&:human_name).map { |g| [display_path ? g.path : g.human_name, g.id, data_attr_group] }
+ ]
+
+ users_opts = [
+ "Users", users.sort_by(&:human_name).map { |u| [display_path ? u.path : u.human_name, u.id, data_attr_users] }
+ ]
options = []
options << group_opts
diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml
index 25233112132..a4c6094c69a 100644
--- a/app/views/projects/new.html.haml
+++ b/app/views/projects/new.html.haml
@@ -19,7 +19,7 @@
- if current_user.can_select_namespace?
.input-group-addon
= root_url
- = f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user, display_path: true), {}, {class: 'select2', tabindex: 1}
+ = f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user, display_path: true), {}, {class: 'select2 js-select-namespace', tabindex: 1}
.input-group-addon
\/
- else