Newer
Older
# 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: "div#foo")
# # => "<button class='...' data-clipboard-target='div#foo'>...</button>"
#
# See http://clipboardjs.com/#usage
css_class = data[:class] || 'btn-clipboard btn-transparent'
title = data[:title] || 'Copy to clipboard'
data = { toggle: 'tooltip', placement: 'bottom', container: 'body' }.merge(data)
content_tag :button,
icon('clipboard'),
Patricio Cano
committed
def http_clone_button(project, placement = 'right', append_link: true)
Stan Hu
committed
klass = 'http-selector'
klass << ' has-tooltip' if current_user.try(:require_password?)
protocol = gitlab_config.protocol.upcase
Patricio Cano
committed
content_tag (append_link ? :a : :span), protocol,
href: (project.http_url_to_repo if append_link),
Stan Hu
committed
html: true,
title: "Set a password on your account<br>to pull or push via #{protocol}"
Stan Hu
committed
}
Patricio Cano
committed
def ssh_clone_button(project, placement = 'right', append_link: true)
Stan Hu
committed
klass = 'ssh-selector'
klass << ' has-tooltip' if current_user.try(:require_ssh_key?)
Patricio Cano
committed
content_tag (append_link ? :a : :span), 'SSH',
href: (project.ssh_url_to_repo if append_link),
Stan Hu
committed
html: true,
title: 'Add an SSH key to your profile<br>to pull or push via SSH.'
Stan Hu
committed
}