mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-29 14:31:09 +02:00
ui fixes
This commit is contained in:
parent
7cccb84fdb
commit
6d14a69d9c
@ -36,7 +36,7 @@
|
||||
<!-- Override Organization Configuration -->
|
||||
<div class="field">
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="override_org_config" id="override-org-config" {{if .OverrideOrgConfig}}checked{{end}} class="js-follow-org-config">
|
||||
<input type="checkbox" name="override_org_config" id="override-org-config" {{if .OverrideOrgConfig}}checked{{end}} class="js-override-org-config">
|
||||
<label><strong>{{ctx.Locale.Tr "actions.general.token_permissions.override_org"}}</strong></label>
|
||||
</div>
|
||||
<p class="help">{{ctx.Locale.Tr "actions.general.token_permissions.override_org_desc"}}</p>
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user