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

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-27 16:19:36 -08:00 committed by Tim Abbott
parent c66d616752
commit f94b29356c
9 changed files with 21 additions and 24 deletions

View File

@ -162,7 +162,6 @@
"settings_invites": false,
"settings_org": false,
"settings_profile_fields": false,
"settings_sections": false,
"settings_streams": false,
"settings_user_groups": false,
"settings_users": false,

View File

@ -92,7 +92,7 @@ const server_events = {
initialize() {},
};
rewiremock("../../static/js/server_events").with(server_events);
set_global("settings_sections", {initialize() {}});
rewiremock("../../static/js/settings_sections").with({initialize() {}});
rewiremock("../../static/js/settings_panel_menu").with({initialize() {}});
rewiremock("../../static/js/settings_toggle").with({initialize() {}});
set_global("subs", {initialize() {}});

View File

@ -8,6 +8,7 @@ const settings_bots = require("./settings_bots");
const settings_config = require("./settings_config");
const settings_data = require("./settings_data");
const settings_panel_menu = require("./settings_panel_menu");
const settings_sections = require("./settings_sections");
const settings_toggle = require("./settings_toggle");
const admin_settings_label = {

View File

@ -35,7 +35,6 @@ import "../server_events";
import "../zulip";
import "../templates";
import "../dropdown_list_widget";
import "../settings_sections";
import "../settings_emoji";
import "../settings_exports";
import "../settings_org";

View File

@ -34,7 +34,6 @@ declare let settings_invites: any;
declare let settings_linkifiers: any;
declare let settings_org: any;
declare let settings_profile_fields: any;
declare let settings_sections: any;
declare let settings_streams: any;
declare let settings_user_groups: any;
declare let settings_users: any;

View File

@ -10,6 +10,7 @@ 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");
$("body").ready(() => {

View File

@ -1,6 +1,7 @@
import * as hashchange from "./hashchange";
import * as keydown_util from "./keydown_util";
import * as popovers from "./popovers";
import * as settings_sections from "./settings_sections";
export let normal_settings;
export let org_settings;

View File

@ -1,17 +1,15 @@
"use strict";
const alert_words_ui = require("./alert_words_ui");
const attachments_ui = require("./attachments_ui");
const settings_account = require("./settings_account");
const settings_bots = require("./settings_bots");
const settings_display = require("./settings_display");
const settings_muting = require("./settings_muting");
const settings_notifications = require("./settings_notifications");
import * as alert_words_ui from "./alert_words_ui";
import * as attachments_ui from "./attachments_ui";
import * as settings_account from "./settings_account";
import * as settings_bots from "./settings_bots";
import * as settings_display from "./settings_display";
import * as settings_muting from "./settings_muting";
import * as settings_notifications from "./settings_notifications";
const load_func_dict = new Map(); // group -> function
const loaded_groups = new Set();
exports.get_group = function (section) {
export function get_group(section) {
// Sometimes several sections all share the same code.
switch (section) {
@ -31,9 +29,9 @@ exports.get_group = function (section) {
default:
return section;
}
};
}
exports.initialize = function () {
export function initialize() {
// personal
load_func_dict.set("your-account", settings_account.set_up);
load_func_dict.set("display-settings", settings_display.set_up);
@ -54,10 +52,10 @@ exports.initialize = function () {
load_func_dict.set("user-groups-admin", settings_user_groups.set_up);
load_func_dict.set("profile-field-settings", settings_profile_fields.set_up);
load_func_dict.set("data-exports-admin", settings_exports.set_up);
};
}
exports.load_settings_section = function (section) {
const group = exports.get_group(section);
export function load_settings_section(section) {
const group = get_group(section);
if (!load_func_dict.has(group)) {
blueslip.error("Unknown section " + section);
@ -75,9 +73,9 @@ exports.load_settings_section = function (section) {
// Do the real work here!
load_func();
loaded_groups.add(group);
};
}
exports.reset_sections = function () {
export function reset_sections() {
loaded_groups.clear();
settings_emoji.reset();
settings_exports.reset();
@ -89,6 +87,4 @@ exports.reset_sections = function () {
settings_user_groups.reset();
settings_muting.reset();
// settings_users doesn't need a reset()
};
window.settings_sections = exports;
}

View File

@ -45,6 +45,7 @@ const search = require("./search");
const sent_messages = require("./sent_messages");
const server_events = require("./server_events");
const settings_panel_menu = require("./settings_panel_menu");
const settings_sections = require("./settings_sections");
const settings_toggle = require("./settings_toggle");
const spoilers = require("./spoilers");
const starred_messages = require("./starred_messages");