Skip to content

Commit c1ae1ad

Browse files
committed
auto toggle "private" checkbox by repo name
1 parent 873dc8f commit c1ae1ad

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

web_src/js/features/repo-new.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,19 @@ export function initRepoNew() {
1515
updateUiAutoInit();
1616

1717
const inputRepoName = form.querySelector<HTMLInputElement>('input[name="repo_name"]');
18+
const inputPrivate = form.querySelector<HTMLInputElement>('input[name="private"]');
1819
const updateUiRepoName = () => {
1920
const helps = form.querySelectorAll(`.help[data-help-for-repo-name]`);
2021
hideElem(helps);
2122
let help = form.querySelector(`.help[data-help-for-repo-name="${CSS.escape(inputRepoName.value)}"]`);
2223
if (!help) help = form.querySelector(`.help[data-help-for-repo-name=""]`);
2324
showElem(help);
25+
const repoNamePreferPrivate = {'.profile': false, '.profile-private': true};
26+
const preferPrivate = repoNamePreferPrivate[inputRepoName.value];
27+
// inputPrivate might be disabled because site admin "force private"
28+
if (preferPrivate !== undefined && !inputPrivate.closest('.disabled, [disabled]')) {
29+
inputPrivate.checked = preferPrivate;
30+
}
2431
};
2532
inputRepoName.addEventListener('input', updateUiRepoName);
2633
updateUiRepoName();

0 commit comments

Comments
 (0)