settings_realm_domains: Fix implicit use of any.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-05-03 14:14:21 -07:00 committed by Tim Abbott
parent 4032f9c0cb
commit 939b88b9a7
2 changed files with 60 additions and 52 deletions

View File

@ -58,11 +58,14 @@ export function setup_realm_domains_modal_handlers(): void {
});
});
$("#realm_domains_table").on("change", ".allow-subdomains", function (e) {
$("#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).prop("checked");
const allow_subdomains = this.checked;
const url = "/json/realm/domains/" + domain;
const data = {
allow_subdomains: JSON.stringify(allow_subdomains),
@ -102,13 +105,16 @@ export function setup_realm_domains_modal_handlers(): void {
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),

View File

@ -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"),
);
});