2015-11-22 23:52:02 -05:00
|
|
|
module ButtonHelper
|
2015-11-24 18:35:24 -05: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
|
2015-12-15 16:11:01 -05:00
|
|
|
# clipboard_button(clipboard_target: "div#foo")
|
|
|
|
# # => "<button class='...' data-clipboard-target='div#foo'>...</button>"
|
2015-11-24 18:35:24 -05:00
|
|
|
#
|
|
|
|
# See http://clipboardjs.com/#usage
|
|
|
|
def clipboard_button(data = {})
|
2015-11-22 23:53:55 -05:00
|
|
|
content_tag :button,
|
|
|
|
icon('clipboard'),
|
2016-01-14 07:59:28 -05:00
|
|
|
class: 'btn btn-clipboard',
|
2015-11-24 18:35:24 -05:00
|
|
|
data: data,
|
2015-11-22 23:53:55 -05:00
|
|
|
type: :button
|
|
|
|
end
|
|
|
|
|
2015-11-22 23:52:02 -05:00
|
|
|
def http_clone_button(project)
|
2016-03-20 01:46:56 -04:00
|
|
|
klass = 'http-selector'
|
2016-03-20 15:01:46 -04:00
|
|
|
klass << ' has-tooltip' if current_user.try(:require_password?)
|
2015-11-22 23:52:02 -05:00
|
|
|
|
|
|
|
protocol = gitlab_config.protocol.upcase
|
|
|
|
|
2016-03-20 01:46:56 -04:00
|
|
|
content_tag :a, protocol,
|
2015-11-22 23:52:02 -05:00
|
|
|
class: klass,
|
2016-03-20 01:46:56 -04:00
|
|
|
href: @project.http_url_to_repo,
|
2015-11-22 23:52:02 -05:00
|
|
|
data: {
|
2016-03-20 01:46:56 -04:00
|
|
|
html: true,
|
2016-03-20 10:52:06 -04:00
|
|
|
placement: 'right',
|
|
|
|
container: 'body',
|
2015-11-22 23:52:02 -05:00
|
|
|
title: "Set a password on your account<br>to pull or push via #{protocol}"
|
2016-03-20 01:46:56 -04:00
|
|
|
}
|
2015-11-22 23:52:02 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def ssh_clone_button(project)
|
2016-03-20 01:46:56 -04:00
|
|
|
klass = 'ssh-selector'
|
2016-03-20 15:01:46 -04:00
|
|
|
klass << ' has-tooltip' if current_user.try(:require_ssh_key?)
|
2015-11-22 23:52:02 -05:00
|
|
|
|
2016-03-20 01:46:56 -04:00
|
|
|
content_tag :a, 'SSH',
|
2015-11-22 23:52:02 -05:00
|
|
|
class: klass,
|
2016-03-20 01:46:56 -04:00
|
|
|
href: project.ssh_url_to_repo,
|
2015-11-22 23:52:02 -05:00
|
|
|
data: {
|
2016-03-20 01:46:56 -04:00
|
|
|
html: true,
|
2016-03-20 10:52:06 -04:00
|
|
|
placement: 'right',
|
|
|
|
container: 'body',
|
2015-11-22 23:52:02 -05:00
|
|
|
title: 'Add an SSH key to your profile<br>to pull or push via SSH.'
|
2016-03-20 01:46:56 -04:00
|
|
|
}
|
2015-11-22 23:52:02 -05:00
|
|
|
end
|
|
|
|
end
|