This commit is contained in:
Excellencedev committed 2026-01-16 16:30:58 +01:00
1 parent 7cccb84fdb
commit 6d14a69d9c
2 files changed
+12 -9

No files matched your search

+11 -8
View File
@@ -2,27 +2,30 @@ export function initActionsPermissionsTable(): void {
const modeRadios = document.querySelectorAll<HTMLInputElement>('.js-permission-mode-radio');
const permTable = document.querySelector<HTMLTableElement>('table.js-permissions-table');
const tableSection = document.querySelector<HTMLElement>('#max-permissions-section');
const followOrgCheckbox = document.querySelector<HTMLInputElement>('.js-follow-org-config');
const overrideOrgCheckbox = document.querySelector<HTMLInputElement>('.js-override-org-config');
const modeSection = document.querySelector<HTMLElement>('.js-permission-mode-section');
if (!modeRadios.length) return;
function updateTableState(): void {
const followOrg = followOrgCheckbox?.checked ?? false;
// If the checkbox exists (Repo settings), we are disabled if it is NOT checked (Follow mode).
// If the checkbox does not exist (Org settings), we are never disabled by this rule.
const shouldDisable = overrideOrgCheckbox ? !overrideOrgCheckbox.checked : false;
const selectedMode = document.querySelector<HTMLInputElement>('input[name="token_permission_mode"]:checked');
const isCustom = selectedMode?.value === 'custom';
// Disable entire form when following org config
// Disable entire form when following org config (Override unchecked)
for (const radio of modeRadios) {
radio.disabled = followOrg;
radio.disabled = shouldDisable;
}
if (modeSection) {
modeSection.style.opacity = followOrg ? '0.5' : '1';
modeSection.style.opacity = shouldDisable ? '0.5' : '1';
}
// Disable table if not custom OR following org
const tableDisabled = !isCustom || followOrg;
// Disable table if layout is disabled OR mode is not custom
const tableDisabled = shouldDisable || !isCustom;
if (permTable) {
const inputs = permTable.querySelectorAll<HTMLInputElement>('input[type="radio"]');
for (const input of inputs) {
@@ -40,7 +43,7 @@ export function initActionsPermissionsTable(): void {
radio.addEventListener('change', updateTableState);
}
followOrgCheckbox?.addEventListener('change', updateTableState);
overrideOrgCheckbox?.addEventListener('change', updateTableState);
updateTableState();