diff --git a/tools/test-js-with-node b/tools/test-js-with-node index b7ca09780d..41b640472e 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -211,7 +211,7 @@ EXEMPT_FILES = make_set( "web/src/settings_panel_menu.js", "web/src/settings_playgrounds.js", "web/src/settings_profile_fields.js", - "web/src/settings_realm_domains.js", + "web/src/settings_realm_domains.ts", "web/src/settings_realm_user_settings_defaults.js", "web/src/settings_sections.js", "web/src/settings_streams.js", diff --git a/web/src/page_params.ts b/web/src/page_params.ts index 82a1637ac8..87cdebd347 100644 --- a/web/src/page_params.ts +++ b/web/src/page_params.ts @@ -63,6 +63,7 @@ export const page_params: { realm_create_web_public_stream_policy: number; realm_delete_own_message_policy: number; realm_description: string; + realm_domains: {domain: string; allow_subdomains: boolean}[]; realm_edit_topic_policy: number; realm_email_changes_disabled: boolean; realm_enable_guest_user_indicator: boolean; diff --git a/web/src/settings_realm_domains.js b/web/src/settings_realm_domains.ts similarity index 92% rename from web/src/settings_realm_domains.js rename to web/src/settings_realm_domains.ts index c2e656fa53..70936bae7b 100644 --- a/web/src/settings_realm_domains.js +++ b/web/src/settings_realm_domains.ts @@ -9,7 +9,12 @@ import {$t_html} from "./i18n"; import {page_params} from "./page_params"; import * as ui_report from "./ui_report"; -export function populate_realm_domains_table(realm_domains) { +type RealmDomain = { + domain: string; + allow_subdomains: boolean; +}; + +export function populate_realm_domains_table(realm_domains: RealmDomain[]): void { // Don't populate the table if the realm domains modal isn't open. if ($("#realm_domains_modal").length === 0) { return; @@ -27,19 +32,19 @@ export function populate_realm_domains_table(realm_domains) { } } -function fade_status_element($elem) { +function fade_status_element($elem: JQuery): void { setTimeout(() => { $elem.fadeOut(500); }, 3000); } -export function setup_realm_domains_modal_handlers() { +export function setup_realm_domains_modal_handlers(): void { $("#realm_domains_table").on("click", ".delete_realm_domain", function () { const domain = $(this).parents("tr").find(".domain").text(); const url = "/json/realm/domains/" + domain; const $realm_domains_info = $(".realm_domains_info"); - channel.del({ + void channel.del({ url, success() { ui_report.success( @@ -65,7 +70,7 @@ export function setup_realm_domains_modal_handlers() { allow_subdomains: JSON.stringify(allow_subdomains), }; - channel.patch({ + void channel.patch({ url, data, success() { @@ -111,7 +116,7 @@ export function setup_realm_domains_modal_handlers() { allow_subdomains: JSON.stringify(allow_subdomains), }; - channel.post({ + void channel.post({ url: "/json/realm/domains", data, success() { @@ -134,7 +139,7 @@ export function setup_realm_domains_modal_handlers() { }); } -export function show_realm_domains_modal() { +export function show_realm_domains_modal(): void { const realm_domains_table_body = render_realm_domains_modal(); dialog_widget.launch({