Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

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

Anders Kaseorg934d4e4e1033
diff --git a/.eslintrc.json b/.eslintrc.json
index b5c3d86eeae..70daf8d1f66 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -145,7 +145,6 @@
"message_list": false,
"narrow": false,
"page_params": false,
- "panels": false,
"pointer": false,
"realm_night_logo": false,
"recent_topics": false,
diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js
index 4914e65dda5..def62700c56 100644
--- a/frontend_tests/node_tests/dispatch.js
+++ b/frontend_tests/node_tests/dispatch.js
@@ -121,7 +121,6 @@ const user_status = zrequire("user_status");
const emoji = zrequire("emoji", "shared/js/emoji");
const server_events_dispatch = zrequire("server_events_dispatch");
-zrequire("panels");
function dispatch(ev) {
server_events_dispatch.dispatch_normal_event(ev);
diff --git a/frontend_tests/node_tests/ui_init.js b/frontend_tests/node_tests/ui_init.js
index fa5ee00aaeb..bee82cd6612 100644
--- a/frontend_tests/node_tests/ui_init.js
+++ b/frontend_tests/node_tests/ui_init.js
@@ -83,7 +83,7 @@ const message_viewport = {
initialize() {},
};
rewiremock("../../static/js/message_viewport").with(message_viewport);
-set_global("panels", {initialize() {}});
+rewiremock("../../static/js/panels").with({initialize() {}});
rewiremock("../../static/js/popovers").with({initialize() {}});
rewiremock("../../static/js/reload").with({initialize() {}});
rewiremock("../../static/js/scroll_bar").with({initialize() {}});
diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js
index 2d52d77aa6f..ad6822f1219 100644
--- a/static/js/bundles/app.js
+++ b/static/js/bundles/app.js
@@ -38,7 +38,6 @@ import "../dropdown_list_widget";
import "../settings_profile_fields";
import "../settings";
import "../ui_init";
-import "../panels";
import "../recent_topics";
import "../search_pill_widget";
import "../desktop_integration";
diff --git a/static/js/global.d.ts b/static/js/global.d.ts
index 6e9189a484e..ff689ad95df 100644
--- a/static/js/global.d.ts
+++ b/static/js/global.d.ts
@@ -18,7 +18,6 @@ declare let message_events: any;
declare let message_list: any;
declare let narrow: any;
declare let page_params: any;
-declare let panels: any;
declare let pointer: any;
declare let recent_topics: any;
declare let search_pill_widget: any;
diff --git a/static/js/panels.js b/static/js/panels.js
index 39069885bea..c7383fd29cf 100644
--- a/static/js/panels.js
+++ b/static/js/panels.js
@@ -1,11 +1,9 @@
-"use strict";
+import {localstorage} from "./localstorage";
+import * as notifications from "./notifications";
+import * as unread_ui from "./unread_ui";
+import * as util from "./util";
-const {localstorage} = require("./localstorage");
-const notifications = require("./notifications");
-const unread_ui = require("./unread_ui");
-const util = require("./util");
-
-const resize_app = function () {
+export function resize_app() {
const panels_height = $("#panels").height();
$("body > .app").height("calc(100% - " + panels_height + "px)");
@@ -16,9 +14,7 @@ const resize_app = function () {
$(".header").height() +
Number.parseInt($(".header").css("paddingBottom"), 10);
$("#floating_recipient_bar").css("top", frb_top + "px");
-};
-
-exports.resize_app = resize_app;
+}
const show_step = function ($process, step) {
$process
@@ -51,7 +47,7 @@ function should_show_notifications(ls) {
);
}
-exports.check_profile_incomplete = function () {
+export function check_profile_incomplete() {
if (!page_params.is_admin) {
return;
}
@@ -67,24 +63,24 @@ exports.check_profile_incomplete = function () {
} else {
$("[data-process='profile-incomplete']").hide();
}
-};
+}
-exports.initialize = function () {
+export function initialize() {
const ls = localstorage();
if (page_params.insecure_desktop_app) {
- exports.open($("[data-process='insecure-desktop-app']"));
+ open($("[data-process='insecure-desktop-app']"));
} else if (page_params.warn_no_email === true && page_params.is_admin) {
// if email has not been set up and the user is the admin,
// display a warning to tell them to set up an email server.
- exports.open($("[data-process='email-server']"));
+ open($("[data-process='email-server']"));
} else if (should_show_notifications(ls)) {
- exports.open($("[data-process='notifications']"));
+ open($("[data-process='notifications']"));
} else if (unread_ui.should_display_bankruptcy_banner()) {
- exports.open($("[data-process='bankruptcy']"));
+ open($("[data-process='bankruptcy']"));
} else {
// TODO: This should be restructured with separate check and
// show calls.
- exports.check_profile_incomplete();
+ check_profile_incomplete();
}
// Configure click handlers.
@@ -127,12 +123,10 @@ exports.initialize = function () {
$(this).click();
}
});
-};
+}
-exports.open = function ($process) {
+export function open($process) {
$("[data-process]").hide();
$process.show();
resize_app();
-};
-
-window.panels = exports;
+}
diff --git a/static/js/recent_topics.js b/static/js/recent_topics.js
index b2c5b69ed70..0a027258ad2 100644
--- a/static/js/recent_topics.js
+++ b/static/js/recent_topics.js
@@ -15,6 +15,7 @@ const muting = require("./muting");
const narrow_state = require("./narrow_state");
const navigate = require("./navigate");
const notifications = require("./notifications");
+const panels = require("./panels");
const people = require("./people");
const recent_senders = require("./recent_senders");
const stream_data = require("./stream_data");
diff --git a/static/js/resize.js b/static/js/resize.js
index 45502a01ef5..0b9cfa0cf11 100644
--- a/static/js/resize.js
+++ b/static/js/resize.js
@@ -3,6 +3,7 @@ import autosize from "autosize";
import * as condense from "./condense";
import * as message_viewport from "./message_viewport";
import * as navigate from "./navigate";
+import * as panels from "./panels";
import * as popovers from "./popovers";
import * as util from "./util";
diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js
index dfa19bae418..33bbae3cb0b 100644
--- a/static/js/server_events_dispatch.js
+++ b/static/js/server_events_dispatch.js
@@ -17,6 +17,7 @@ import * as narrow_state from "./narrow_state";
import * as night_mode from "./night_mode";
import * as notifications from "./notifications";
import * as overlays from "./overlays";
+import * as panels from "./panels";
import * as peer_data from "./peer_data";
import * as people from "./people";
import * as reactions from "./reactions";
diff --git a/static/js/ui_init.js b/static/js/ui_init.js
index 7805d153c90..24ce3154558 100644
--- a/static/js/ui_init.js
+++ b/static/js/ui_init.js
@@ -34,6 +34,7 @@ import * as muting from "./muting";
import * as navigate from "./navigate";
import * as notifications from "./notifications";
import * as overlays from "./overlays";
+import * as panels from "./panels";
import * as people from "./people";
import * as pm_conversations from "./pm_conversations";
import * as pm_list from "./pm_list";