summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-12-23 20:58:24 -0800
committerStan Hu <stanhu@gmail.com>2018-12-23 21:02:19 -0800
commit4a8b4d8a515152a2dfd1eb9d400222d5c2892fff (patch)
tree6c8a91c0142ae11e6cd8e20a73805518dbdb8e2a
parent751217987b0782115140e4c2858d91a4b596463a (diff)
downloadgitlab-ce-4a8b4d8a515152a2dfd1eb9d400222d5c2892fff.tar.gz
Fix missing Git clone button when protocol restriction setting enabled
If Git clones are restricted to either HTTP or SSH-only in the application settings, the clone button would not show. The refactoring in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22196 broke this. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/55676
-rw-r--r--app/helpers/application_settings_helper.rb12
-rw-r--r--app/views/projects/buttons/_clone.html.haml33
-rw-r--r--changelogs/unreleased/sh-fix-http-clone-panel.yml5
3 files changed, 32 insertions, 18 deletions
diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb
index 72731d969a2..5a7c005fd06 100644
--- a/app/helpers/application_settings_helper.rb
+++ b/app/helpers/application_settings_helper.rb
@@ -26,6 +26,18 @@ module ApplicationSettingsHelper
end
end
+ def all_protocols_enabled?
+ Gitlab::CurrentSettings.enabled_git_access_protocol.blank?
+ end
+
+ def ssh_enabled?
+ all_protocols_enabled? || enabled_protocol == 'ssh'
+ end
+
+ def http_enabled?
+ all_protocols_enabled? || enabled_protocol == 'http'
+ end
+
def enabled_project_button(project, protocol)
case protocol
when 'ssh'
diff --git a/app/views/projects/buttons/_clone.html.haml b/app/views/projects/buttons/_clone.html.haml
index d453a3a9dac..53d427ec40a 100644
--- a/app/views/projects/buttons/_clone.html.haml
+++ b/app/views/projects/buttons/_clone.html.haml
@@ -1,25 +1,22 @@
- project = project || @project
.git-clone-holder.js-git-clone-holder.input-group
- - if allowed_protocols_present?
- .input-group-text.clone-dropdown-btn.btn
- %span.js-clone-dropdown-label
- = enabled_project_button(project, enabled_protocol)
- - else
- %a#clone-dropdown.input-group-text.btn.btn-primary.btn-xs.clone-dropdown-btn.qa-clone-dropdown{ href: '#', data: { toggle: 'dropdown' } }
- %span.append-right-4.js-clone-dropdown-label
- = _('Clone')
- = sprite_icon("arrow-down", css_class: "icon")
+ %a#clone-dropdown.input-group-text.btn.btn-primary.btn-xs.clone-dropdown-btn.qa-clone-dropdown{ href: '#', data: { toggle: 'dropdown' } }
+ %span.append-right-4.js-clone-dropdown-label
+ = _('Clone')
+ = sprite_icon("arrow-down", css_class: "icon")
%form.p-3.dropdown-menu.dropdown-menu-right.dropdown-menu-large.dropdown-menu-selectable.clone-options-dropdown.qa-clone-options
- %li.pb-2
- %label.label-bold
- = _('Clone with SSH')
- .input-group
- = text_field_tag :ssh_project_clone, project.ssh_url_to_repo, class: "js-select-on-focus form-control qa-ssh-clone-url", readonly: true, aria: { label: 'Project clone URL' }
- .input-group-append
- = clipboard_button(target: '#ssh_project_clone', title: _("Copy URL to clipboard"), class: "input-group-text btn-default btn-clipboard")
- = render_if_exists 'projects/buttons/geo'
- %li
+ - if ssh_enabled?
+ %li.pb-2
+ %label.label-bold
+ = _('Clone with SSH')
+ .input-group
+ = text_field_tag :ssh_project_clone, project.ssh_url_to_repo, class: "js-select-on-focus form-control qa-ssh-clone-url", readonly: true, aria: { label: 'Project clone URL' }
+ .input-group-append
+ = clipboard_button(target: '#ssh_project_clone', title: _("Copy URL to clipboard"), class: "input-group-text btn-default btn-clipboard")
+ = render_if_exists 'projects/buttons/geo'
+ %li
+ - if http_enabled?
%label.label-bold
= _('Clone with %{http_label}') % { http_label: gitlab_config.protocol.upcase }
.input-group
diff --git a/changelogs/unreleased/sh-fix-http-clone-panel.yml b/changelogs/unreleased/sh-fix-http-clone-panel.yml
new file mode 100644
index 00000000000..ab220bd5076
--- /dev/null
+++ b/changelogs/unreleased/sh-fix-http-clone-panel.yml
@@ -0,0 +1,5 @@
+---
+title: Fix missing Git clone button when protocol restriction setting enabled
+merge_request: 24015
+author:
+type: fixed