aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js
diff options
context:
space:
mode:
Diffstat (limited to 'web_src/js')
-rw-r--r--web_src/js/features/repo-settings.js26
1 files changed, 9 insertions, 17 deletions
diff --git a/web_src/js/features/repo-settings.js b/web_src/js/features/repo-settings.js
index 3d02a82bb6..9f094cd2d1 100644
--- a/web_src/js/features/repo-settings.js
+++ b/web_src/js/features/repo-settings.js
@@ -1,6 +1,5 @@
import $ from 'jquery';
import {createMonaco} from './codeeditor.js';
-import {initRepoCommonFilterSearchDropdown} from './repo-common.js';
const {appSubUrl, csrfToken} = window.config;
@@ -73,20 +72,13 @@ export function initRepoSettingGitHook() {
}
export function initRepoSettingBranches() {
- // Branches
- if ($('.repository.settings.branches').length > 0) {
- initRepoCommonFilterSearchDropdown('.protected-branches .dropdown');
- $('.enable-protection, .enable-whitelist, .enable-statuscheck').on('change', function () {
- if (this.checked) {
- $($(this).data('target')).removeClass('disabled');
- } else {
- $($(this).data('target')).addClass('disabled');
- }
- });
- $('.disable-whitelist').on('change', function () {
- if (this.checked) {
- $($(this).data('target')).addClass('disabled');
- }
- });
- }
+ if (!$('.repository.settings.branches').length) return;
+ $('.toggle-target-enabled').on('change', function () {
+ const $target = $($(this).attr('data-target'));
+ $target.toggleClass('disabled', !this.checked);
+ });
+ $('.toggle-target-disabled').on('change', function () {
+ const $target = $($(this).attr('data-target'));
+ if (this.checked) $target.addClass('disabled'); // only disable, do not auto enable
+ });
}