Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
settings_realm_domains: Fix implicit use of any.
Anders Kaseorg939b88b9a7d9
diff --git a/web/src/settings_realm_domains.ts b/web/src/settings_realm_domains.tsindex a606e5668eb..2604cdf0247 100644--- a/web/src/settings_realm_domains.ts+++ b/web/src/settings_realm_domains.ts@@ -58,57 +58,63 @@ export function setup_realm_domains_modal_handlers(): void {});});- $("#realm_domains_table").on("change", ".allow-subdomains", function (e) {- e.stopPropagation();- const $realm_domains_info = $(".realm_domains_info");- const domain = $(this).parents("tr").find(".domain").text();- const allow_subdomains = $(this).prop("checked");- const url = "/json/realm/domains/" + domain;- const data = {- allow_subdomains: JSON.stringify(allow_subdomains),- };+ $("#realm_domains_table").on(+ "change",+ "input.allow-subdomains",+ function (this: HTMLInputElement, e) {+ e.stopPropagation();+ const $realm_domains_info = $(".realm_domains_info");+ const domain = $(this).parents("tr").find(".domain").text();+ const allow_subdomains = this.checked;+ const url = "/json/realm/domains/" + domain;+ const data = {+ allow_subdomains: JSON.stringify(allow_subdomains),+ };- void channel.patch({- url,- data,- success() {- if (allow_subdomains) {- ui_report.success(- $t_html(- {- defaultMessage:- "Update successful: Subdomains allowed for {domain}",- },- {domain},- ),- $realm_domains_info,- );- } else {- ui_report.success(- $t_html(- {- defaultMessage:- "Update successful: Subdomains no longer allowed for {domain}",- },- {domain},- ),- $realm_domains_info,- );- }- fade_status_element($realm_domains_info);- },- error(xhr) {- ui_report.error($t_html({defaultMessage: "Failed"}), xhr, $realm_domains_info);- fade_status_element($realm_domains_info);- },- });- });+ void channel.patch({+ url,+ data,+ success() {+ if (allow_subdomains) {+ ui_report.success(+ $t_html(+ {+ defaultMessage:+ "Update successful: Subdomains allowed for {domain}",+ },+ {domain},+ ),+ $realm_domains_info,+ );+ } else {+ ui_report.success(+ $t_html(+ {+ defaultMessage:+ "Update successful: Subdomains no longer allowed for {domain}",+ },+ {domain},+ ),+ $realm_domains_info,+ );+ }+ fade_status_element($realm_domains_info);+ },+ error(xhr) {+ ui_report.error($t_html({defaultMessage: "Failed"}), xhr, $realm_domains_info);+ fade_status_element($realm_domains_info);+ },+ });+ },+ );$("#submit-add-realm-domain").on("click", () => {const $realm_domains_info = $(".realm_domains_info");const $widget = $("#add-realm-domain-widget");const domain = $widget.find(".new-realm-domain").val();- const allow_subdomains = $widget.find(".new-realm-domain-allow-subdomains").prop("checked");+ const allow_subdomains = $widget.find<HTMLInputElement>(+ "input.new-realm-domain-allow-subdomains",+ )[0].checked;const data = {domain,allow_subdomains: JSON.stringify(allow_subdomains),diff --git a/web/tests/settings_realm_domains.test.js b/web/tests/settings_realm_domains.test.jsindex 1ddee1d3003..5b88b4d1f73 100644--- a/web/tests/settings_realm_domains.test.js+++ b/web/tests/settings_realm_domains.test.js@@ -28,9 +28,10 @@ function test_realms_domain_modal(override, add_realm_domain) {);$("#add-realm-domain-widget").set_find_results(- ".new-realm-domain-allow-subdomains",- $.create("new-realm-domain-allow-subdomains-stub"),+ "input.new-realm-domain-allow-subdomains",+ $("<new-realm-domain-allow-subdomains-stub>"),);+ $("<new-realm-domain-allow-subdomains-stub>")[0] = {};let posted;let success_callback;@@ -76,13 +77,14 @@ function test_change_allow_subdomains(change_allow_subdomains) {$domain_obj.text(domain);const $elem_obj = $.create("<elem html>");+ const elem_obj = {to_$: () => $elem_obj};const $parents_obj = $.create("parents object");$elem_obj.set_parents_result("tr", $parents_obj);$parents_obj.set_find_results(".domain", $domain_obj);- $elem_obj.prop("checked", allow);+ elem_obj.checked = allow;- change_allow_subdomains.call($elem_obj, ev);+ change_allow_subdomains.call(elem_obj, ev);success_callback();assert.equal(@@ -94,8 +96,8 @@ function test_change_allow_subdomains(change_allow_subdomains) {assert.equal($info.val(), "translated HTML: Failed");allow = false;- $elem_obj.prop("checked", allow);- change_allow_subdomains.call($elem_obj, ev);+ elem_obj.checked = allow;+ change_allow_subdomains.call(elem_obj, ev);success_callback();assert.equal($info.val(),@@ -107,6 +109,6 @@ run_test("test_realm_domains_table", ({override}) => {settings_realm_domains.setup_realm_domains_modal_handlers();test_realms_domain_modal(override, () => $("#submit-add-realm-domain").trigger("click"));test_change_allow_subdomains(- $("#realm_domains_table").get_on_handler("change", ".allow-subdomains"),+ $("#realm_domains_table").get_on_handler("change", "input.allow-subdomains"),);});