Commit fe7ca531 authored by Luke Bennett's avatar Luke Bennett

Remove unneeded push permission check from the mirror repositories partial.

The EE mirror repositories partial (mirror_repos_form) has unneeded checked for :admin_remote_mirror.
All users viewing this partial should already have this permission.
parent f983def9
- import_data = @project.import_data || @project.build_import_data - import_data = @project.import_data || @project.build_import_data
- is_one_user_option = default_mirror_users.count == 1 - is_one_user_option = default_mirror_users.count == 1
- protocols = Gitlab::UrlSanitizer::ALLOWED_SCHEMES.join('|') - protocols = Gitlab::UrlSanitizer::ALLOWED_SCHEMES.join('|')
- can_push = can?(current_user, :admin_remote_mirror, @project) - options = [[_('Push'), 'push']]
- can_pull = can?(current_user, :admin_mirror, @project) - has_existing_pull_mirror = @project.mirror.present?
- options = [] - if can?(current_user, :admin_mirror, @project)
- options.push([_('Push'), 'push']) if can_push
- if can_pull
- has_existing_pull_mirror = can_pull && @project.mirror
- pull_addition_method = has_existing_pull_mirror ? options.method(:push) : options.method(:unshift) - pull_addition_method = has_existing_pull_mirror ? options.method(:push) : options.method(:unshift)
- pull_addition_method.call([_('Pull'), 'pull']) if can_pull - pull_addition_method.call([_('Pull'), 'pull'])
.form-group .form-group
= label_tag :mirror_direction, _('Mirror direction'), class: 'label-light' = label_tag :mirror_direction, _('Mirror direction'), class: 'label-light'
...@@ -16,8 +13,7 @@ ...@@ -16,8 +13,7 @@
.js-form-insertion-point .js-form-insertion-point
- if can_push %template.js-push-mirrors-form
%template.js-push-mirrors-form
= f.fields_for :remote_mirrors, @project.remote_mirrors.build do |rm_f| = f.fields_for :remote_mirrors, @project.remote_mirrors.build do |rm_f|
= rm_f.hidden_field :enabled, value: '1' = rm_f.hidden_field :enabled, value: '1'
= rm_f.hidden_field :url, class: 'js-mirror-url-hidden', required: true, pattern: "(#{protocols}):\/\/.+" = rm_f.hidden_field :url, class: 'js-mirror-url-hidden', required: true, pattern: "(#{protocols}):\/\/.+"
...@@ -31,8 +27,7 @@ ...@@ -31,8 +27,7 @@
= label_tag :password, _('Password'), class: 'label-bold' = label_tag :password, _('Password'), class: 'label-bold'
= text_field_tag :password, '', type: 'password', class: 'form-control js-password' = text_field_tag :password, '', type: 'password', class: 'form-control js-password'
- if can_pull %template.js-pull-mirrors-form
%template.js-pull-mirrors-form
= f.hidden_field :mirror, value: '1' = f.hidden_field :mirror, value: '1'
= f.hidden_field :username_only_import_url, class: 'js-mirror-url-hidden', required: true, pattern: "(#{protocols}):\/\/.+" = f.hidden_field :username_only_import_url, class: 'js-mirror-url-hidden', required: true, pattern: "(#{protocols}):\/\/.+"
= f.hidden_field :only_mirror_protected_branches, class: 'js-mirror-protected-hidden' = f.hidden_field :only_mirror_protected_branches, class: 'js-mirror-protected-hidden'
......
---
title: Remove unneeded permission checks from the mirror repositories partial.
merge_request: 8077
author:
type: other
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