settings: Remove unnecessary if condtions checking for_realm_settings.

This commit removes unnecessary if condtions which are checking
for_realm_settings value which are basically present to handle
the code which is only for user-level settings, but since we
now return early for the realm-level defaults code we do not
need these conditions.

This is done in a separate commit just to make the original commit
adding save/discard widget easy to review.
This commit is contained in:
Sahil Batra 2021-10-01 00:14:04 +05:30 committed by Tim Abbott
parent 8528914131
commit 89be686d9e
2 changed files with 38 additions and 45 deletions

View File

@ -106,42 +106,40 @@ export function set_up(settings_panel) {
});
}
if (!for_realm_settings) {
$(language_modal_elem)
.find(".language")
.on("click", (e) => {
e.preventDefault();
e.stopPropagation();
overlays.close_modal(language_modal_elem);
const $link = $(e.target).closest("a[data-code]");
const setting_value = $link.attr("data-code");
const data = {default_language: setting_value};
const new_language = $link.attr("data-name");
container.find(".default_language_name").text(new_language);
change_display_setting(
data,
settings_panel,
".language-settings-status",
$t_html(
{
defaultMessage:
"Saved. Please <z-link>reload</z-link> for the change to take effect.",
},
{"z-link": (content_html) => `<a class='reload_link'>${content_html}</a>`},
),
true,
);
});
container.find(".setting_default_language").on("click", (e) => {
$(language_modal_elem)
.find(".language")
.on("click", (e) => {
e.preventDefault();
e.stopPropagation();
overlays.open_modal(language_modal_elem);
overlays.close_modal(language_modal_elem);
const $link = $(e.target).closest("a[data-code]");
const setting_value = $link.attr("data-code");
const data = {default_language: setting_value};
const new_language = $link.attr("data-name");
container.find(".default_language_name").text(new_language);
change_display_setting(
data,
settings_panel,
".language-settings-status",
$t_html(
{
defaultMessage:
"Saved. Please <z-link>reload</z-link> for the change to take effect.",
},
{"z-link": (content_html) => `<a class='reload_link'>${content_html}</a>`},
),
true,
);
});
}
container.find(".setting_default_language").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
overlays.open_modal(language_modal_elem);
});
container.find(".setting_twenty_four_hour_time").on("change", function () {
const data = {twenty_four_hour_time: this.value};

View File

@ -161,19 +161,14 @@ export function set_up(settings_panel) {
// This final patch of settings are ones for which we
// intentionally don't let organization administrators set
// organization-level defaults.
container.find(".send_test_notification").on("click", () => {
notifications.send_test_notification(
$t({defaultMessage: "This is what a Zulip notification looks like."}),
);
});
if (!for_realm_settings) {
container.find(".send_test_notification").on("click", () => {
notifications.send_test_notification(
$t({defaultMessage: "This is what a Zulip notification looks like."}),
);
});
}
if (!for_realm_settings) {
set_enable_marketing_emails_visibility();
rerender_ui();
}
set_enable_marketing_emails_visibility();
rerender_ui();
}
export function update_page(settings_panel) {