js: Convert static/js/realm_icon.js to ES6 module.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-27 16:16:09 -08:00 committed by Tim Abbott
parent b2849edfd7
commit f577489aa4
8 changed files with 12 additions and 15 deletions

View File

@ -153,7 +153,6 @@
"panels": false,
"pointer": false,
"reactions": false,
"realm_icon": false,
"realm_logo": false,
"realm_night_logo": false,
"recent_topics": false,

View File

@ -47,7 +47,8 @@ rewiremock("../../static/js/night_mode").with(night_mode);
const notifications = {__esModule: true};
rewiremock("../../static/js/notifications").with(notifications);
const reactions = set_global("reactions", {});
const realm_icon = set_global("realm_icon", {});
const realm_icon = {__esModule: true};
rewiremock("../../static/js/realm_icon").with(realm_icon);
const realm_logo = set_global("realm_logo", {});
const reload = {__esModule: true};
rewiremock("../../static/js/reload").with(reload);

View File

@ -40,7 +40,8 @@ const page_params = set_global("page_params", {
realm_authentication_methods: {},
});
const realm_icon = set_global("realm_icon", {});
const realm_icon = {__esModule: true};
rewiremock("../../static/js/realm_icon").with(realm_icon);
const channel = {__esModule: true};
rewiremock("../../static/js/channel").with(channel);

View File

@ -34,7 +34,6 @@ import "../message_events";
import "../server_events";
import "../zulip";
import "../templates";
import "../realm_icon";
import "../realm_logo";
import "../reminder";
import "../confirm_dialog";

View File

@ -26,7 +26,6 @@ declare let page_params: any;
declare let panels: any;
declare let pointer: any;
declare let reactions: any;
declare let realm_icon: any;
declare let realm_logo: any;
declare let recent_topics: any;
declare let reminder: any;

View File

@ -1,9 +1,7 @@
"use strict";
import * as channel from "./channel";
import * as upload_widget from "./upload_widget";
const channel = require("./channel");
const upload_widget = require("./upload_widget");
exports.build_realm_icon_widget = function (upload_function) {
export function build_realm_icon_widget(upload_function) {
const get_file_input = function () {
return $("#realm-icon-upload-widget .image_file_input").expectOne();
};
@ -31,9 +29,9 @@ exports.build_realm_icon_widget = function (upload_function) {
upload_function,
page_params.max_icon_file_size,
);
};
}
exports.rerender = function () {
export function rerender() {
$("#realm-icon-upload-widget .image-block").attr("src", page_params.realm_icon_url);
if (page_params.realm_icon_source === "U") {
$("#realm-icon-upload-widget .image-delete-button").show();
@ -44,6 +42,4 @@ exports.rerender = function () {
const file_input = $("#realm-icon-upload-widget .image_file_input");
file_input.val("");
}
};
window.realm_icon = exports;
}

View File

@ -17,6 +17,7 @@ import * as notifications from "./notifications";
import * as overlays from "./overlays";
import * as peer_data from "./peer_data";
import * as people from "./people";
import * as realm_icon from "./realm_icon";
import * as reload from "./reload";
import * as scroll_bar from "./scroll_bar";
import * as settings_config from "./settings_config";

View File

@ -7,6 +7,7 @@ const render_settings_admin_realm_domains_list = require("../templates/settings/
const channel = require("./channel");
const loading = require("./loading");
const overlays = require("./overlays");
const realm_icon = require("./realm_icon");
const settings_config = require("./settings_config");
const settings_ui = require("./settings_ui");
const stream_data = require("./stream_data");