e0fe2834eb
Now you can create a new file and select a target_branch != source_branch. If the file that you want to create already exists on the target branch an error message is shown A glDropdown is used to select and create a new branch instead of a text field.
37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-return-assign, max-len */
|
|
(function() {
|
|
var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; };
|
|
|
|
this.NewCommitForm = (function() {
|
|
function NewCommitForm(form, targetBranchName = 'target_branch') {
|
|
this.form = form;
|
|
this.targetBranchName = targetBranchName;
|
|
this.renderDestination = bind(this.renderDestination, this);
|
|
this.targetBranchDropdown = form.find('button.js-target-branch');
|
|
this.originalBranch = form.find('.js-original-branch');
|
|
this.createMergeRequest = form.find('.js-create-merge-request');
|
|
this.createMergeRequestContainer = form.find('.js-create-merge-request-container');
|
|
this.targetBranchDropdown.on('change.branch', this.renderDestination);
|
|
this.renderDestination();
|
|
}
|
|
|
|
NewCommitForm.prototype.renderDestination = function() {
|
|
var different;
|
|
var targetBranch = this.form.find(`input[name="${this.targetBranchName}"]`);
|
|
|
|
different = targetBranch.val() !== this.originalBranch.val();
|
|
if (different) {
|
|
this.createMergeRequestContainer.show();
|
|
if (!this.wasDifferent) {
|
|
this.createMergeRequest.prop('checked', true);
|
|
}
|
|
} else {
|
|
this.createMergeRequestContainer.hide();
|
|
this.createMergeRequest.prop('checked', false);
|
|
}
|
|
return this.wasDifferent = different;
|
|
};
|
|
|
|
return NewCommitForm;
|
|
})();
|
|
}).call(window);
|