Some checks failed
cache-seeder / prune (push) Has been skipped
cache-seeder / frontend (push) Failing after 3s
cache-seeder / python (push) Failing after 3s
cache-seeder / gobuild (push) Failing after 4s
cache-seeder / lint (bindata, lint-backend) (push) Failing after 3s
giteabot backport / giteabot (push) Has been skipped
giteabot / giteabot (push) Has been skipped
cache-prune / prune (push) Has been skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Has been cancelled
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
35 lines
1.8 KiB
TypeScript
35 lines
1.8 KiB
TypeScript
import {registerGlobalInitFunc} from '../modules/observer.ts';
|
|
import {toggleElem, toggleElemClass} from '../utils/dom.ts';
|
|
|
|
export function initActionsPermissionsForm(): void {
|
|
registerGlobalInitFunc('initRepoActionsPermissionsForm', initRepoActionsPermissionsForm);
|
|
registerGlobalInitFunc('initOwnerActionsPermissionsForm', initOwnerActionsPermissionsForm);
|
|
}
|
|
|
|
function initRepoActionsPermissionsForm(form: HTMLFormElement) {
|
|
initActionsOverrideOwnerConfig(form);
|
|
initActionsPermissionTable(form);
|
|
}
|
|
|
|
function initOwnerActionsPermissionsForm(form: HTMLFormElement) {
|
|
initActionsPermissionTable(form);
|
|
}
|
|
|
|
function initActionsPermissionTable(form: HTMLFormElement) {
|
|
// show or hide permissions table based on enable max permissions checkbox (aka: whether you use custom permissions or not)
|
|
const permTable = form.querySelector<HTMLTableElement>('.js-permissions-table')!;
|
|
const enableMaxCheckbox = form.querySelector<HTMLInputElement>('input[name=enable_max_permissions]')!;
|
|
const onEnableMaxCheckboxChange = () => toggleElem(permTable, enableMaxCheckbox.checked);
|
|
onEnableMaxCheckboxChange();
|
|
enableMaxCheckbox.addEventListener('change', onEnableMaxCheckboxChange);
|
|
}
|
|
|
|
function initActionsOverrideOwnerConfig(form: HTMLFormElement) {
|
|
// enable or disable repo token permissions config section based on override owner config checkbox
|
|
const overrideOwnerConfig = form.querySelector<HTMLInputElement>('input[name=override_owner_config]')!;
|
|
const repoTokenPermConfigSection = form.querySelector('.js-repo-token-permissions-config')!;
|
|
const onOverrideOwnerConfigChange = () => toggleElemClass(repoTokenPermConfigSection, 'container-disabled', !overrideOwnerConfig.checked);
|
|
onOverrideOwnerConfigChange();
|
|
overrideOwnerConfig.addEventListener('change', onOverrideOwnerConfigChange);
|
|
}
|