From 18e98a364388e53786c7fe01eaff75efa496bb4c Mon Sep 17 00:00:00 2001
From: Alfredo Sumaran <alfredo@gitlab.com>
Date: Sun, 21 Aug 2016 00:19:22 -0500
Subject: [PATCH] Do not update if one dropdown has not selected any option

No need to update the branch permission if no option is marked on the dropdown
---
 app/assets/javascripts/protected_branch_edit.js.es6 | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/app/assets/javascripts/protected_branch_edit.js.es6 b/app/assets/javascripts/protected_branch_edit.js.es6
index a59fcbfa082..40bc4adb71b 100644
--- a/app/assets/javascripts/protected_branch_edit.js.es6
+++ b/app/assets/javascripts/protected_branch_edit.js.es6
@@ -31,6 +31,9 @@
       const $allowedToMergeInput = this.$wrap.find(`input[name="${this.$allowedToMergeDropdown.data('fieldName')}"]`);
       const $allowedToPushInput = this.$wrap.find(`input[name="${this.$allowedToPushDropdown.data('fieldName')}"]`);
 
+      // Do not update if one dropdown has not selected any option
+      if (!($allowedToMergeInput.length && $allowedToPushInput.length)) return; 
+
       $.ajax({
         type: 'POST',
         url: this.$wrap.data('url'),
-- 
GitLab