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

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-27 16:23:35 -08:00 committed by Tim Abbott
parent 972a52ca99
commit d36c6f23f6
7 changed files with 21 additions and 25 deletions

View File

@ -125,7 +125,6 @@
"files": ["static/js/**"],
"globals": {
"$": false,
"admin": false,
"blueslip": false,
"bot_data": false,
"compose_actions": false,

View File

@ -21,7 +21,8 @@ rewiremock("../../static/js/search").with({
set_global("document", "document-stub");
const history = set_global("history", {});
const admin = set_global("admin", {});
const admin = {__esModule: true};
rewiremock("../../static/js/admin").with(admin);
const drafts = {__esModule: true};
rewiremock("../../static/js/drafts").with(drafts);
set_global("favicon", {});

View File

@ -1,18 +1,16 @@
"use strict";
import render_admin_tab from "../templates/admin_tab.hbs";
import render_settings_organization_settings_tip from "../templates/settings/organization_settings_tip.hbs";
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");
const settings_emoji = require("./settings_emoji");
const settings_org = require("./settings_org");
const settings_panel_menu = require("./settings_panel_menu");
const settings_sections = require("./settings_sections");
const settings_toggle = require("./settings_toggle");
import * as overlays from "./overlays";
import * as settings from "./settings";
import * as settings_bots from "./settings_bots";
import * as settings_config from "./settings_config";
import * as settings_data from "./settings_data";
import * as settings_emoji from "./settings_emoji";
import * as settings_org from "./settings_org";
import * as settings_panel_menu from "./settings_panel_menu";
import * as settings_sections from "./settings_sections";
import * as settings_toggle from "./settings_toggle";
const admin_settings_label = {
// Organization settings
@ -50,7 +48,7 @@ function insert_tip_box() {
.prepend(tip_box);
}
exports.build_page = function () {
export function build_page() {
const options = {
custom_profile_field_types: page_params.custom_profile_field_types,
realm_name: page_params.realm_name,
@ -143,16 +141,14 @@ exports.build_page = function () {
$("#id_realm_default_twenty_four_hour_time").val(
JSON.stringify(page_params.realm_default_twenty_four_hour_time),
);
};
}
exports.launch = function (section) {
export function launch(section) {
settings.build_page();
exports.build_page();
build_page();
settings_sections.reset_sections();
overlays.open_settings();
settings_panel_menu.org_settings.activate_section_or_default(section);
settings_toggle.highlight_toggle("organization");
};
window.admin = exports;
}

View File

@ -37,7 +37,6 @@ import "../templates";
import "../dropdown_list_widget";
import "../settings_profile_fields";
import "../settings";
import "../admin";
import "../message_view_header";
import "../bot_data";
import "../reactions";

View File

@ -3,7 +3,6 @@
// remove each declaration when the corresponding module is migrated
// to TS.
declare let admin: any;
declare let blueslip: any;
declare let bot_data: any;
declare let compose_actions: any;

View File

@ -1,3 +1,4 @@
import * as admin from "./admin";
import * as drafts from "./drafts";
import * as floating_recipient_bar from "./floating_recipient_bar";
import * as hash_util from "./hash_util";

View File

@ -1,6 +1,7 @@
import timezones from "../generated/timezones.json";
import render_settings_tab from "../templates/settings_tab.hbs";
import * as admin from "./admin";
import * as overlays from "./overlays";
import * as people from "./people";
import * as settings_account from "./settings_account";