Commit 8598c343 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch...

Merge branch '7433-mirroring-repos-direction-select-empty-and-consistency-across-offerings' into 'master'

Remove unneeded can_pull and can_push checks for ee mirror_repos_form

Closes #7433

See merge request gitlab-org/gitlab-ee!8077
parents 6e6c9199 fe7ca531
- import_data = @project.import_data || @project.build_import_data
- is_one_user_option = default_mirror_users.count == 1
- protocols = Gitlab::UrlSanitizer::ALLOWED_SCHEMES.join('|')
- can_push = can?(current_user, :admin_remote_mirror, @project)
- can_pull = can?(current_user, :admin_mirror, @project)
- options = []
- options.push([_('Push'), 'push']) if can_push
- if can_pull
- has_existing_pull_mirror = can_pull && @project.mirror
- options = [[_('Push'), 'push']]
- has_existing_pull_mirror = @project.mirror.present?
- if can?(current_user, :admin_mirror, @project)
- 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
= label_tag :mirror_direction, _('Mirror direction'), class: 'label-light'
......@@ -16,47 +13,45 @@
.js-form-insertion-point
- if can_push
%template.js-push-mirrors-form
= f.fields_for :remote_mirrors, @project.remote_mirrors.build do |rm_f|
= 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 :only_protected_branches, class: 'js-mirror-protected-hidden'
.form-group
= label_tag :auth_method, _('Authentication method'), class: 'label-bold'
= select_tag :auth_method, options_for_select([[_('None'), 'none'], [_('Password'), 'password']], 'none'), { class: "form-control js-auth-method" }
.form-group.js-password-group.collapse
= label_tag :password, _('Password'), class: 'label-bold'
= text_field_tag :password, '', type: 'password', class: 'form-control js-password'
- if can_pull
%template.js-pull-mirrors-form
= 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 :only_mirror_protected_branches, class: 'js-mirror-protected-hidden'
= f.fields_for :import_data, import_data do |import_form|
= render partial: 'projects/mirrors/pull/ssh_host_keys', locals: { f: import_form }
= render partial: 'projects/mirrors/pull/authentication_method', locals: { f: import_form }
.form-group
= f.label :mirror_user_id, _('Mirror user'), class: 'label-light'
- if is_one_user_option
= select_tag(:mirror_user_id_select, options_for_mirror_user, class: 'js-mirror-user select2 lg append-bottom-5', required: true, disabled: true)
= f.hidden_field :mirror_user_id, value: default_mirror_users.first.id if is_one_user_option
- else
= f.select(:mirror_user_id, options_for_mirror_user, {}, class: 'js-mirror-user select2 lg append-bottom-5', required: true)
.help-block
= _('This user will be the author of all events in the activity feed that are the result of an update, like new branches being created or new commits being pushed to existing branches. Upon creation or when reassigning you can only assign yourself to be the mirror user.')
.form-check.append-bottom-10
= f.check_box :mirror_overwrites_diverged_branches, class: 'form-check-input', checked: false
= f.label :mirror_overwrites_diverged_branches, _('Overwrite diverged branches'), class: 'form-check-label'
.form-text.text-muted
= _("If disabled, a diverged local branch will not be automatically updated with commits from its remote counterpart, to prevent local data loss. If the default branch (%{default_branch}) has diverged and cannot be updated, mirroring will fail. Other diverged branches are silently ignored.") % { default_branch: @project.default_branch }
- if @project.builds_enabled?
= render 'shared/mirror_trigger_builds_setting', f: f, checked: false
%template.js-push-mirrors-form
= f.fields_for :remote_mirrors, @project.remote_mirrors.build do |rm_f|
= 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 :only_protected_branches, class: 'js-mirror-protected-hidden'
.form-group
= label_tag :auth_method, _('Authentication method'), class: 'label-bold'
= select_tag :auth_method, options_for_select([[_('None'), 'none'], [_('Password'), 'password']], 'none'), { class: "form-control js-auth-method" }
.form-group.js-password-group.collapse
= label_tag :password, _('Password'), class: 'label-bold'
= text_field_tag :password, '', type: 'password', class: 'form-control js-password'
%template.js-pull-mirrors-form
= 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 :only_mirror_protected_branches, class: 'js-mirror-protected-hidden'
= f.fields_for :import_data, import_data do |import_form|
= render partial: 'projects/mirrors/pull/ssh_host_keys', locals: { f: import_form }
= render partial: 'projects/mirrors/pull/authentication_method', locals: { f: import_form }
.form-group
= f.label :mirror_user_id, _('Mirror user'), class: 'label-light'
- if is_one_user_option
= select_tag(:mirror_user_id_select, options_for_mirror_user, class: 'js-mirror-user select2 lg append-bottom-5', required: true, disabled: true)
= f.hidden_field :mirror_user_id, value: default_mirror_users.first.id if is_one_user_option
- else
= f.select(:mirror_user_id, options_for_mirror_user, {}, class: 'js-mirror-user select2 lg append-bottom-5', required: true)
.help-block
= _('This user will be the author of all events in the activity feed that are the result of an update, like new branches being created or new commits being pushed to existing branches. Upon creation or when reassigning you can only assign yourself to be the mirror user.')
.form-check.append-bottom-10
= f.check_box :mirror_overwrites_diverged_branches, class: 'form-check-input', checked: false
= f.label :mirror_overwrites_diverged_branches, _('Overwrite diverged branches'), class: 'form-check-label'
.form-text.text-muted
= _("If disabled, a diverged local branch will not be automatically updated with commits from its remote counterpart, to prevent local data loss. If the default branch (%{default_branch}) has diverged and cannot be updated, mirroring will fail. Other diverged branches are silently ignored.") % { default_branch: @project.default_branch }
- if @project.builds_enabled?
= render 'shared/mirror_trigger_builds_setting', f: f, checked: false
---
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