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:
authorJose Ivan Vargas <jvargas@gitlab.com>2017-11-15 22:47:22 +0300
committerJose Ivan Vargas <jvargas@gitlab.com>2017-11-27 19:12:23 +0300
commit349e3622f92cc4c6ea51ecaac76ef7c4ea8999e3 (patch)
tree8313b2a218fae41b78ee6d64474c7345e226d48d /app/helpers/button_helper.rb
parent2e2f0675c97ba233ab089922b231a7aac97d633a (diff)
Added ssh_button helper specs and addressed ruby code observations
Diffstat (limited to 'app/helpers/button_helper.rb')
-rw-r--r--app/helpers/button_helper.rb44
1 files changed, 22 insertions, 22 deletions
diff --git a/app/helpers/button_helper.rb b/app/helpers/button_helper.rb
index 4f945b5ad9e..d06cf2de2c3 100644
--- a/app/helpers/button_helper.rb
+++ b/app/helpers/button_helper.rb
@@ -58,34 +58,34 @@ module ButtonHelper
def http_clone_button(project, append_link: true)
protocol = gitlab_config.protocol.upcase
+ dropdown_description = http_dropdown_description(protocol)
+ append_url = project.http_url_to_repo if append_link
- protocol_description =
- if current_user.try(:require_password_creation?)
- _("Set a password on your account to pull or push via %{protocol}.") % { protocol: protocol }
- else
- _("Create a personal access token on your account to pull or push via %{protocol}.") % { protocol: protocol }
- end
-
- protocol_element_output = content_tag(:strong, protocol, class: 'dropdown-menu-inner-title')
+ dropdown_item_with_description(protocol, dropdown_description, href: append_url)
+ end
- if current_user.try(:require_password_creation?) || current_user.try(:require_personal_access_token_creation_for_git_auth?)
- protocol_element_output << content_tag(:span, protocol_description, class: 'dropdown-menu-inner-content')
+ def http_dropdown_description(protocol)
+ if current_user.try(:require_password_creation_for_git?)
+ _("Set a password on your account to pull or push via %{protocol}.") % { protocol: protocol }
+ else
+ _("Create a personal access token on your account to pull or push via %{protocol}.") % { protocol: protocol }
end
-
- content_tag (append_link ? :a : :span),
- protocol_element_output,
- class: 'http-selector',
- href: (project.http_url_to_repo if append_link)
end
def ssh_clone_button(project, append_link: true)
- ssh_description = _("You won't be able to pull or push project code via SSH until you add an SSH key to your profile")
- ssh_element_output = content_tag(:strong, 'SSH', class: 'dropdown-menu-inner-title')
- ssh_element_output << content_tag(:span, ssh_description, class: 'dropdown-menu-inner-content') if current_user.try(:require_ssh_key?)
+ dropdown_description = _("You won't be able to pull or push project code via SSH until you add an SSH key to your profile") if current_user.try(:require_ssh_key?)
+ append_url = project.ssh_url_to_repo if append_link
+
+ dropdown_item_with_description('SSH', dropdown_description, href: append_url)
+ end
+
+ def dropdown_item_with_description(title, description, href: nil)
+ button_content = content_tag(:strong, title, class: 'dropdown-menu-inner-title')
+ button_content << content_tag(:span, description, class: 'dropdown-menu-inner-content') if description
- content_tag (append_link ? :a : :span),
- ssh_element_output,
- class: 'ssh-selector',
- href: (project.ssh_url_to_repo if append_link)
+ content_tag (href ? :a : :span),
+ button_content,
+ class: "#{title.downcase}-selector",
+ href: (href if href)
end
end