Add clipboard button to project clone panel

Closes #3585
This commit is contained in:
Robert Speicher 2015-11-24 19:32:06 -05:00
parent 7dab8ed739
commit 1d80cd315e
5 changed files with 15 additions and 11 deletions

View file

@ -3,11 +3,9 @@ class @Project
# Git clone panel switcher
cloneHolder = $('.git-clone-holder')
if cloneHolder.length
$('a, button', cloneHolder).click ->
$('a, button', cloneHolder).removeClass 'active'
$(@).addClass 'active'
$('#project_clone', cloneHolder).val $(@).data 'clone'
$(".clone").text("").append $(@).data 'clone'
$('.js-protocol-switch', cloneHolder).click ->
$('.js-protocol-switch', cloneHolder).toggleClass('active')
$('#project_clone').val($(@).data('clone'))
# Ref switcher
$('.project-refs-select').on 'change', ->
@ -39,4 +37,4 @@ class @Project
when 4 then label = ' On Mention '
$('#notifications-button').empty().append("<i class='fa fa-bell'></i>" + label + "<i class='fa fa-angle-down'></i>")
$(@).parents('ul').find('li.active').removeClass 'active'
$(@).parent().addClass 'active'
$(@).parent().addClass 'active'

View file

@ -178,6 +178,11 @@
&:active {
outline: none;
}
&.btn-clipboard {
padding-left: 15px;
padding-right: 15px;
}
}
.active {
@ -552,4 +557,4 @@ pre.light-well {
z-index: 100;
position: relative;
}
}
}

View file

@ -23,7 +23,7 @@ module ButtonHelper
end
def http_clone_button(project)
klass = 'btn'
klass = 'btn js-protocol-switch'
klass << ' active' if default_clone_protocol == 'http'
klass << ' has_tooltip' if current_user.try(:require_password?)
@ -41,7 +41,7 @@ module ButtonHelper
end
def ssh_clone_button(project)
klass = 'btn'
klass = 'btn js-protocol-switch'
klass << ' active' if default_clone_protocol == 'ssh'
klass << ' has_tooltip' if current_user.try(:require_ssh_key?)

View file

@ -173,8 +173,7 @@ module ProjectsHelper
'unknown'
end
def default_url_to_repo(project = nil)
project = project || @project
def default_url_to_repo(project = @project)
current_user ? project.url_to_repo : project.http_url_to_repo
end

View file

@ -6,6 +6,8 @@
.input-group-btn
= http_clone_button(project)
= text_field_tag :project_clone, default_url_to_repo(project), class: "js-select-on-focus form-control", readonly: true
.input-group-btn
= clipboard_button(clipboard_target: '#project_clone')
- if project.kind_of?(Project)
.input-group-addon.has_tooltip{title: "#{visibility_level_label(project.visibility_level)} project", data: { container: "body" } }
.visibility-level-label