mirror of https://github.com/zulip/zulip.git
settings-modal: Only update display if overlay loaded in DOM.
If the personal / organization settings overlay has not been loaded to the DOM in the user's session, then there's no need to update the overlay display for changes to the user's permissions to update their name, email or avatar. So we check for the relevant element ids before updating the overlay display when the user's role or these organization settings change, and return early if they are not present in the DOM.
This commit is contained in:
parent
9a7f33ab98
commit
578af48632
|
@ -720,6 +720,8 @@ test("test get_sorted_options_list", () => {
|
||||||
|
|
||||||
test("misc", ({override_rewire}) => {
|
test("misc", ({override_rewire}) => {
|
||||||
page_params.is_admin = false;
|
page_params.is_admin = false;
|
||||||
|
$("#user-avatar-upload-widget").length = 1;
|
||||||
|
$("#user_details_section").length = 1;
|
||||||
|
|
||||||
const $stub_notification_disable_parent = $.create("<stub notification_disable parent");
|
const $stub_notification_disable_parent = $.create("<stub notification_disable parent");
|
||||||
$stub_notification_disable_parent.set_find_results(
|
$stub_notification_disable_parent.set_find_results(
|
||||||
|
|
|
@ -51,6 +51,10 @@ export function update_full_name(new_full_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function update_name_change_display() {
|
export function update_name_change_display() {
|
||||||
|
if ($("#user_details_section").length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!settings_data.user_can_change_name()) {
|
if (!settings_data.user_can_change_name()) {
|
||||||
$("#full_name").prop("disabled", true);
|
$("#full_name").prop("disabled", true);
|
||||||
$(".change_name_tooltip").show();
|
$(".change_name_tooltip").show();
|
||||||
|
@ -61,6 +65,10 @@ export function update_name_change_display() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function update_email_change_display() {
|
export function update_email_change_display() {
|
||||||
|
if ($("#user_details_section").length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!settings_data.user_can_change_email()) {
|
if (!settings_data.user_can_change_email()) {
|
||||||
$("#change_email_button").prop("disabled", true);
|
$("#change_email_button").prop("disabled", true);
|
||||||
$("#change_email_button_container").addClass("email_changes_disabled_tooltip");
|
$("#change_email_button_container").addClass("email_changes_disabled_tooltip");
|
||||||
|
@ -116,6 +124,10 @@ function upload_avatar($file_input) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function update_avatar_change_display() {
|
export function update_avatar_change_display() {
|
||||||
|
if ($("#user-avatar-upload-widget").length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!settings_data.user_can_change_avatar()) {
|
if (!settings_data.user_can_change_avatar()) {
|
||||||
$("#user-avatar-upload-widget .image_upload_button").addClass("hide");
|
$("#user-avatar-upload-widget .image_upload_button").addClass("hide");
|
||||||
$("#user-avatar-upload-widget .image-disabled").removeClass("hide");
|
$("#user-avatar-upload-widget .image-disabled").removeClass("hide");
|
||||||
|
@ -130,6 +142,10 @@ export function update_avatar_change_display() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function update_account_settings_display() {
|
export function update_account_settings_display() {
|
||||||
|
if ($("#user_details_section").length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
update_name_change_display();
|
update_name_change_display();
|
||||||
update_email_change_display();
|
update_email_change_display();
|
||||||
update_avatar_change_display();
|
update_avatar_change_display();
|
||||||
|
|
Loading…
Reference in New Issue