mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-05 04:05:32 +02:00
Re-implement changes for feedback
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
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 modeSection = document.querySelector<HTMLElement>('.js-permission-mode-section');
|
||||
|
||||
if (!modeRadios.length) return;
|
||||
|
||||
function updateTableState(): void {
|
||||
const followOrg = followOrgCheckbox?.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
|
||||
for (const radio of modeRadios) {
|
||||
radio.disabled = followOrg;
|
||||
}
|
||||
|
||||
if (modeSection) {
|
||||
modeSection.style.opacity = followOrg ? '0.5' : '1';
|
||||
}
|
||||
|
||||
// Disable table if not custom OR following org
|
||||
const tableDisabled = !isCustom || followOrg;
|
||||
if (permTable) {
|
||||
const inputs = permTable.querySelectorAll<HTMLInputElement>('input[type="radio"]');
|
||||
for (const input of inputs) {
|
||||
input.disabled = tableDisabled;
|
||||
}
|
||||
permTable.style.opacity = tableDisabled ? '0.5' : '1';
|
||||
}
|
||||
|
||||
if (tableSection) {
|
||||
tableSection.style.opacity = tableDisabled ? '0.5' : '1';
|
||||
}
|
||||
}
|
||||
|
||||
for (const radio of modeRadios) {
|
||||
radio.addEventListener('change', updateTableState);
|
||||
}
|
||||
|
||||
followOrgCheckbox?.addEventListener('change', updateTableState);
|
||||
|
||||
updateTableState();
|
||||
}
|
||||
@@ -64,6 +64,7 @@ import {initGlobalButtonClickOnEnter, initGlobalButtons, initGlobalDeleteButton}
|
||||
import {initGlobalComboMarkdownEditor, initGlobalEnterQuickSubmit, initGlobalFormDirtyLeaveConfirm} from './features/common-form.ts';
|
||||
import {callInitFunctions} from './modules/init.ts';
|
||||
import {initRepoViewFileTree} from './features/repo-view-file-tree.ts';
|
||||
import {initActionsPermissionsTable} from './features/repo-settings-actions.ts';
|
||||
|
||||
const initStartTime = performance.now();
|
||||
const initPerformanceTracer = callInitFunctions([
|
||||
@@ -158,6 +159,7 @@ const initPerformanceTracer = callInitFunctions([
|
||||
initOAuth2SettingsDisableCheckbox,
|
||||
|
||||
initRepoFileView,
|
||||
initActionsPermissionsTable,
|
||||
]);
|
||||
|
||||
// it must be the last one, then the "querySelectorAll" only needs to be executed once for global init functions.
|
||||
|
||||
Reference in New Issue
Block a user