Skip to content
Snippets Groups Projects

Resolve "Customize branch name when using create branch in an issue"

Compare and Show latest version
2 files
+ 15
11
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -122,7 +122,7 @@ export default class CreateMergeRequestDropdown {
checkBranchExists() {
if (this.newBranchNameInput.value) {
this.checkBranchExistencePath = this.checkBranchExistencePath.replace(/(\/branches\/)(.*?)$/, "$1" + this.newBranchNameInput.value);
this.checkBranchExistencePath = this.checkBranchExistencePath.replace(/(\/branches\/)(.*?)$/, `$1${this.newBranchNameInput.value}`);
} else {
this.checkBranchExistencePath = this.wrapperEl.dataset.checkBranchExistencePath;
}
@@ -137,14 +137,16 @@ export default class CreateMergeRequestDropdown {
this.isCheckingBranchExistence = true;
},
})
.always(() => this.isCheckingBranchExistence = false)
.always(() => {
this.isCheckingBranchExistence = false;
})
.success((jqXHR, textStatus, xhr) => {
if (xhr.status == 200 || xhr.status == 204) {
if (xhr.status === 200 || xhr.status === 204) {
this.branchTaken = true;
}
})
.fail((xhr) => {
if (xhr.status == 404) {
if (xhr.status === 404) {
this.branchTaken = false;
}
});
@@ -230,12 +232,14 @@ export default class CreateMergeRequestDropdown {
// `ENTER` key submits the data.
if (e.keyCode === 13 && this.inputsAreValid) {
return this.createMergeRequestButton.click();
this.createMergeRequestButton.click();
return;
}
// `ESC` key closes the dropdown.
if (e.keyCode === 27) {
return this.dropdownToggle.click();
this.dropdownToggle.click();
return;
}
// If the input is empty, use the original branch name generated by the backend.
@@ -252,8 +256,8 @@ export default class CreateMergeRequestDropdown {
this.inputsAreValid = false;
this.disableCreateAction();
this.showNewBranchTakenMessage();
this.createBranchPath = this.createBranchPath.replace(/(branch_name=)(.+?)(?=&issue)/, "$1" + this.newBranchNameInput.value);
this.createMrPath = this.createMrPath.replace(/(branch_name=)(.+?)(?=&ref)/, "$1" + this.newBranchNameInput.value);
this.createBranchPath = this.createBranchPath.replace(/(branch_name=)(.+?)(?=&issue)/, `$1${this.newBranchNameInput.value}`);
this.createMrPath = this.createMrPath.replace(/(branch_name=)(.+?)(?=&ref)/, `$1${this.newBranchNameInput.value}`);
} else {
this.inputsAreValid = true;
this.enable();
@@ -270,8 +274,8 @@ export default class CreateMergeRequestDropdown {
return;
}
this.createBranchPath = this.createBranchPath.replace(/(ref=)(.+?)$/, "$1" + this.refInput.value);
this.createMrPath = this.createMrPath.replace(/(ref=)(.+?)$/, "$1" + this.refInput.value);
this.createBranchPath = this.createBranchPath.replace(/(ref=)(.+?)$/, `$1${this.refInput.value}`);
this.createMrPath = this.createMrPath.replace(/(ref=)(.+?)$/, `$1${this.refInput.value}`);
}
onClickCreateMergeRequestButton(e) {
Loading