summaryrefslogtreecommitdiff
path: root/app/helpers/button_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/button_helper.rb')
-rw-r--r--app/helpers/button_helper.rb50
1 files changed, 33 insertions, 17 deletions
diff --git a/app/helpers/button_helper.rb b/app/helpers/button_helper.rb
index d6c05843743..9051a493b9b 100644
--- a/app/helpers/button_helper.rb
+++ b/app/helpers/button_helper.rb
@@ -17,42 +17,58 @@ module ButtonHelper
def clipboard_button(data = {})
content_tag :button,
icon('clipboard'),
- class: 'btn btn-clipboard',
+ class: "btn btn-clipboard",
+ data: data,
+ type: :button
+ end
+
+ # Output a "Copy to Clipboard" button with a custom CSS class
+ #
+ # data - Data attributes passed to `content_tag`
+ # css_class - Class passed to the `content_tag`
+ #
+ # Examples:
+ #
+ # # Define the target element
+ # clipboard_button_with_class({clipboard_target: "div#foo"}, css_class: "btn-clipboard")
+ # # => "<button class='btn btn-clipboard' data-clipboard-target='div#foo'>...</button>"
+ def clipboard_button_with_class(data = {}, css_class: 'btn-clipboard')
+ content_tag :button,
+ icon('clipboard'),
+ class: "btn #{css_class}",
data: data,
type: :button
end
def http_clone_button(project)
- klass = 'btn js-protocol-switch'
- klass << ' active' if default_clone_protocol == 'http'
- klass << ' has_tooltip' if current_user.try(:require_password?)
+ klass = 'http-selector'
+ klass << ' has-tooltip' if current_user.try(:require_password?)
protocol = gitlab_config.protocol.upcase
- content_tag :button, protocol,
+ content_tag :a, protocol,
class: klass,
+ href: project.http_url_to_repo,
data: {
- clone: project.http_url_to_repo,
+ html: true,
+ placement: 'right',
container: 'body',
- html: 'true',
title: "Set a password on your account<br>to pull or push via #{protocol}"
- },
- type: :button
+ }
end
def ssh_clone_button(project)
- klass = 'btn js-protocol-switch'
- klass << ' active' if default_clone_protocol == 'ssh'
- klass << ' has_tooltip' if current_user.try(:require_ssh_key?)
+ klass = 'ssh-selector'
+ klass << ' has-tooltip' if current_user.try(:require_ssh_key?)
- content_tag :button, 'SSH',
+ content_tag :a, 'SSH',
class: klass,
+ href: project.ssh_url_to_repo,
data: {
- clone: project.ssh_url_to_repo,
+ html: true,
+ placement: 'right',
container: 'body',
- html: 'true',
title: 'Add an SSH key to your profile<br>to pull or push via SSH.'
- },
- type: :button
+ }
end
end