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 <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa committed 2026-02-05 22:33:26 -08:00
1 parent ad40072267
commit 7d3d930137
1 file changed
+8 -11
@@ -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);