Commit d66182c1 authored by Luke Bennett's avatar Luke Bennett

Add push password handling for ee push pull

parent c554c302
...@@ -10,7 +10,6 @@ export default class PushPull { ...@@ -10,7 +10,6 @@ export default class PushPull {
this.$form = $('.js-mirror-form', this.$container); this.$form = $('.js-mirror-form', this.$container);
this.$urlInput = $('.js-mirror-url', this.$form); this.$urlInput = $('.js-mirror-url', this.$form);
this.$protectedBranchesInput = $('.js-mirror-protected', this.$form); this.$protectedBranchesInput = $('.js-mirror-protected', this.$form);
this.$mirrorDirectionSelect = $('.js-mirror-direction', this.$form);
this.$table = $('.js-mirrors-table-body', this.$container); this.$table = $('.js-mirrors-table-body', this.$container);
this.mirrorEndpoint = this.$form.data('projectMirrorEndpoint'); this.mirrorEndpoint = this.$form.data('projectMirrorEndpoint');
} }
......
...@@ -8,6 +8,8 @@ export default class EEPushPull extends PushPull { ...@@ -8,6 +8,8 @@ export default class EEPushPull extends PushPull {
constructor(...args) { constructor(...args) {
super(...args); super(...args);
this.$password = undefined;
this.$mirrorDirectionSelect = $('.js-mirror-direction', this.$form);
this.$insertionPoint = $('.js-form-insertion-point', this.$form); this.$insertionPoint = $('.js-form-insertion-point', this.$form);
this.$repoCount = $('.js-mirrored-repo-count', this.$container); this.$repoCount = $('.js-mirrored-repo-count', this.$container);
this.directionFormMap = { this.directionFormMap = {
...@@ -24,6 +26,17 @@ export default class EEPushPull extends PushPull { ...@@ -24,6 +26,17 @@ export default class EEPushPull extends PushPull {
super.init(); super.init();
} }
updateUrl() {
let val = this.$urlInput.val();
if (this.$password) {
const password = this.$password.val();
if (password) val = val.replace('@', `:${password}@`);
}
$('.js-mirror-url-hidden', this.$form).val(val);
}
handleUpdate() { handleUpdate() {
return this.hideForm() return this.hideForm()
.then(() => { .then(() => {
...@@ -63,10 +76,14 @@ export default class EEPushPull extends PushPull { ...@@ -63,10 +76,14 @@ export default class EEPushPull extends PushPull {
this.updateUrl(); this.updateUrl();
this.updateProtectedBranches(); this.updateProtectedBranches();
if (direction === 'pull') this.initMirrorPull(); if (direction === 'pull') return this.initMirrorPull();
return this.initMirrorPush();
} }
initMirrorPull() { initMirrorPull() {
this.$password.off('input.updateUrl');
this.$password = undefined;
const mirrorPull = new MirrorPull('.js-mirror-form'); const mirrorPull = new MirrorPull('.js-mirror-form');
if (this.$urlInput.val() !== '') mirrorPull.handleRepositoryUrlInput(); if (this.$urlInput.val() !== '') mirrorPull.handleRepositoryUrlInput();
...@@ -75,6 +92,11 @@ export default class EEPushPull extends PushPull { ...@@ -75,6 +92,11 @@ export default class EEPushPull extends PushPull {
this.initSelect2(); this.initSelect2();
} }
initMirrorPush() {
this.$password = $('.js-password', this.$form);
this.$password.on('input.updateUrl', () => this.debouncedUpdateUrl());
}
initSelect2() { initSelect2() {
$('.js-mirror-user', this.$form).select2({ $('.js-mirror-user', this.$form).select2({
width: 'resolve', width: 'resolve',
......
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