From 7d3d930137206b346eb29d69a57750371b530ff9 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 4 Feb 2026 16:26:29 -0800 Subject: [PATCH] backups: Show/hide form elements instead of disabling for simplicity - Unlike the case of network forms, for example, there is nothing the user could infer from a disabled form element. If they see a disabled DNS field, they would understand that it is an editable value but has been disabled due to other option values. It is important to allow users to discover this. However, in case of password fields, they are not needed to be shown to the user unless the appropriate option is selected. Tests: - In the add remote repository form, selecting the authentication type radio options shows and hides the password field. Selecting the value for encryption type shows and hides the encryption password field. Signed-off-by: Sunil Mohan Adapa --- .../static/backups_add_remote_repository.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/plinth/modules/backups/static/backups_add_remote_repository.js b/plinth/modules/backups/static/backups_add_remote_repository.js index 3377259e3..b1ab34317 100644 --- a/plinth/modules/backups/static/backups_add_remote_repository.js +++ b/plinth/modules/backups/static/backups_add_remote_repository.js @@ -31,24 +31,21 @@ document.addEventListener('DOMContentLoaded', () => { const encryptionConfirmPassphraseField = document.getElementById('id_confirm_encryption_passphrase'); function handleAuthTypeChange() { - if (keyAuth.checked) { - sshPasswordField.value = ""; - sshPasswordField.disabled = true; + if (passwordAuth.checked) { + sshPasswordField.parentElement.parentElement.style.display = 'block'; } else { - sshPasswordField.disabled = false; + sshPasswordField.parentElement.parentElement.style.display = 'none'; } } function handleEncryptionTypeChange() { + let display = 'none'; if (encryptionType.value === "repokey") { - encryptionPassphraseField.disabled = false; - encryptionConfirmPassphraseField.disabled = false; - } else { - encryptionPassphraseField.value = ""; - encryptionPassphraseField.disabled = true; - encryptionConfirmPassphraseField.value = ""; - encryptionConfirmPassphraseField.disabled = true; + display = 'block'; } + + encryptionPassphraseField.parentElement.parentElement.style.display = display; + encryptionConfirmPassphraseField.parentElement.parentElement.style.display = display; } keyAuth.addEventListener('change', handleAuthTypeChange);