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

Anders Kaseorg972a52ca99fa
diff --git a/.eslintrc.json b/.eslintrc.json
index cebafab1045..c9444c45404 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -155,7 +155,6 @@
"realm_night_logo": false,
"recent_topics": false,
"search_pill_widget": false,
- "settings": false,
"settings_profile_fields": false,
"stream_list": false,
"StripeCheckout": false,
diff --git a/frontend_tests/node_tests/hashchange.js b/frontend_tests/node_tests/hashchange.js
index ff10c28319e..e302dfbb1ae 100644
--- a/frontend_tests/node_tests/hashchange.js
+++ b/frontend_tests/node_tests/hashchange.js
@@ -34,7 +34,8 @@ rewiremock("../../static/js/message_viewport").with(message_viewport);
const narrow = set_global("narrow", {});
const overlays = {__esModule: true};
rewiremock("../../static/js/overlays").with(overlays);
-const settings = set_global("settings", {});
+const settings = {__esModule: true};
+rewiremock("../../static/js/settings").with(settings);
const subs = set_global("subs", {});
const ui_util = {__esModule: true};
rewiremock("../../static/js/ui_util").with(ui_util);
diff --git a/static/js/admin.js b/static/js/admin.js
index bd5901e5a9e..93f9f9b67a7 100644
--- a/static/js/admin.js
+++ b/static/js/admin.js
@@ -4,6 +4,7 @@ const render_admin_tab = require("../templates/admin_tab.hbs");
const render_settings_organization_settings_tip = require("../templates/settings/organization_settings_tip.hbs");
const overlays = require("./overlays");
+const settings = require("./settings");
const settings_bots = require("./settings_bots");
const settings_config = require("./settings_config");
const settings_data = require("./settings_data");
diff --git a/static/js/global.d.ts b/static/js/global.d.ts
index 205792f926e..579d39bbfa9 100644
--- a/static/js/global.d.ts
+++ b/static/js/global.d.ts
@@ -27,7 +27,6 @@ declare let pointer: any;
declare let reactions: any;
declare let recent_topics: any;
declare let search_pill_widget: any;
-declare let settings: any;
declare let settings_profile_fields: any;
declare let stream_list: any;
declare let subs: any;
diff --git a/static/js/hashchange.js b/static/js/hashchange.js
index a356b35c470..cab177bdf8f 100644
--- a/static/js/hashchange.js
+++ b/static/js/hashchange.js
@@ -7,6 +7,7 @@ import * as message_viewport from "./message_viewport";
import * as navigate from "./navigate";
import * as overlays from "./overlays";
import * as search from "./search";
+import * as settings from "./settings";
import * as settings_panel_menu from "./settings_panel_menu";
import * as top_left_corner from "./top_left_corner";
import * as ui_util from "./ui_util";
diff --git a/static/js/settings.js b/static/js/settings.js
index 26fb7a14008..7fc6b7e1a2f 100644
--- a/static/js/settings.js
+++ b/static/js/settings.js
@@ -1,17 +1,17 @@
-"use strict";
+import timezones from "../generated/timezones.json";
+import render_settings_tab from "../templates/settings_tab.hbs";
-const timezones = require("../generated/timezones.json");
-const render_settings_tab = require("../templates/settings_tab.hbs");
+import * as overlays from "./overlays";
+import * as people from "./people";
+import * as settings_account from "./settings_account";
+import * as settings_bots from "./settings_bots";
+import * as settings_config from "./settings_config";
+import * as settings_notifications from "./settings_notifications";
+import * as settings_panel_menu from "./settings_panel_menu";
+import * as settings_sections from "./settings_sections";
+import * as settings_toggle from "./settings_toggle";
-const overlays = require("./overlays");
-const people = require("./people");
-const settings_account = require("./settings_account");
-const settings_bots = require("./settings_bots");
-const settings_config = require("./settings_config");
-const settings_notifications = require("./settings_notifications");
-const settings_panel_menu = require("./settings_panel_menu");
-const settings_sections = require("./settings_sections");
-const settings_toggle = require("./settings_toggle");
+export let settings_label;
$("body").ready(() => {
$("#settings_overlay_container").on("click", (e) => {
@@ -33,7 +33,7 @@ $("body").ready(() => {
});
function setup_settings_label() {
- exports.settings_label = {
+ settings_label = {
// settings_notification
enable_online_push_notifications: i18n.t(
"Send mobile notifications even if I'm online (useful for testing)",
@@ -67,7 +67,7 @@ function setup_settings_label() {
};
}
-exports.build_page = function () {
+export function build_page() {
setup_settings_label();
const rendered_settings_tab = render_settings_tab({
@@ -79,7 +79,7 @@ exports.build_page = function () {
botserverrc: "botserverrc",
timezones: timezones.timezones,
can_create_new_bots: settings_bots.can_create_new_bots(),
- settings_label: exports.settings_label,
+ settings_label,
demote_inactive_streams_values: settings_config.demote_inactive_streams_values,
color_scheme_values: settings_config.color_scheme_values,
twenty_four_hour_time_values: settings_config.twenty_four_hour_time_values,
@@ -94,19 +94,19 @@ exports.build_page = function () {
});
$(".settings-box").html(rendered_settings_tab);
-};
+}
-exports.launch = function (section) {
- exports.build_page();
+export function launch(section) {
+ build_page();
admin.build_page();
settings_sections.reset_sections();
overlays.open_settings();
settings_panel_menu.normal_settings.activate_section_or_default(section);
settings_toggle.highlight_toggle("settings");
-};
+}
-exports.set_settings_header = function (key) {
+export function set_settings_header(key) {
const header_text = $(
`#settings_page .sidebar-list [data-section='${CSS.escape(key)}'] .text`,
).text();
@@ -120,6 +120,4 @@ exports.set_settings_header = function (key) {
" sidebar list. Please add it.",
);
}
-};
-
-window.settings = exports;
+}
diff --git a/static/js/settings_panel_menu.js b/static/js/settings_panel_menu.js
index ed380e6c270..051c6a5c07d 100644
--- a/static/js/settings_panel_menu.js
+++ b/static/js/settings_panel_menu.js
@@ -1,6 +1,7 @@
import * as hashchange from "./hashchange";
import * as keydown_util from "./keydown_util";
import * as popovers from "./popovers";
+import * as settings from "./settings";
import * as settings_sections from "./settings_sections";
export let normal_settings;