settings_realm_domains: Convert module to TypeScript.

This commit is contained in:
Varun Singh 2024-01-06 00:20:08 +05:30 committed by GitHub
parent 979ace1cea
commit 4b04716237
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 8 deletions

View File

@ -211,7 +211,7 @@ EXEMPT_FILES = make_set(
"web/src/settings_panel_menu.js", "web/src/settings_panel_menu.js",
"web/src/settings_playgrounds.js", "web/src/settings_playgrounds.js",
"web/src/settings_profile_fields.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_realm_user_settings_defaults.js",
"web/src/settings_sections.js", "web/src/settings_sections.js",
"web/src/settings_streams.js", "web/src/settings_streams.js",

View File

@ -63,6 +63,7 @@ export const page_params: {
realm_create_web_public_stream_policy: number; realm_create_web_public_stream_policy: number;
realm_delete_own_message_policy: number; realm_delete_own_message_policy: number;
realm_description: string; realm_description: string;
realm_domains: {domain: string; allow_subdomains: boolean}[];
realm_edit_topic_policy: number; realm_edit_topic_policy: number;
realm_email_changes_disabled: boolean; realm_email_changes_disabled: boolean;
realm_enable_guest_user_indicator: boolean; realm_enable_guest_user_indicator: boolean;

View File

@ -9,7 +9,12 @@ import {$t_html} from "./i18n";
import {page_params} from "./page_params"; import {page_params} from "./page_params";
import * as ui_report from "./ui_report"; 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. // Don't populate the table if the realm domains modal isn't open.
if ($("#realm_domains_modal").length === 0) { if ($("#realm_domains_modal").length === 0) {
return; 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(() => { setTimeout(() => {
$elem.fadeOut(500); $elem.fadeOut(500);
}, 3000); }, 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 () { $("#realm_domains_table").on("click", ".delete_realm_domain", function () {
const domain = $(this).parents("tr").find(".domain").text(); const domain = $(this).parents("tr").find(".domain").text();
const url = "/json/realm/domains/" + domain; const url = "/json/realm/domains/" + domain;
const $realm_domains_info = $(".realm_domains_info"); const $realm_domains_info = $(".realm_domains_info");
channel.del({ void channel.del({
url, url,
success() { success() {
ui_report.success( ui_report.success(
@ -65,7 +70,7 @@ export function setup_realm_domains_modal_handlers() {
allow_subdomains: JSON.stringify(allow_subdomains), allow_subdomains: JSON.stringify(allow_subdomains),
}; };
channel.patch({ void channel.patch({
url, url,
data, data,
success() { success() {
@ -111,7 +116,7 @@ export function setup_realm_domains_modal_handlers() {
allow_subdomains: JSON.stringify(allow_subdomains), allow_subdomains: JSON.stringify(allow_subdomains),
}; };
channel.post({ void channel.post({
url: "/json/realm/domains", url: "/json/realm/domains",
data, data,
success() { 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(); const realm_domains_table_body = render_realm_domains_modal();
dialog_widget.launch({ dialog_widget.launch({