Commit 42fc4233 authored by Jacob Schatz's avatar Jacob Schatz

Merge branch 'fix-default-http-clone' into 'master'

Make HTTP(s) label consistent on clone bar

Sites that use http:// for the external_url should always display HTTP on
the clone bar. Similarly, sites that use https:// should show HTTPS.

Currently, the inconsistency looks like:

![http-magic](/uploads/945fda580f7ba5aee36cc572b49baf2b/http-magic.gif)

Also restores the tooltips that vanished in 7ba4482f:

![image](/uploads/b5a7b3e68b4992a447fcaa51915e866c/image.png)


See merge request !3319
parents a4422a3a 7418429d
......@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.6.0 (unreleased)
- Fix bug where wrong commit ID was being used in a merge request diff to show old image (Stan Hu)
- Make HTTP(s) label consistent on clone bar (Stan Hu)
- Add confidential issues
- Bump gitlab_git to 9.0.3 (Stan Hu)
- Support Golang subpackage fetching (Stan Hu)
......
......@@ -11,7 +11,6 @@ class @Project
$(@).toggleClass('active')
url = $("#project_clone").val()
console.log("url",url)
# Update the input field
$('#project_clone').val(url)
......
......@@ -23,36 +23,34 @@ module ButtonHelper
end
def http_clone_button(project)
klass = 'btn js-protocol-switch'
klass << ' active' if default_clone_protocol == 'http'
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 = '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
......@@ -209,7 +209,7 @@ module ProjectsHelper
def default_clone_protocol
if !current_user || current_user.require_ssh_key?
"http"
gitlab_config.protocol
else
"ssh"
end
......
......@@ -8,11 +8,9 @@
= icon('angle-down')
%ul.dropdown-menu.dropdown-menu-right.clone-options-dropdown
%li
%a#ssh-selector{href: @project.ssh_url_to_repo}
SSH
= ssh_clone_button(project)
%li
%a#http-selector{href: @project.http_url_to_repo}
HTTPS
= 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
......
......@@ -27,7 +27,7 @@ class Spinach::Features::ProjectCreate < Spinach::FeatureSteps
step 'I click on HTTP' do
find('#clone-dropdown').click
find('#http-selector').click
find('.http-selector').click
end
step 'Remote url should update to http link' do
......@@ -36,7 +36,7 @@ class Spinach::Features::ProjectCreate < Spinach::FeatureSteps
step 'If I click on SSH' do
find('#clone-dropdown').click
find('#ssh-selector').click
find('.ssh-selector').click
end
step 'Remote url should update to ssh link' do
......
......@@ -94,4 +94,23 @@ describe ProjectsHelper do
end
end
end
describe 'default_clone_protocol' do
describe 'using HTTP' do
it 'returns HTTP' do
expect(helper).to receive(:current_user).and_return(nil)
expect(helper.send(:default_clone_protocol)).to eq('http')
end
end
describe 'using HTTPS' do
it 'returns HTTPS' do
allow(Gitlab.config.gitlab).to receive(:protocol).and_return('https')
expect(helper).to receive(:current_user).and_return(nil)
expect(helper.send(:default_clone_protocol)).to eq('https')
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment