Skip to content
Snippets Groups Projects

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

Compare and Show latest version
3 files
+ 18
16
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -13,10 +13,11 @@ export default class CreateMergeRequestDropdown {
@@ -13,10 +13,11 @@ export default class CreateMergeRequestDropdown {
constructor(wrapperEl) {
constructor(wrapperEl) {
this.wrapperEl = wrapperEl;
this.wrapperEl = wrapperEl;
this.availableButton = this.wrapperEl.querySelector('.available');
this.availableButton = this.wrapperEl.querySelector('.available');
this.branchNameInput = this.wrapperEl.querySelector('#branch-name');
this.createMergeRequestButton = this.wrapperEl.querySelector('.js-create-merge-request');
this.createMergeRequestButton = this.wrapperEl.querySelector('.js-create-merge-request');
this.dropdownList = this.wrapperEl.querySelector('.dropdown-menu');
this.dropdownList = this.wrapperEl.querySelector('.dropdown-menu');
this.dropdownToggle = this.wrapperEl.querySelector('.js-dropdown-toggle');
this.dropdownToggle = this.wrapperEl.querySelector('.js-dropdown-toggle');
 
this.newBranchNameInput = this.wrapperEl.querySelector('#new-branch-name');
 
this.refInput = this.wrapperEl.querySelector('#ref');
this.unavailableButton = this.wrapperEl.querySelector('.unavailable');
this.unavailableButton = this.wrapperEl.querySelector('.unavailable');
this.unavailableButtonArrow = this.unavailableButton.querySelector('.fa');
this.unavailableButtonArrow = this.unavailableButton.querySelector('.fa');
this.unavailableButtonText = this.unavailableButton.querySelector('.text');
this.unavailableButtonText = this.unavailableButton.querySelector('.text');
@@ -138,7 +139,8 @@ export default class CreateMergeRequestDropdown {
@@ -138,7 +139,8 @@ export default class CreateMergeRequestDropdown {
this.createMergeRequestButton
this.createMergeRequestButton
.addEventListener('click', this.onClickCreateMergeRequestButton.bind(this));
.addEventListener('click', this.onClickCreateMergeRequestButton.bind(this));
this.branchNameInput.addEventListener('keyup', this.onChangeBranchNameInput.bind(this));
this.newBranchNameInput.addEventListener('keyup', this.onChangeNewBranchNameInput.bind(this));
 
this.refInput.addEventListener('keyup', this.onChangeRefInput.bind(this));
}
}
isBusy() {
isBusy() {
@@ -148,17 +150,17 @@ export default class CreateMergeRequestDropdown {
@@ -148,17 +150,17 @@ export default class CreateMergeRequestDropdown {
this.branchCreated;
this.branchCreated;
}
}
onChangeBranchNameInput(e) {
onChangeNewBranchNameInput() {
// 1. Change URL
// 1. Change URL
// 2. Check branch existence by this.checkBranchExists();
// 2. Check branch existence by this.checkBranchExists();
// Change the URL for a branch creation.
this.createBranchPath = this.createBranchPath.replace(/(branch_name=)(.+?)(?=&issue)/, "$1" + this.newBranchNameInput.value);
this.createBranchPath = this.wrapperEl.dataset.createBranchPath.
this.createMrPath = this.createMrPath.replace(/(branch_name=)(.+?)(?=&ref)/, "$1" + this.newBranchNameInput.value);
replace(/(branch_name)(.+?)(?=&issue)/, "$1=" + this.branchNameInput.value);
}
// Change the URL for a merge request creation.
onChangeRefInput() {
this.createMrPath = this.wrapperEl.dataset.createMrPath.
this.createBranchPath = this.createBranchPath.replace(/(ref=)(.+?)$/, "$1" + this.refInput.value);
replace(/(branch_name)(.+?)(?=&ref)/, "$1=" + this.branchNameInput.value);
this.createMrPath = this.createMrPath.replace(/(ref=)(.+?)$/, "$1" + this.refInput.value);
}
}
onClickCreateMergeRequestButton(e) {
onClickCreateMergeRequestButton(e) {
Loading