mirror of https://github.com/zulip/zulip.git
alert_words_ui: Convert module to TypeScript.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
681180ee86
commit
819a91aec7
|
@ -49,7 +49,7 @@ EXEMPT_FILES = make_set(
|
||||||
"web/src/add_subscribers_pill.js",
|
"web/src/add_subscribers_pill.js",
|
||||||
"web/src/admin.js",
|
"web/src/admin.js",
|
||||||
"web/src/alert_popup.ts",
|
"web/src/alert_popup.ts",
|
||||||
"web/src/alert_words_ui.js",
|
"web/src/alert_words_ui.ts",
|
||||||
"web/src/archive.js",
|
"web/src/archive.js",
|
||||||
"web/src/assets.d.ts",
|
"web/src/assets.d.ts",
|
||||||
"web/src/attachments_ui.ts",
|
"web/src/attachments_ui.ts",
|
||||||
|
|
|
@ -12,7 +12,7 @@ import * as ui_report from "./ui_report";
|
||||||
|
|
||||||
export let loaded = false;
|
export let loaded = false;
|
||||||
|
|
||||||
export function rerender_alert_words_ui() {
|
export function rerender_alert_words_ui(): void {
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ export function rerender_alert_words_ui() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_alert_word_status(status_text, is_error) {
|
function update_alert_word_status(status_text: string, is_error: boolean): void {
|
||||||
const $alert_word_status = $("#alert_word_status");
|
const $alert_word_status = $("#alert_word_status");
|
||||||
if (is_error) {
|
if (is_error) {
|
||||||
$alert_word_status.removeClass("alert-success").addClass("alert-danger");
|
$alert_word_status.removeClass("alert-success").addClass("alert-danger");
|
||||||
|
@ -46,8 +46,8 @@ function update_alert_word_status(status_text, is_error) {
|
||||||
$alert_word_status.show();
|
$alert_word_status.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_alert_word() {
|
function add_alert_word(): void {
|
||||||
const alert_word = $("#add-alert-word-name").val().trim();
|
const alert_word = $<HTMLInputElement>("input#add-alert-word-name").val()!.trim();
|
||||||
|
|
||||||
if (alert_words.has_alert_word(alert_word)) {
|
if (alert_words.has_alert_word(alert_word)) {
|
||||||
ui_report.client_error(
|
ui_report.client_error(
|
||||||
|
@ -64,9 +64,9 @@ function add_alert_word() {
|
||||||
dialog_widget.submit_api_request(channel.post, "/json/users/me/alert_words", data);
|
dialog_widget.submit_api_request(channel.post, "/json/users/me/alert_words", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_alert_word(alert_word) {
|
function remove_alert_word(alert_word: string): void {
|
||||||
const words_to_be_removed = [alert_word];
|
const words_to_be_removed = [alert_word];
|
||||||
channel.del({
|
void channel.del({
|
||||||
url: "/json/users/me/alert_words",
|
url: "/json/users/me/alert_words",
|
||||||
data: {alert_words: JSON.stringify(words_to_be_removed)},
|
data: {alert_words: JSON.stringify(words_to_be_removed)},
|
||||||
success() {
|
success() {
|
||||||
|
@ -84,18 +84,18 @@ function remove_alert_word(alert_word) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function show_add_alert_word_modal() {
|
export function show_add_alert_word_modal(): void {
|
||||||
const html_body = render_add_alert_word();
|
const html_body = render_add_alert_word();
|
||||||
|
|
||||||
function add_alert_word_post_render() {
|
function add_alert_word_post_render(): void {
|
||||||
const $add_user_group_input_element = $("#add-alert-word-name");
|
const $add_user_group_input_element = $<HTMLInputElement>("input#add-alert-word-name");
|
||||||
const $add_user_group_submit_button = $("#add-alert-word .dialog_submit_button");
|
const $add_user_group_submit_button = $("#add-alert-word .dialog_submit_button");
|
||||||
$add_user_group_submit_button.prop("disabled", true);
|
$add_user_group_submit_button.prop("disabled", true);
|
||||||
|
|
||||||
$add_user_group_input_element.on("input", () => {
|
$add_user_group_input_element.on("input", () => {
|
||||||
$add_user_group_submit_button.prop(
|
$add_user_group_submit_button.prop(
|
||||||
"disabled",
|
"disabled",
|
||||||
$add_user_group_input_element.val().trim() === "",
|
$add_user_group_input_element.val()!.trim() === "",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ export function show_add_alert_word_modal() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function set_up_alert_words() {
|
export function set_up_alert_words(): void {
|
||||||
// The settings page must be rendered before this function gets called.
|
// The settings page must be rendered before this function gets called.
|
||||||
loaded = true;
|
loaded = true;
|
||||||
rerender_alert_words_ui();
|
rerender_alert_words_ui();
|
||||||
|
@ -135,6 +135,6 @@ export function set_up_alert_words() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function reset() {
|
export function reset(): void {
|
||||||
loaded = false;
|
loaded = false;
|
||||||
}
|
}
|
Loading…
Reference in New Issue