settings: Use text cursor for "Email" when email changes are disabled.

This commit includes the following changes:
 - Use a regular text cursor in place of a pointer cursor for the
   "Email" field label when the email changes are disabled.
 - Implement tests to verify the above changes made.
This commit is contained in:
Saubhagya Patel
2024-12-08 16:27:53 +05:30
committed by Tim Abbott
parent ad766c802e
commit b15fb45408
3 changed files with 5 additions and 1 deletions

View File

@@ -83,9 +83,11 @@ export function update_email_change_display(): void {
if (!settings_data.user_can_change_email()) {
$("#change_email_button").prop("disabled", true);
$("#change_email_button_container").addClass("disabled_setting_tooltip");
$("label[for='change_email_button']").addClass("cursor-text");
} else {
$("#change_email_button").prop("disabled", false);
$("#change_email_button_container").removeClass("disabled_setting_tooltip");
$("label[for='change_email_button']").removeClass("cursor-text");
}
}

View File

@@ -7,7 +7,7 @@
<form class="grid">
{{#if user_has_email_set}}
<div class="input-group">
<label class="settings-field-label" for="change_email_button">{{t "Email" }}</label>
<label class="settings-field-label {{#unless user_can_change_email}}cursor-text{{/unless}}" for="change_email_button">{{t "Email" }}</label>
<div id="change_email_button_container" class="{{#unless user_can_change_email}}disabled_setting_tooltip{{/unless}}">
<button id="change_email_button" type="button" class="button rounded tippy-zulip-delayed-tooltip" data-tippy-content="{{t 'Change your email' }}" {{#unless user_can_change_email}}disabled="disabled"{{/unless}}>
{{current_user.delivery_email}}

View File

@@ -810,10 +810,12 @@ test("misc", ({override}) => {
override(realm, "realm_email_changes_disabled", false);
settings_account.update_email_change_display();
assert.ok(!$("#change_email_button").prop("disabled"));
assert.ok(!$("label[for='change_email_button']").hasClass("cursor-text"));
override(realm, "realm_email_changes_disabled", true);
settings_account.update_email_change_display();
assert.ok($("#change_email_button").prop("disabled"));
assert.ok($("label[for='change_email_button']").hasClass("cursor-text"));
override(realm, "realm_avatar_changes_disabled", false);
override(realm, "server_avatar_changes_disabled", false);