Commit 4efaef25 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '6165-migrate-ee-specific-code-ee' into 'master'

Migrate EE specific code in `app/views/layouts/nav/sidebar/_project.html.haml`

See merge request gitlab-org/gitlab-ee!6182
parents 1f1bcbb0 dab6894c
...@@ -323,16 +323,6 @@ module ProjectsHelper ...@@ -323,16 +323,6 @@ module ProjectsHelper
end end
end end
def size_limit_message(project)
show_lfs = project.lfs_enabled? ? 'including files in LFS' : ''
"The total size of this project's repository #{show_lfs} will be limited to this size. 0 for unlimited. Leave empty to inherit the group/global value."
end
def project_above_size_limit_message
Gitlab::RepositorySizeError.new(@project).above_size_limit_message
end
def git_user_name def git_user_name
if current_user if current_user
current_user.name.gsub('"', '\"') current_user.name.gsub('"', '\"')
...@@ -351,8 +341,6 @@ module ProjectsHelper ...@@ -351,8 +341,6 @@ module ProjectsHelper
def default_url_to_repo(project = @project) def default_url_to_repo(project = @project)
case default_clone_protocol case default_clone_protocol
when 'krb5'
project.kerberos_url_to_repo
when 'ssh' when 'ssh'
project.ssh_url_to_repo project.ssh_url_to_repo
else else
...@@ -363,20 +351,17 @@ module ProjectsHelper ...@@ -363,20 +351,17 @@ module ProjectsHelper
def default_clone_protocol def default_clone_protocol
if allowed_protocols_present? if allowed_protocols_present?
enabled_protocol enabled_protocol
elsif alternative_kerberos_url? && current_user
"krb5"
else else
if !current_user || current_user.require_ssh_key? extra_default_clone_protocol
gitlab_config.protocol
else
'ssh'
end
end end
end end
# Given the current GitLab configuration, check whether the GitLab URL for Kerberos is going to be different than the HTTP URL def extra_default_clone_protocol
def alternative_kerberos_url? if !current_user || current_user.require_ssh_key?
Gitlab.config.alternative_gitlab_kerberos_url? gitlab_config.protocol
else
'ssh'
end
end end
def project_last_activity(project) def project_last_activity(project)
...@@ -419,36 +404,6 @@ module ProjectsHelper ...@@ -419,36 +404,6 @@ module ProjectsHelper
end end
end end
def project_can_be_shared?
!membership_locked? || @project.allowed_to_share_with_group?
end
def membership_locked?
if @project.group && @project.group.membership_lock
true
else
false
end
end
def share_project_description
share_with_group = @project.allowed_to_share_with_group?
share_with_members = !membership_locked?
project_name = content_tag(:strong, @project.name)
member_message = "You can add a new member to #{project_name}"
description =
if share_with_group && share_with_members
"#{member_message} or share it with another group."
elsif share_with_group
"You can share #{project_name} with another group."
elsif share_with_members
"#{member_message}."
end
description.to_s.html_safe
end
def readme_cache_key def readme_cache_key
sha = @project.commit.try(:sha) || 'nil' sha = @project.commit.try(:sha) || 'nil'
[@project.full_path, sha, "readme"].join('-') [@project.full_path, sha, "readme"].join('-')
...@@ -552,4 +507,37 @@ module ProjectsHelper ...@@ -552,4 +507,37 @@ module ProjectsHelper
"list-label" "list-label"
end end
end end
def sidebar_settings_paths
%w[
projects#edit
project_members#index
integrations#show
services#edit
repository#show
ci_cd#show
badges#index
pages#show
]
end
def sidebar_repository_paths
%w[
tree
blob
blame
edit_tree
new_tree
find_file
commit
commits
compare
projects/repositories
tags
branches
releases
graphs
network
]
end
end end
...@@ -34,8 +34,10 @@ ...@@ -34,8 +34,10 @@
= link_to project_cycle_analytics_path(@project), title: _('Cycle Analytics'), class: 'shortcuts-project-cycle-analytics' do = link_to project_cycle_analytics_path(@project), title: _('Cycle Analytics'), class: 'shortcuts-project-cycle-analytics' do
%span= _('Cycle Analytics') %span= _('Cycle Analytics')
= render_if_exists 'projects/sidebar/security_dashboard'
- if project_nav_tab? :files - if project_nav_tab? :files
= nav_link(controller: %w(tree blob blame edit_tree new_tree find_file commit commits compare projects/repositories tags branches releases graphs network path_locks)) do = nav_link(controller: sidebar_repository_paths) do
= link_to project_tree_path(@project), class: 'shortcuts-tree' do = link_to project_tree_path(@project), class: 'shortcuts-tree' do
.nav-icon-container .nav-icon-container
= sprite_icon('doc_text') = sprite_icon('doc_text')
...@@ -43,7 +45,7 @@ ...@@ -43,7 +45,7 @@
= _('Repository') = _('Repository')
%ul.sidebar-sub-level-items %ul.sidebar-sub-level-items
= nav_link(controller: %w(tree blob blame edit_tree new_tree find_file commit commits compare projects/repositories tags branches releases graphs network path_locks), html_options: { class: "fly-out-top-item" } ) do = nav_link(controller: sidebar_repository_paths, html_options: { class: "fly-out-top-item" } ) do
= link_to project_tree_path(@project) do = link_to project_tree_path(@project) do
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
= _('Repository') = _('Repository')
...@@ -80,10 +82,7 @@ ...@@ -80,10 +82,7 @@
= link_to charts_project_graph_path(@project, current_ref) do = link_to charts_project_graph_path(@project, current_ref) do
= _('Charts') = _('Charts')
- if @project.feature_available?(:file_locks) = render_if_exists 'projects/sidebar/repository_locked_files'
= nav_link(controller: [:path_locks]) do
= link_to project_path_locks_path(@project) do
= _('Locked Files')
- if project_nav_tab? :issues - if project_nav_tab? :issues
= nav_link(controller: @project.issues_enabled? ? [:issues, :labels, :milestones, :boards] : :issues) do = nav_link(controller: @project.issues_enabled? ? [:issues, :labels, :milestones, :boards] : :issues) do
...@@ -114,15 +113,13 @@ ...@@ -114,15 +113,13 @@
= link_to project_boards_path(@project), title: boards_link_text do = link_to project_boards_path(@project), title: boards_link_text do
%span %span
= boards_link_text = boards_link_text
= nav_link(controller: :labels) do = nav_link(controller: :labels) do
= link_to project_labels_path(@project), title: 'Labels' do = link_to project_labels_path(@project), title: 'Labels' do
%span %span
= _('Labels') = _('Labels')
- if EE::Gitlab::ServiceDesk.enabled?(project: @project) = render_if_exists 'projects/sidebar/issues_service_desk'
= nav_link(controller: :issues, action: :service_desk ) do
= link_to service_desk_project_issues_path(@project), title: 'Service Desk' do
%span Service Desk
= nav_link(controller: :milestones) do = nav_link(controller: :milestones) do
= link_to project_milestones_path(@project), title: 'Milestones' do = link_to project_milestones_path(@project), title: 'Milestones' do
...@@ -287,7 +284,7 @@ ...@@ -287,7 +284,7 @@
= _('Snippets') = _('Snippets')
- if project_nav_tab? :settings - if project_nav_tab? :settings
= nav_link(path: %w[projects#edit project_members#index integrations#show services#edit repository#show ci_cd#show badges#index pages#show audit_events#index]) do = nav_link(path: sidebar_settings_paths) do
= link_to edit_project_path(@project), class: 'shortcuts-tree' do = link_to edit_project_path(@project), class: 'shortcuts-tree' do
.nav-icon-container .nav-icon-container
= sprite_icon('settings') = sprite_icon('settings')
...@@ -297,7 +294,7 @@ ...@@ -297,7 +294,7 @@
%ul.sidebar-sub-level-items %ul.sidebar-sub-level-items
- can_edit = can?(current_user, :admin_project, @project) - can_edit = can?(current_user, :admin_project, @project)
- if can_edit - if can_edit
= nav_link(path: %w[projects#edit project_members#index integrations#show services#edit repository#show ci_cd#show badges#index pages#show audit_events#index], html_options: { class: "fly-out-top-item" } ) do = nav_link(path: sidebar_settings_paths, html_options: { class: "fly-out-top-item" } ) do
= link_to edit_project_path(@project) do = link_to edit_project_path(@project) do
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
= _('Settings') = _('Settings')
...@@ -335,7 +332,7 @@ ...@@ -335,7 +332,7 @@
%span %span
= _('Pages') = _('Pages')
= render 'projects/settings/ee/nav' = render_if_exists 'projects/sidebar/settings_audit_events'
- else - else
= nav_link(controller: :project_members) do = nav_link(controller: :project_members) do
......
module EE module EE
module ProjectsHelper module ProjectsHelper
extend ::Gitlab::Utils::Override
override :sidebar_settings_paths
def sidebar_settings_paths
super + %w(audit_events#index)
end
override :sidebar_repository_paths
def sidebar_repository_paths
super + %w(path_locks)
end
override :default_url_to_repo
def default_url_to_repo(project = @project)
case default_clone_protocol
when 'krb5'
project.kerberos_url_to_repo
else
super
end
end
override :extra_default_clone_protocol
def extra_default_clone_protocol
if alternative_kerberos_url? && current_user
"krb5"
else
super
end
end
# Given the current GitLab configuration, check whether the GitLab URL for Kerberos is going to be different than the HTTP URL
def alternative_kerberos_url?
::Gitlab.config.alternative_gitlab_kerberos_url?
end
def can_change_push_rule?(push_rule, rule) def can_change_push_rule?(push_rule, rule)
return true if push_rule.global? return true if push_rule.global?
...@@ -19,5 +55,45 @@ module EE ...@@ -19,5 +55,45 @@ module EE
def ci_cd_projects_available? def ci_cd_projects_available?
::License.feature_available?(:ci_cd_projects) && import_sources_enabled? ::License.feature_available?(:ci_cd_projects) && import_sources_enabled?
end end
def size_limit_message(project)
show_lfs = project.lfs_enabled? ? 'including files in LFS' : ''
"The total size of this project's repository #{show_lfs} will be limited to this size. 0 for unlimited. Leave empty to inherit the group/global value."
end
def project_above_size_limit_message
::Gitlab::RepositorySizeError.new(@project).above_size_limit_message
end
def project_can_be_shared?
!membership_locked? || @project.allowed_to_share_with_group?
end
def membership_locked?
if @project.group && @project.group.membership_lock
true
else
false
end
end
def share_project_description
share_with_group = @project.allowed_to_share_with_group?
share_with_members = !membership_locked?
project_name = content_tag(:strong, @project.name)
member_message = "You can add a new member to #{project_name}"
description =
if share_with_group && share_with_members
"#{member_message} or share it with another group."
elsif share_with_group
"You can share #{project_name} with another group."
elsif share_with_members
"#{member_message}."
end
description.to_s.html_safe
end
end end
end end
- if @project.feature_available?(:audit_events) || show_promotions?
= nav_link(controller: :audit_events) do
= link_to project_audit_events_path(@project), title: "Audit Events" do
%span
Audit Events
- return unless EE::Gitlab::ServiceDesk.enabled?(project: @project)
= nav_link(controller: :issues, action: :service_desk ) do
= link_to service_desk_project_issues_path(@project), title: 'Service Desk' do
%span _('Service Desk')
- return unless @project.feature_available?(:file_locks)
= nav_link(controller: [:path_locks]) do
= link_to project_path_locks_path(@project) do
= _('Locked Files')
- return unless @project.feature_available?(:audit_events) || show_promotions?
= nav_link(controller: :audit_events) do
= link_to project_audit_events_path(@project), title: "Audit Events" do
%span _('Audit Events')
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