mirror of https://github.com/zulip/zulip.git
ts: Migrate `realm_logo` to TypeScript.
This commit is contained in:
parent
b8e0850aa1
commit
c47a18eb2b
|
@ -142,7 +142,7 @@ EXEMPT_FILES = make_set(
|
||||||
"web/src/read_receipts.js",
|
"web/src/read_receipts.js",
|
||||||
"web/src/ready.ts",
|
"web/src/ready.ts",
|
||||||
"web/src/realm_icon.ts",
|
"web/src/realm_icon.ts",
|
||||||
"web/src/realm_logo.js",
|
"web/src/realm_logo.ts",
|
||||||
"web/src/realm_playground.ts",
|
"web/src/realm_playground.ts",
|
||||||
"web/src/realm_user_settings_defaults.ts",
|
"web/src/realm_user_settings_defaults.ts",
|
||||||
"web/src/recent_view_ui.js",
|
"web/src/recent_view_ui.js",
|
||||||
|
|
|
@ -22,6 +22,7 @@ export const page_params: {
|
||||||
is_spectator: boolean;
|
is_spectator: boolean;
|
||||||
max_avatar_file_size_mib: number;
|
max_avatar_file_size_mib: number;
|
||||||
max_icon_file_size_mib: number;
|
max_icon_file_size_mib: number;
|
||||||
|
max_logo_file_size_mib: number;
|
||||||
muted_users: {id: number; timestamp: number}[];
|
muted_users: {id: number; timestamp: number}[];
|
||||||
needs_tutorial: boolean;
|
needs_tutorial: boolean;
|
||||||
page_load_time: number;
|
page_load_time: number;
|
||||||
|
@ -41,6 +42,10 @@ export const page_params: {
|
||||||
realm_invite_to_realm_policy: number;
|
realm_invite_to_realm_policy: number;
|
||||||
realm_invite_to_stream_policy: number;
|
realm_invite_to_stream_policy: number;
|
||||||
realm_is_zephyr_mirror_realm: boolean;
|
realm_is_zephyr_mirror_realm: boolean;
|
||||||
|
realm_logo_source: string;
|
||||||
|
realm_logo_url: string;
|
||||||
|
realm_night_logo_source: string;
|
||||||
|
realm_night_logo_url: string;
|
||||||
realm_move_messages_between_streams_policy: number;
|
realm_move_messages_between_streams_policy: number;
|
||||||
realm_name_changes_disabled: boolean;
|
realm_name_changes_disabled: boolean;
|
||||||
realm_name: string;
|
realm_name: string;
|
||||||
|
|
|
@ -5,8 +5,9 @@ import {page_params} from "./page_params";
|
||||||
import * as settings_data from "./settings_data";
|
import * as settings_data from "./settings_data";
|
||||||
import * as ui_util from "./ui_util";
|
import * as ui_util from "./ui_util";
|
||||||
import * as upload_widget from "./upload_widget";
|
import * as upload_widget from "./upload_widget";
|
||||||
|
import type {UploadFunction} from "./upload_widget";
|
||||||
|
|
||||||
export function build_realm_logo_widget(upload_function, is_night) {
|
export function build_realm_logo_widget(upload_function: UploadFunction, is_night: boolean): void {
|
||||||
let logo_section_id = "#realm-day-logo-upload-widget";
|
let logo_section_id = "#realm-day-logo-upload-widget";
|
||||||
let logo_source = page_params.realm_logo_source;
|
let logo_source = page_params.realm_logo_source;
|
||||||
|
|
||||||
|
@ -16,11 +17,11 @@ export function build_realm_logo_widget(upload_function, is_night) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const $delete_button_elem = $(logo_section_id + " .image-delete-button");
|
const $delete_button_elem = $(logo_section_id + " .image-delete-button");
|
||||||
const $file_input_elem = $(logo_section_id + " .image_file_input");
|
const $file_input_elem = $<HTMLInputElement>(logo_section_id + " .image_file_input");
|
||||||
const $file_input_error_elem = $(logo_section_id + " .image_file_input_error");
|
const $file_input_error_elem = $(logo_section_id + " .image_file_input_error");
|
||||||
const $upload_button_elem = $(logo_section_id + " .image_upload_button");
|
const $upload_button_elem = $(logo_section_id + " .image_upload_button");
|
||||||
|
|
||||||
const get_file_input = function () {
|
const get_file_input = function (): JQuery<HTMLInputElement> {
|
||||||
return $file_input_elem.expectOne();
|
return $file_input_elem.expectOne();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ export function build_realm_logo_widget(upload_function, is_night) {
|
||||||
$delete_button_elem.on("click", (e) => {
|
$delete_button_elem.on("click", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
channel.del({
|
void channel.del({
|
||||||
url: "/json/realm/logo",
|
url: "/json/realm/logo",
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
|
@ -53,7 +54,11 @@ export function build_realm_logo_widget(upload_function, is_night) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_logo_delete_button(logo_source, $logo_delete_button, $file_input) {
|
function change_logo_delete_button(
|
||||||
|
logo_source: string,
|
||||||
|
$logo_delete_button: JQuery,
|
||||||
|
$file_input: JQuery<HTMLInputElement>,
|
||||||
|
): void {
|
||||||
if (logo_source === "U") {
|
if (logo_source === "U") {
|
||||||
$logo_delete_button.show();
|
$logo_delete_button.show();
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,9 +69,11 @@ function change_logo_delete_button(logo_source, $logo_delete_button, $file_input
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function render() {
|
export function render(): void {
|
||||||
const $file_input = $("#realm-day-logo-upload-widget .image_file_input");
|
const $file_input = $<HTMLInputElement>("#realm-day-logo-upload-widget .image_file_input");
|
||||||
const $night_file_input = $("#realm-night-logo-upload-widget .realm-logo-file-input");
|
const $night_file_input = $<HTMLInputElement>(
|
||||||
|
"#realm-night-logo-upload-widget .realm-logo-file-input",
|
||||||
|
);
|
||||||
$("#realm-day-logo-upload-widget .image-block").attr("src", page_params.realm_logo_url);
|
$("#realm-day-logo-upload-widget .image-block").attr("src", page_params.realm_logo_url);
|
||||||
|
|
||||||
if (page_params.realm_night_logo_source === "D" && page_params.realm_logo_source !== "D") {
|
if (page_params.realm_night_logo_source === "D" && page_params.realm_logo_source !== "D") {
|
||||||
|
@ -101,7 +108,7 @@ export function render() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initialize() {
|
export function initialize(): void {
|
||||||
// render once
|
// render once
|
||||||
render();
|
render();
|
||||||
|
|
Loading…
Reference in New Issue