mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
settings_sections: Convert module to typescript.
This commit is contained in:
@@ -220,7 +220,7 @@ EXEMPT_FILES = make_set(
|
|||||||
"web/src/settings_profile_fields.ts",
|
"web/src/settings_profile_fields.ts",
|
||||||
"web/src/settings_realm_domains.ts",
|
"web/src/settings_realm_domains.ts",
|
||||||
"web/src/settings_realm_user_settings_defaults.ts",
|
"web/src/settings_realm_user_settings_defaults.ts",
|
||||||
"web/src/settings_sections.js",
|
"web/src/settings_sections.ts",
|
||||||
"web/src/settings_streams.ts",
|
"web/src/settings_streams.ts",
|
||||||
"web/src/settings_toggle.js",
|
"web/src/settings_toggle.js",
|
||||||
"web/src/settings_ui.ts",
|
"web/src/settings_ui.ts",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import * as settings_data from "./settings_data.ts";
|
|||||||
import * as settings_invites from "./settings_invites.ts";
|
import * as settings_invites from "./settings_invites.ts";
|
||||||
import * as settings_org from "./settings_org.ts";
|
import * as settings_org from "./settings_org.ts";
|
||||||
import * as settings_panel_menu from "./settings_panel_menu.js";
|
import * as settings_panel_menu from "./settings_panel_menu.js";
|
||||||
import * as settings_sections from "./settings_sections.js";
|
import * as settings_sections from "./settings_sections.ts";
|
||||||
import * as settings_toggle from "./settings_toggle.js";
|
import * as settings_toggle from "./settings_toggle.js";
|
||||||
import * as settings_users from "./settings_users.ts";
|
import * as settings_users from "./settings_users.ts";
|
||||||
import {current_user, realm} from "./state_data.ts";
|
import {current_user, realm} from "./state_data.ts";
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import * as settings_config from "./settings_config.ts";
|
|||||||
import * as settings_data from "./settings_data.ts";
|
import * as settings_data from "./settings_data.ts";
|
||||||
import * as settings_panel_menu from "./settings_panel_menu.js";
|
import * as settings_panel_menu from "./settings_panel_menu.js";
|
||||||
import * as settings_preferences from "./settings_preferences.ts";
|
import * as settings_preferences from "./settings_preferences.ts";
|
||||||
import * as settings_sections from "./settings_sections.js";
|
import * as settings_sections from "./settings_sections.ts";
|
||||||
import * as settings_toggle from "./settings_toggle.js";
|
import * as settings_toggle from "./settings_toggle.js";
|
||||||
import {current_user, realm} from "./state_data.ts";
|
import {current_user, realm} from "./state_data.ts";
|
||||||
import * as timerender from "./timerender.ts";
|
import * as timerender from "./timerender.ts";
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {$t, $t_html} from "./i18n.ts";
|
|||||||
import * as keydown_util from "./keydown_util.ts";
|
import * as keydown_util from "./keydown_util.ts";
|
||||||
import * as popovers from "./popovers.ts";
|
import * as popovers from "./popovers.ts";
|
||||||
import * as scroll_util from "./scroll_util.ts";
|
import * as scroll_util from "./scroll_util.ts";
|
||||||
import * as settings_sections from "./settings_sections.js";
|
import * as settings_sections from "./settings_sections.ts";
|
||||||
import {redraw_active_users_list, redraw_deactivated_users_list} from "./settings_users.ts";
|
import {redraw_active_users_list, redraw_deactivated_users_list} from "./settings_users.ts";
|
||||||
|
|
||||||
export let normal_settings;
|
export let normal_settings;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import assert from "minimalistic-assert";
|
||||||
|
|
||||||
import * as alert_words_ui from "./alert_words_ui.ts";
|
import * as alert_words_ui from "./alert_words_ui.ts";
|
||||||
import * as attachments_ui from "./attachments_ui.ts";
|
import * as attachments_ui from "./attachments_ui.ts";
|
||||||
import * as blueslip from "./blueslip.ts";
|
import * as blueslip from "./blueslip.ts";
|
||||||
@@ -18,10 +20,10 @@ import * as settings_streams from "./settings_streams.ts";
|
|||||||
import * as settings_user_topics from "./settings_user_topics.ts";
|
import * as settings_user_topics from "./settings_user_topics.ts";
|
||||||
import * as settings_users from "./settings_users.ts";
|
import * as settings_users from "./settings_users.ts";
|
||||||
|
|
||||||
const load_func_dict = new Map(); // group -> function
|
const load_func_dict = new Map<string, () => void>(); // key is a group
|
||||||
const loaded_groups = new Set();
|
const loaded_groups = new Set();
|
||||||
|
|
||||||
export function get_group(section) {
|
export function get_group(section: string): string {
|
||||||
// Sometimes several sections all share the same code.
|
// Sometimes several sections all share the same code.
|
||||||
|
|
||||||
switch (section) {
|
switch (section) {
|
||||||
@@ -46,13 +48,14 @@ export function get_group(section) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initialize() {
|
export function initialize(): void {
|
||||||
// personal
|
// personal
|
||||||
load_func_dict.set("your-account", settings_account.set_up);
|
load_func_dict.set("your-account", settings_account.set_up);
|
||||||
load_func_dict.set("preferences", () => {
|
load_func_dict.set("preferences", () => {
|
||||||
settings_preferences.set_up(settings_preferences.user_settings_panel);
|
settings_preferences.set_up(settings_preferences.user_settings_panel);
|
||||||
});
|
});
|
||||||
load_func_dict.set("notifications", () => {
|
load_func_dict.set("notifications", () => {
|
||||||
|
assert(settings_notifications.user_settings_panel !== undefined);
|
||||||
settings_notifications.set_up(settings_notifications.user_settings_panel);
|
settings_notifications.set_up(settings_notifications.user_settings_panel);
|
||||||
});
|
});
|
||||||
load_func_dict.set("your-bots", settings_bots.set_up);
|
load_func_dict.set("your-bots", settings_bots.set_up);
|
||||||
@@ -77,7 +80,7 @@ export function initialize() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function load_settings_section(section) {
|
export function load_settings_section(section: string): void {
|
||||||
const group = get_group(section);
|
const group = get_group(section);
|
||||||
|
|
||||||
if (!load_func_dict.has(group)) {
|
if (!load_func_dict.has(group)) {
|
||||||
@@ -92,13 +95,14 @@ export function load_settings_section(section) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const load_func = load_func_dict.get(group);
|
const load_func = load_func_dict.get(group);
|
||||||
|
assert(load_func !== undefined);
|
||||||
|
|
||||||
// Do the real work here!
|
// Do the real work here!
|
||||||
load_func();
|
load_func();
|
||||||
loaded_groups.add(group);
|
loaded_groups.add(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function reset_sections() {
|
export function reset_sections(): void {
|
||||||
loaded_groups.clear();
|
loaded_groups.clear();
|
||||||
settings_emoji.reset();
|
settings_emoji.reset();
|
||||||
settings_exports.reset();
|
settings_exports.reset();
|
||||||
@@ -109,7 +109,7 @@ import * as settings_notifications from "./settings_notifications.ts";
|
|||||||
import * as settings_panel_menu from "./settings_panel_menu.js";
|
import * as settings_panel_menu from "./settings_panel_menu.js";
|
||||||
import * as settings_preferences from "./settings_preferences.ts";
|
import * as settings_preferences from "./settings_preferences.ts";
|
||||||
import * as settings_realm_user_settings_defaults from "./settings_realm_user_settings_defaults.ts";
|
import * as settings_realm_user_settings_defaults from "./settings_realm_user_settings_defaults.ts";
|
||||||
import * as settings_sections from "./settings_sections.js";
|
import * as settings_sections from "./settings_sections.ts";
|
||||||
import * as settings_toggle from "./settings_toggle.js";
|
import * as settings_toggle from "./settings_toggle.js";
|
||||||
import * as sidebar_ui from "./sidebar_ui.ts";
|
import * as sidebar_ui from "./sidebar_ui.ts";
|
||||||
import * as spoilers from "./spoilers.ts";
|
import * as spoilers from "./spoilers.ts";
|
||||||
|
|||||||
Reference in New Issue
Block a user