summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/new_commit_form.js
diff options
context:
space:
mode:
authorJacopo <beschi.jacopo@gmail.com>2016-12-22 07:21:40 +0100
committerJacopo <beschi.jacopo@gmail.com>2017-03-13 16:36:11 +0100
commite0fe2834ebe6d9678444c8a10b79ca093f944232 (patch)
treea2d7c482f7271d8af7ba47e76c9d48a1d3e357f4 /app/assets/javascripts/new_commit_form.js
parent9ed3db915026c6e0cd266a1c276386e3e96d2151 (diff)
downloadgitlab-ce-e0fe2834ebe6d9678444c8a10b79ca093f944232.tar.gz
New file from interface on existing branch
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.
Diffstat (limited to 'app/assets/javascripts/new_commit_form.js')
-rw-r--r--app/assets/javascripts/new_commit_form.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/assets/javascripts/new_commit_form.js b/app/assets/javascripts/new_commit_form.js
index 747f693726e..ad36f08840d 100644
--- a/app/assets/javascripts/new_commit_form.js
+++ b/app/assets/javascripts/new_commit_form.js
@@ -3,19 +3,23 @@
var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; };
this.NewCommitForm = (function() {
- function NewCommitForm(form) {
+ function NewCommitForm(form, targetBranchName = 'target_branch') {
+ this.form = form;
+ this.targetBranchName = targetBranchName;
this.renderDestination = bind(this.renderDestination, this);
- this.newBranch = form.find('.js-target-branch');
+ 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();
- this.newBranch.keyup(this.renderDestination);
}
NewCommitForm.prototype.renderDestination = function() {
var different;
- different = this.newBranch.val() !== this.originalBranch.val();
+ var targetBranch = this.form.find(`input[name="${this.targetBranchName}"]`);
+
+ different = targetBranch.val() !== this.originalBranch.val();
if (different) {
this.createMergeRequestContainer.show();
if (!this.wasDifferent) {