2015-11-23 04:52:02 +00:00
|
|
|
module ButtonHelper
|
2015-11-24 23:35:24 +00:00
|
|
|
# Output a "Copy to Clipboard" button
|
|
|
|
#
|
|
|
|
# data - Data attributes passed to `content_tag`
|
|
|
|
#
|
|
|
|
# Examples:
|
|
|
|
#
|
|
|
|
# # Define the clipboard's text
|
|
|
|
# clipboard_button(clipboard_text: "Foo")
|
|
|
|
# # => "<button class='...' data-clipboard-text='Foo'>...</button>"
|
|
|
|
#
|
|
|
|
# # Define the target element
|
|
|
|
# clipboard_button(clipboard_target: "#foo")
|
|
|
|
# # => "<button class='...' data-clipboard-target='#foo'>...</button>"
|
|
|
|
#
|
|
|
|
# See http://clipboardjs.com/#usage
|
|
|
|
def clipboard_button(data = {})
|
2015-11-23 04:53:55 +00:00
|
|
|
content_tag :button,
|
|
|
|
icon('clipboard'),
|
2015-11-24 23:35:24 +00:00
|
|
|
class: 'btn btn-xs btn-clipboard',
|
|
|
|
data: data,
|
2015-11-23 04:53:55 +00:00
|
|
|
type: :button
|
|
|
|
end
|
|
|
|
|
2015-11-23 04:52:02 +00:00
|
|
|
def http_clone_button(project)
|
|
|
|
klass = 'btn'
|
|
|
|
klass << ' active' if default_clone_protocol == 'http'
|
|
|
|
klass << ' has_tooltip' if current_user.try(:require_password?)
|
|
|
|
|
|
|
|
protocol = gitlab_config.protocol.upcase
|
|
|
|
|
|
|
|
content_tag :button, protocol,
|
|
|
|
class: klass,
|
|
|
|
data: {
|
|
|
|
clone: project.http_url_to_repo,
|
|
|
|
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'
|
|
|
|
klass << ' active' if default_clone_protocol == 'ssh'
|
|
|
|
klass << ' has_tooltip' if current_user.try(:require_ssh_key?)
|
|
|
|
|
|
|
|
content_tag :button, 'SSH',
|
|
|
|
class: klass,
|
|
|
|
data: {
|
|
|
|
clone: project.ssh_url_to_repo,
|
|
|
|
container: 'body',
|
|
|
|
html: 'true',
|
|
|
|
title: 'Add an SSH key to your profile<br>to pull or push via SSH.'
|
|
|
|
},
|
|
|
|
type: :button
|
|
|
|
end
|
|
|
|
end
|