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: Convert module to typescript.

evykassirer4ff7bc16bca5
diff --git a/tools/test-js-with-node b/tools/test-js-with-node
index a31cce63b1d..57436e460e0 100755
--- a/tools/test-js-with-node
+++ b/tools/test-js-with-node
@@ -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",
diff --git a/web/src/admin.js b/web/src/admin.js
index c79935cfa5a..9546ae5f766 100644
--- a/web/src/admin.js
+++ b/web/src/admin.js
@@ -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";
diff --git a/web/src/dialog_widget.ts b/web/src/dialog_widget.ts
index a751c5f3816..9fd439d41d4 100644
--- a/web/src/dialog_widget.ts
+++ b/web/src/dialog_widget.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
diff --git a/web/src/hashchange.js b/web/src/hashchange.js
index 4a446a68823..2a2b35080a8 100644
--- a/web/src/hashchange.js
+++ b/web/src/hashchange.js
@@ -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";
diff --git a/web/src/settings.js b/web/src/settings.ts
similarity index 95%
rename from web/src/settings.js
rename to web/src/settings.ts
index c2fbbb6d1a0..359e542515b 100644
--- a/web/src/settings.js
+++ b/web/src/settings.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,
diff --git a/web/src/settings_account.ts b/web/src/settings_account.ts
index 81938103665..38cadfe0a09 100644
--- a/web/src/settings_account.ts
+++ b/web/src/settings_account.ts
@@ -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();
diff --git a/web/src/settings_invites.ts b/web/src/settings_invites.ts
index b0f6520e4e0..74f7116b64e 100644
--- a/web/src/settings_invites.ts
+++ b/web/src/settings_invites.ts
@@ -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();
diff --git a/web/src/settings_users.ts b/web/src/settings_users.ts
index 665035afb48..42ca99eec7f 100644
--- a/web/src/settings_users.ts
+++ b/web/src/settings_users.ts
@@ -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();
diff --git a/web/src/ui_init.js b/web/src/ui_init.js
index 4f3cf77dedb..eb70bd83644 100644
--- a/web/src/ui_init.js
+++ b/web/src/ui_init.js
@@ -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";
diff --git a/web/src/user_events.js b/web/src/user_events.js
index fd664154ee4..360c3be5771 100644
--- a/web/src/user_events.js
+++ b/web/src/user_events.js
@@ -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";