Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove jQuery calls that have no effect on showElem and hideElem #30110

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions web_src/js/features/admin/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export function initAdminCommon() {
if ($(this).val().substring(0, 1) === '0') {
$('#user_name').removeAttr('disabled');
$('#login_name').removeAttr('required');
hideElem($('.non-local'));
showElem($('.local'));
hideElem('.non-local');
showElem('.local');
$('#user_name').trigger('focus');

if ($(this).data('password') === 'required') {
Expand All @@ -29,8 +29,8 @@ export function initAdminCommon() {
$('#user_name').attr('disabled', 'disabled');
}
$('#login_name').attr('required', 'required');
showElem($('.non-local'));
hideElem($('.local'));
showElem('.non-local');
hideElem('.local');
$('#login_name').trigger('focus');

$('#password').removeAttr('required');
Expand All @@ -40,9 +40,9 @@ export function initAdminCommon() {

function onSecurityProtocolChange() {
if ($('#security_protocol').val() > 0) {
showElem($('.has-tls'));
showElem('.has-tls');
} else {
hideElem($('.has-tls'));
hideElem('.has-tls');
}
}

Expand All @@ -57,29 +57,29 @@ export function initAdminCommon() {
}

function onOAuth2Change(applyDefaultValues) {
hideElem($('.open_id_connect_auto_discovery_url, .oauth2_use_custom_url'));
hideElem('.open_id_connect_auto_discovery_url, .oauth2_use_custom_url');
$('.open_id_connect_auto_discovery_url input[required]').removeAttr('required');

const provider = $('#oauth2_provider').val();
switch (provider) {
case 'openidConnect':
$('.open_id_connect_auto_discovery_url input').attr('required', 'required');
showElem($('.open_id_connect_auto_discovery_url'));
showElem('.open_id_connect_auto_discovery_url');
break;
default:
if ($(`#${provider}_customURLSettings`).data('required')) {
$('#oauth2_use_custom_url').attr('checked', 'checked');
}
if ($(`#${provider}_customURLSettings`).data('available')) {
showElem($('.oauth2_use_custom_url'));
showElem('.oauth2_use_custom_url');
}
}
onOAuth2UseCustomURLChange(applyDefaultValues);
}

function onOAuth2UseCustomURLChange(applyDefaultValues) {
const provider = $('#oauth2_provider').val();
hideElem($('.oauth2_use_custom_url_field'));
hideElem('.oauth2_use_custom_url_field');
$('.oauth2_use_custom_url_field input[required]').removeAttr('required');

if (document.getElementById('oauth2_use_custom_url')?.checked) {
Expand All @@ -102,38 +102,38 @@ export function initAdminCommon() {
// New authentication
if ($('.admin.new.authentication').length > 0) {
$('#auth_type').on('change', function () {
hideElem($('.ldap, .dldap, .smtp, .pam, .oauth2, .has-tls, .search-page-size, .sspi'));
hideElem('.ldap, .dldap, .smtp, .pam, .oauth2, .has-tls, .search-page-size, .sspi');

$('.ldap input[required], .binddnrequired input[required], .dldap input[required], .smtp input[required], .pam input[required], .oauth2 input[required], .has-tls input[required], .sspi input[required]').removeAttr('required');
$('.binddnrequired').removeClass('required');

const authType = $(this).val();
switch (authType) {
case '2': // LDAP
showElem($('.ldap'));
showElem('.ldap');
$('.binddnrequired input, .ldap div.required:not(.dldap) input').attr('required', 'required');
$('.binddnrequired').addClass('required');
break;
case '3': // SMTP
showElem($('.smtp'));
showElem($('.has-tls'));
showElem('.smtp');
showElem('.has-tls');
$('.smtp div.required input, .has-tls').attr('required', 'required');
break;
case '4': // PAM
showElem($('.pam'));
showElem('.pam');
$('.pam input').attr('required', 'required');
break;
case '5': // LDAP
showElem($('.dldap'));
showElem('.dldap');
$('.dldap div.required:not(.ldap) input').attr('required', 'required');
break;
case '6': // OAuth2
showElem($('.oauth2'));
showElem('.oauth2');
$('.oauth2 div.required:not(.oauth2_use_custom_url,.oauth2_use_custom_url_field,.open_id_connect_auto_discovery_url) input').attr('required', 'required');
onOAuth2Change(true);
break;
case '7': // SSPI
showElem($('.sspi'));
showElem('.sspi');
$('.sspi div.required input').attr('required', 'required');
break;
}
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/features/org-team.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export function initOrgTeamSettings() {
$('.organization.new.team input[name=permission]').on('change', () => {
const val = $('input[name=permission]:checked', '.organization.new.team').val();
if (val === 'admin') {
hideElem($('.organization.new.team .team-units'));
hideElem('.organization.new.team .team-units');
} else {
showElem($('.organization.new.team .team-units'));
showElem('.organization.new.team .team-units');
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/features/repo-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ export function initRepoEditor() {

$('.js-quick-pull-choice-option').on('change', function () {
if ($(this).val() === 'commit-to-new-branch') {
showElem($('.quick-pull-branch-name'));
showElem('.quick-pull-branch-name');
document.querySelector('.quick-pull-branch-name input').required = true;
} else {
hideElem($('.quick-pull-branch-name'));
hideElem('.quick-pull-branch-name');
document.querySelector('.quick-pull-branch-name input').required = false;
}
$('#commit-button').text(this.getAttribute('button_text'));
Expand Down