Commit 4a8b4d8a authored by Stan Hu's avatar Stan Hu

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
parent 75121798
...@@ -26,6 +26,18 @@ module ApplicationSettingsHelper ...@@ -26,6 +26,18 @@ module ApplicationSettingsHelper
end end
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) def enabled_project_button(project, protocol)
case protocol case protocol
when 'ssh' when 'ssh'
......
- project = project || @project - project = project || @project
.git-clone-holder.js-git-clone-holder.input-group .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' } } %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 %span.append-right-4.js-clone-dropdown-label
= _('Clone') = _('Clone')
= sprite_icon("arrow-down", css_class: "icon") = 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 %form.p-3.dropdown-menu.dropdown-menu-right.dropdown-menu-large.dropdown-menu-selectable.clone-options-dropdown.qa-clone-options
- if ssh_enabled?
%li.pb-2 %li.pb-2
%label.label-bold %label.label-bold
= _('Clone with SSH') = _('Clone with SSH')
...@@ -20,6 +16,7 @@ ...@@ -20,6 +16,7 @@
= clipboard_button(target: '#ssh_project_clone', title: _("Copy URL to clipboard"), class: "input-group-text btn-default btn-clipboard") = 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' = render_if_exists 'projects/buttons/geo'
%li %li
- if http_enabled?
%label.label-bold %label.label-bold
= _('Clone with %{http_label}') % { http_label: gitlab_config.protocol.upcase } = _('Clone with %{http_label}') % { http_label: gitlab_config.protocol.upcase }
.input-group .input-group
......
---
title: Fix missing Git clone button when protocol restriction setting enabled
merge_request: 24015
author:
type: fixed
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