Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

settings: Refactor the confirmation notice for email changes.

Saubhagya Patel74112e4034ba
diff --git a/web/src/settings_account.ts b/web/src/settings_account.ts
index e3d53d2ae96..362ff9596ac 100644
--- a/web/src/settings_account.ts
+++ b/web/src/settings_account.ts
@@ -17,6 +17,7 @@ import type {PillUpdateField} from "./custom_profile_fields_ui.ts";
import * as dialog_widget from "./dialog_widget.ts";
import {$t_html} from "./i18n.ts";
import * as keydown_util from "./keydown_util.ts";
+import * as loading from "./loading.ts";
import * as modals from "./modals.ts";
import * as overlays from "./overlays.ts";
import {page_params} from "./page_params.ts";
@@ -579,36 +580,40 @@ export function set_up(): void {
const data = {
email: $("#change_email_form").find<HTMLInputElement>("input[name='email']").val(),
};
+ const $status_element = $("#email-change-status").expectOne();
- const opts = {
- success_continuation() {
+ /* Ideally, this code path would use do_settings_change; we're avoiding it
+ in order to do the success feedback without a banner. */
+ $status_element.fadeTo(0, 1);
+ loading.make_indicator($status_element, {text: settings_ui.strings.saving});
+
+ void channel.patch({
+ url: "/json/settings",
+ data,
+ success() {
+ ui_report.message(
+ $t_html(
+ {
+ defaultMessage:
+ "Check your email ({email}) to confirm the new address.",
+ },
+ {email: data.email},
+ ),
+ $status_element,
+ "inline-block",
+ );
if (page_params.development_environment) {
const email_msg = render_settings_dev_env_email_access();
- ui_report.success(
- email_msg,
- $("#dev-account-settings-status").expectOne(),
- 4000,
- );
+ ui_report.success(email_msg, $("#dev-account-settings-status").expectOne());
}
dialog_widget.close();
},
- error_continuation() {
+ error(xhr) {
+ loading.destroy_indicator($status_element);
+ ui_report.error(settings_ui.strings.failure_html, xhr, $change_email_error);
dialog_widget.hide_dialog_spinner();
},
- $error_msg_element: $change_email_error,
- success_msg_html: $t_html(
- {defaultMessage: "Check your email ({email}) to confirm the new address."},
- {email: data.email},
- ),
- sticky: true,
- };
- settings_ui.do_settings_change(
- channel.patch,
- "/json/settings",
- data,
- $("#account-settings-status").expectOne(),
- opts,
- );
+ });
}
$("#change_email_button").on("click", (e) => {
diff --git a/web/templates/settings/account_settings.hbs b/web/templates/settings/account_settings.hbs
index 05dd0fbe1cb..dbf0ec1ff33 100644
--- a/web/templates/settings/account_settings.hbs
+++ b/web/templates/settings/account_settings.hbs
@@ -13,6 +13,7 @@
{{current_user.delivery_email}}
</button>
</div>
+ <div id="email-change-status"></div>
</div>
{{else}}
{{! Demo organizations before the owner has configured an email address. }}