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/settings_display.js to ES6 module.

Anders Kaseorg4d738ebe15fe
diff --git a/.eslintrc.json b/.eslintrc.json
index 95fdcc2dcf7..b12973f017f 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -157,7 +157,6 @@
"search_pill_widget": false,
"settings": false,
"settings_bots": false,
- "settings_display": false,
"settings_emoji": false,
"settings_exports": false,
"settings_linkifiers": false,
diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js
index 061226856f1..0b0d36dd300 100644
--- a/frontend_tests/node_tests/dispatch.js
+++ b/frontend_tests/node_tests/dispatch.js
@@ -58,7 +58,8 @@ rewiremock("../../static/js/scroll_bar").with(scroll_bar);
const settings_account = {__esModule: true};
rewiremock("../../static/js/settings_account").with(settings_account);
const settings_bots = set_global("settings_bots", {});
-const settings_display = set_global("settings_display", {});
+const settings_display = {__esModule: true};
+rewiremock("../../static/js/settings_display").with(settings_display);
const settings_emoji = set_global("settings_emoji", {});
const settings_exports = set_global("settings_exports", {});
const settings_invites = set_global("settings_invites", {});
diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js
index b6311325afd..35a1f715a38 100644
--- a/static/js/bundles/app.js
+++ b/static/js/bundles/app.js
@@ -35,7 +35,6 @@ import "../server_events";
import "../zulip";
import "../templates";
import "../dropdown_list_widget";
-import "../settings_display";
import "../settings_notifications";
import "../settings_bots";
import "../settings_sections";
diff --git a/static/js/global.d.ts b/static/js/global.d.ts
index 696e2035277..513abf3e6ca 100644
--- a/static/js/global.d.ts
+++ b/static/js/global.d.ts
@@ -29,7 +29,6 @@ declare let recent_topics: any;
declare let search_pill_widget: any;
declare let settings: any;
declare let settings_bots: any;
-declare let settings_display: any;
declare let settings_emoji: any;
declare let settings_exports: any;
declare let settings_invites: any;
diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js
index 2f98ab902f7..d2eb60b9975 100644
--- a/static/js/server_events_dispatch.js
+++ b/static/js/server_events_dispatch.js
@@ -23,6 +23,7 @@ import * as reload from "./reload";
import * as scroll_bar from "./scroll_bar";
import * as settings_account from "./settings_account";
import * as settings_config from "./settings_config";
+import * as settings_display from "./settings_display";
import * as starred_messages from "./starred_messages";
import * as stream_data from "./stream_data";
import * as stream_events from "./stream_events";
diff --git a/static/js/settings_display.js b/static/js/settings_display.js
index a93be8e610c..6c8ef5bffbc 100644
--- a/static/js/settings_display.js
+++ b/static/js/settings_display.js
@@ -1,12 +1,10 @@
-"use strict";
-
-const channel = require("./channel");
-const emojisets = require("./emojisets");
-const loading = require("./loading");
-const overlays = require("./overlays");
-const settings_config = require("./settings_config");
-const settings_ui = require("./settings_ui");
-const ui_report = require("./ui_report");
+import * as channel from "./channel";
+import * as emojisets from "./emojisets";
+import * as loading from "./loading";
+import * as overlays from "./overlays";
+import * as settings_config from "./settings_config";
+import * as settings_ui from "./settings_ui";
+import * as ui_report from "./ui_report";
const meta = {
loaded: false,
@@ -34,7 +32,7 @@ function change_display_setting(data, status_element, success_msg, sticky) {
);
}
-exports.set_up = function () {
+export function set_up() {
meta.loaded = true;
$("#display-settings-status").hide();
@@ -151,9 +149,9 @@ exports.set_up = function () {
const data = {translate_emoticons: JSON.stringify(this.checked)};
change_display_setting(data, "#emoji-settings-status");
});
-};
+}
-exports.report_emojiset_change = async function () {
+export async function report_emojiset_change() {
// TODO: Clean up how this works so we can use
// change_display_setting. The challenge is that we don't want to
// report success before the server_events request returns that
@@ -173,9 +171,9 @@ exports.report_emojiset_change = async function () {
const spinner = $("#emoji-settings-status").expectOne();
settings_ui.display_checkmark(spinner);
}
-};
+}
-exports.update_page = function () {
+export function update_page() {
$("#left_side_userlist").prop("checked", page_params.left_side_userlist);
$("#default_language_name").text(page_params.default_language_name);
$("#translate_emoticons").prop("checked", page_params.translate_emoticons);
@@ -184,6 +182,4 @@ exports.update_page = function () {
// TODO: Set emojiset selector here.
// Longer term, we'll want to automate this function
-};
-
-window.settings_display = exports;
+}
diff --git a/static/js/settings_sections.js b/static/js/settings_sections.js
index d875a1dd0db..6cfb27c7e39 100644
--- a/static/js/settings_sections.js
+++ b/static/js/settings_sections.js
@@ -3,6 +3,7 @@
const alert_words_ui = require("./alert_words_ui");
const attachments_ui = require("./attachments_ui");
const settings_account = require("./settings_account");
+const settings_display = require("./settings_display");
const settings_muting = require("./settings_muting");
const load_func_dict = new Map(); // group -> function