mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	settings: Convert module to typescript.
This commit is contained in:
		@@ -203,7 +203,7 @@ EXEMPT_FILES = make_set(
 | 
			
		||||
        "web/src/sent_messages.ts",
 | 
			
		||||
        "web/src/sentry.ts",
 | 
			
		||||
        "web/src/server_events.js",
 | 
			
		||||
        "web/src/settings.js",
 | 
			
		||||
        "web/src/settings.ts",
 | 
			
		||||
        "web/src/settings_account.ts",
 | 
			
		||||
        "web/src/settings_bots.ts",
 | 
			
		||||
        "web/src/settings_components.ts",
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@ import {$t, get_language_name, language_list} from "./i18n.ts";
 | 
			
		||||
import {page_params} from "./page_params.ts";
 | 
			
		||||
import * as people from "./people.ts";
 | 
			
		||||
import {realm_user_settings_defaults} from "./realm_user_settings_defaults.ts";
 | 
			
		||||
import * as settings from "./settings.js";
 | 
			
		||||
import * as settings from "./settings.ts";
 | 
			
		||||
import * as settings_bots from "./settings_bots.ts";
 | 
			
		||||
import * as settings_components from "./settings_components.ts";
 | 
			
		||||
import * as settings_config from "./settings_config.ts";
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@ function current_dialog_widget_selector(): string {
 | 
			
		||||
 *      2) We attach the DOM for the modal to the body element
 | 
			
		||||
 *         to avoid interference from other elements.
 | 
			
		||||
 *
 | 
			
		||||
 *      3) For settings, we have a click handler in settings.js
 | 
			
		||||
 *      3) For settings, we have a click handler in settings.ts
 | 
			
		||||
 *         that will close the dialog via modals.close_active.
 | 
			
		||||
 *
 | 
			
		||||
 *      4) We assume that since this is a modal, you will
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@ import * as popovers from "./popovers.ts";
 | 
			
		||||
import * as recent_view_ui from "./recent_view_ui.ts";
 | 
			
		||||
import * as recent_view_util from "./recent_view_util.ts";
 | 
			
		||||
import * as scheduled_messages_overlay_ui from "./scheduled_messages_overlay_ui.ts";
 | 
			
		||||
import * as settings from "./settings.js";
 | 
			
		||||
import * as settings from "./settings.ts";
 | 
			
		||||
import * as settings_panel_menu from "./settings_panel_menu.ts";
 | 
			
		||||
import * as settings_toggle from "./settings_toggle.ts";
 | 
			
		||||
import * as sidebar_ui from "./sidebar_ui.ts";
 | 
			
		||||
 
 | 
			
		||||
@@ -24,34 +24,7 @@ import {current_user, realm} from "./state_data.ts";
 | 
			
		||||
import * as timerender from "./timerender.ts";
 | 
			
		||||
import {user_settings} from "./user_settings.ts";
 | 
			
		||||
 | 
			
		||||
export let settings_label;
 | 
			
		||||
 | 
			
		||||
function setup_settings_label() {
 | 
			
		||||
    settings_label = {
 | 
			
		||||
        // settings_notification
 | 
			
		||||
        allow_private_data_export: $t({
 | 
			
		||||
            defaultMessage: "Let administrators export my private data",
 | 
			
		||||
        }),
 | 
			
		||||
        presence_enabled: $t({
 | 
			
		||||
            defaultMessage: "Display my availability to other users",
 | 
			
		||||
        }),
 | 
			
		||||
        presence_enabled_parens_text: $t({defaultMessage: "invisible mode off"}),
 | 
			
		||||
        send_stream_typing_notifications: $t({
 | 
			
		||||
            defaultMessage: "Let recipients see when I'm typing messages in channels",
 | 
			
		||||
        }),
 | 
			
		||||
        send_private_typing_notifications: $t({
 | 
			
		||||
            defaultMessage: "Let recipients see when I'm typing direct messages",
 | 
			
		||||
        }),
 | 
			
		||||
        send_read_receipts: $t({
 | 
			
		||||
            defaultMessage: "Let others see when I've read messages",
 | 
			
		||||
        }),
 | 
			
		||||
 | 
			
		||||
        ...settings_config.notification_settings_labels,
 | 
			
		||||
        ...settings_config.preferences_settings_labels,
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function get_parsed_date_of_joining() {
 | 
			
		||||
function get_parsed_date_of_joining(): string {
 | 
			
		||||
    const user_date_joined = people.get_by_user_id(current_user.user_id).date_joined;
 | 
			
		||||
    return timerender.get_localized_date_or_time_for_format(
 | 
			
		||||
        parseISO(user_date_joined),
 | 
			
		||||
@@ -59,14 +32,14 @@ function get_parsed_date_of_joining() {
 | 
			
		||||
    );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function user_can_change_password() {
 | 
			
		||||
function user_can_change_password(): boolean {
 | 
			
		||||
    if (settings_data.user_email_not_configured()) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    return realm.realm_email_auth_enabled;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function update_lock_icon_in_sidebar() {
 | 
			
		||||
export function update_lock_icon_in_sidebar(): void {
 | 
			
		||||
    if (current_user.is_owner) {
 | 
			
		||||
        $(".org-settings-list .locked").hide();
 | 
			
		||||
        return;
 | 
			
		||||
@@ -88,8 +61,29 @@ export function update_lock_icon_in_sidebar() {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function build_page() {
 | 
			
		||||
    setup_settings_label();
 | 
			
		||||
export function build_page(): void {
 | 
			
		||||
    const settings_label = {
 | 
			
		||||
        // settings_notification
 | 
			
		||||
        allow_private_data_export: $t({
 | 
			
		||||
            defaultMessage: "Let administrators export my private data",
 | 
			
		||||
        }),
 | 
			
		||||
        presence_enabled: $t({
 | 
			
		||||
            defaultMessage: "Display my availability to other users",
 | 
			
		||||
        }),
 | 
			
		||||
        presence_enabled_parens_text: $t({defaultMessage: "invisible mode off"}),
 | 
			
		||||
        send_stream_typing_notifications: $t({
 | 
			
		||||
            defaultMessage: "Let recipients see when I'm typing messages in channels",
 | 
			
		||||
        }),
 | 
			
		||||
        send_private_typing_notifications: $t({
 | 
			
		||||
            defaultMessage: "Let recipients see when I'm typing direct messages",
 | 
			
		||||
        }),
 | 
			
		||||
        send_read_receipts: $t({
 | 
			
		||||
            defaultMessage: "Let others see when I've read messages",
 | 
			
		||||
        }),
 | 
			
		||||
 | 
			
		||||
        ...settings_config.notification_settings_labels,
 | 
			
		||||
        ...settings_config.preferences_settings_labels,
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    const rendered_settings_tab = render_settings_tab({
 | 
			
		||||
        full_name: people.my_full_name(),
 | 
			
		||||
@@ -157,7 +151,7 @@ export function build_page() {
 | 
			
		||||
    common.adjust_mac_kbd_tags("#user_enter_sends_label kbd");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function open_settings_overlay() {
 | 
			
		||||
export function open_settings_overlay(): void {
 | 
			
		||||
    overlays.open_overlay({
 | 
			
		||||
        name: "settings",
 | 
			
		||||
        $overlay: $("#settings_overlay_container"),
 | 
			
		||||
@@ -169,7 +163,7 @@ export function open_settings_overlay() {
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function launch(section) {
 | 
			
		||||
export function launch(section: string): void {
 | 
			
		||||
    settings_sections.reset_sections();
 | 
			
		||||
 | 
			
		||||
    open_settings_overlay();
 | 
			
		||||
@@ -179,7 +173,7 @@ export function launch(section) {
 | 
			
		||||
    settings_toggle.goto("settings");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function initialize() {
 | 
			
		||||
export function initialize(): void {
 | 
			
		||||
    const rendered_settings_overlay = render_settings_overlay({
 | 
			
		||||
        is_owner: current_user.is_owner,
 | 
			
		||||
        is_admin: current_user.is_admin,
 | 
			
		||||
@@ -751,7 +751,7 @@ export function set_up(): void {
 | 
			
		||||
    );
 | 
			
		||||
    $("#user_deactivate_account_button").on("click", (e) => {
 | 
			
		||||
        // This click event must not get propagated to parent container otherwise the modal
 | 
			
		||||
        // will not show up because of a call to `close_active` in `settings.js`.
 | 
			
		||||
        // will not show up because of a call to `close_active` in `settings.ts`.
 | 
			
		||||
        e.preventDefault();
 | 
			
		||||
        e.stopPropagation();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -260,7 +260,7 @@ export function on_load_success(
 | 
			
		||||
    }
 | 
			
		||||
    $(".admin_invites_table").on("click", ".revoke", function (this: HTMLElement, e) {
 | 
			
		||||
        // This click event must not get propagated to parent container otherwise the modal
 | 
			
		||||
        // will not show up because of a call to `close_active` in `settings.js`.
 | 
			
		||||
        // will not show up because of a call to `close_active` in `settings.ts`.
 | 
			
		||||
        e.preventDefault();
 | 
			
		||||
        e.stopPropagation();
 | 
			
		||||
        const $row = $(this).closest(".invite_row");
 | 
			
		||||
@@ -294,7 +294,7 @@ export function on_load_success(
 | 
			
		||||
 | 
			
		||||
    $(".admin_invites_table").on("click", ".resend", function (this: HTMLElement, e) {
 | 
			
		||||
        // This click event must not get propagated to parent container otherwise the modal
 | 
			
		||||
        // will not show up because of a call to `close_active` in `settings.js`.
 | 
			
		||||
        // will not show up because of a call to `close_active` in `settings.ts`.
 | 
			
		||||
        e.preventDefault();
 | 
			
		||||
        e.stopPropagation();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -595,7 +595,7 @@ function start_data_load(): void {
 | 
			
		||||
function handle_deactivation($tbody: JQuery): void {
 | 
			
		||||
    $tbody.on("click", ".deactivate", (e) => {
 | 
			
		||||
        // This click event must not get propagated to parent container otherwise the modal
 | 
			
		||||
        // will not show up because of a call to `close_active` in `settings.js`.
 | 
			
		||||
        // will not show up because of a call to `close_active` in `settings.ts`.
 | 
			
		||||
        e.preventDefault();
 | 
			
		||||
        e.stopPropagation();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -103,7 +103,7 @@ import * as scroll_bar from "./scroll_bar.ts";
 | 
			
		||||
import * as scroll_util from "./scroll_util.ts";
 | 
			
		||||
import * as search from "./search.ts";
 | 
			
		||||
import * as server_events from "./server_events.js";
 | 
			
		||||
import * as settings from "./settings.js";
 | 
			
		||||
import * as settings from "./settings.ts";
 | 
			
		||||
import * as settings_data from "./settings_data.ts";
 | 
			
		||||
import * as settings_notifications from "./settings_notifications.ts";
 | 
			
		||||
import * as settings_panel_menu from "./settings_panel_menu.ts";
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ import * as narrow_state from "./narrow_state.ts";
 | 
			
		||||
import * as navbar_alerts from "./navbar_alerts.ts";
 | 
			
		||||
import * as people from "./people.ts";
 | 
			
		||||
import * as pm_list from "./pm_list.ts";
 | 
			
		||||
import * as settings from "./settings.js";
 | 
			
		||||
import * as settings from "./settings.ts";
 | 
			
		||||
import * as settings_account from "./settings_account.ts";
 | 
			
		||||
import * as settings_config from "./settings_config.ts";
 | 
			
		||||
import * as settings_exports from "./settings_exports.ts";
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user