Commit f715c41d authored by Robert Speicher's avatar Robert Speicher

Add frontend "keep divergent refs" option

parent 4629e944
...@@ -22,15 +22,18 @@ export default class MirrorRepos { ...@@ -22,15 +22,18 @@ export default class MirrorRepos {
} }
initMirrorPush() { initMirrorPush() {
this.$keepDivergentRefsInput = $('.js-mirror-keep-divergent-refs', this.$form);
this.$passwordGroup = $('.js-password-group', this.$container); this.$passwordGroup = $('.js-password-group', this.$container);
this.$password = $('.js-password', this.$passwordGroup); this.$password = $('.js-password', this.$passwordGroup);
this.$authMethod = $('.js-auth-method', this.$form); this.$authMethod = $('.js-auth-method', this.$form);
this.$keepDivergentRefsInput.on('change', () => this.updateKeepDivergentRefs());
this.$authMethod.on('change', () => this.togglePassword()); this.$authMethod.on('change', () => this.togglePassword());
this.$password.on('input.updateUrl', () => this.debouncedUpdateUrl()); this.$password.on('input.updateUrl', () => this.debouncedUpdateUrl());
this.initMirrorSSH(); this.initMirrorSSH();
this.updateProtectedBranches(); this.updateProtectedBranches();
this.updateKeepDivergentRefs();
} }
initMirrorSSH() { initMirrorSSH() {
...@@ -61,6 +64,16 @@ export default class MirrorRepos { ...@@ -61,6 +64,16 @@ export default class MirrorRepos {
$('.js-mirror-protected-hidden', this.$form).val(val); $('.js-mirror-protected-hidden', this.$form).val(val);
} }
updateKeepDivergentRefs() {
const field = this.$keepDivergentRefsInput.get(0);
// This field only exists after the form is switched to 'Push' mode
if (field) {
const val = field.checked ? this.$keepDivergentRefsInput.val() : '0';
$('.js-mirror-keep-divergent-refs-hidden', this.$form).val(val);
}
}
registerUpdateListeners() { registerUpdateListeners() {
this.debouncedUpdateUrl = debounce(() => this.updateUrl(), 200); this.debouncedUpdateUrl = debounce(() => this.updateUrl(), 200);
this.$urlInput.on('input', () => this.debouncedUpdateUrl()); this.$urlInput.on('input', () => this.debouncedUpdateUrl());
......
...@@ -77,6 +77,7 @@ class Projects::MirrorsController < Projects::ApplicationController ...@@ -77,6 +77,7 @@ class Projects::MirrorsController < Projects::ApplicationController
id id
enabled enabled
only_protected_branches only_protected_branches
keep_divergent_refs
auth_method auth_method
password password
ssh_known_hosts ssh_known_hosts
......
- protocols = Gitlab::UrlSanitizer::ALLOWED_SCHEMES.join('|') - protocols = Gitlab::UrlSanitizer::ALLOWED_SCHEMES.join('|')
- keep_divergent_refs = Feature.enabled?(:keep_divergent_refs, @project)
= 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}):\/\/.+"
= rm_f.hidden_field :only_protected_branches, class: 'js-mirror-protected-hidden' = rm_f.hidden_field :only_protected_branches, class: 'js-mirror-protected-hidden'
- if keep_divergent_refs
= rm_f.hidden_field :keep_divergent_refs, class: 'js-mirror-keep-divergent-refs-hidden'
= render partial: 'projects/mirrors/ssh_host_keys', locals: { f: rm_f } = render partial: 'projects/mirrors/ssh_host_keys', locals: { f: rm_f }
= render partial: 'projects/mirrors/authentication_method', locals: { f: rm_f } = render partial: 'projects/mirrors/authentication_method', locals: { f: rm_f }
- if keep_divergent_refs
.form-check.append-bottom-10
= check_box_tag :keep_divergent_refs, '1', false, class: 'js-mirror-keep-divergent-refs form-check-input'
= label_tag :keep_divergent_refs, 'Keep divergent refs', class: 'form-check-label'
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