change_password_modal: Hide the dialog spinner when action fails.

This commit also add the comma(,) and exclamation mark(!) to the
error messages wherever they were missing.

This commit modify the settings_change_error function to show the error
inside the modal, instead of the settings panel behind it.
This commit is contained in:
Maneesh Shukla
2025-02-05 18:13:22 +05:30
committed by Tim Abbott
parent 47f21ae9c5
commit 205cfc0f85
3 changed files with 10 additions and 9 deletions

View File

@@ -60,7 +60,7 @@ export function password_warning(password: string, $password_field: JQuery): str
if (password.length < min_length) {
return $t(
{defaultMessage: "Password should be at least {length} characters long"},
{defaultMessage: "Password should be at least {length} characters long."},
{length: min_length},
);
} else if (password.length > max_length) {
@@ -71,5 +71,5 @@ export function password_warning(password: string, $password_field: JQuery): str
{max: max_length},
);
}
return zxcvbn(password).feedback.warning ?? $t({defaultMessage: "Password is too weak"});
return zxcvbn(password).feedback.warning ?? $t({defaultMessage: "Password is too weak."});
}

View File

@@ -199,7 +199,8 @@ export function update_send_read_receipts_tooltip(): void {
}
function settings_change_error(message_html: string, xhr?: JQuery.jqXHR): void {
ui_report.error(message_html, xhr, $("#account-settings-status").expectOne());
ui_report.error(message_html, xhr, $("#dialog_error"));
dialog_widget.hide_dialog_spinner();
}
function update_custom_profile_field(
@@ -463,7 +464,7 @@ export function set_up(): void {
if (old_password === "") {
ui_report.error(
$t_html({defaultMessage: "Please enter your password"}),
$t_html({defaultMessage: "Please enter your password."}),
undefined,
$("#dialog_error"),
);
@@ -472,7 +473,7 @@ export function set_up(): void {
if (new_password === "") {
ui_report.error(
$t_html({defaultMessage: "Please choose a new password"}),
$t_html({defaultMessage: "Please choose a new password."}),
undefined,
$("#dialog_error"),
);
@@ -483,7 +484,7 @@ export function set_up(): void {
if (new_password && new_password.toString().length > max_length) {
ui_report.error(
$t_html(
{defaultMessage: "Maximum password length: {max_length} characters"},
{defaultMessage: "Maximum password length: {max_length} characters."},
{max_length},
),
undefined,
@@ -549,7 +550,7 @@ export function set_up(): void {
);
return;
} else if (!password_quality(new_pw, undefined, $new_pw_field)) {
settings_change_error($t_html({defaultMessage: "New password is too weak"}));
settings_change_error($t_html({defaultMessage: "New password is too weak!"}));
return;
}
}

View File

@@ -59,7 +59,7 @@ run_test("basics w/progress bar", () => {
assert.equal($bar.w, "39.7%");
assert.equal($bar.added_class, "bar-danger");
warning = password_warning(password, password_field(10));
assert.equal(warning, "translated: Password should be at least 10 characters long");
assert.equal(warning, "translated: Password should be at least 10 characters long.");
password = "foo";
accepted = password_quality(password, $bar, password_field(2, 200, 10));
@@ -67,7 +67,7 @@ run_test("basics w/progress bar", () => {
assert.equal($bar.w, "10.390277164940581%");
assert.equal($bar.added_class, "bar-success");
warning = password_warning(password, password_field(2));
assert.equal(warning, "translated: Password is too weak");
assert.equal(warning, "translated: Password is too weak.");
password = "aaaaaaaa";
accepted = password_quality(password, $bar, password_field(6, 1e100));