diff --git a/.eslintrc.json b/.eslintrc.json index c9444c4540..fdea75ba8e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -125,7 +125,6 @@ "files": ["static/js/**"], "globals": { "$": false, - "admin": false, "blueslip": false, "bot_data": false, "compose_actions": false, diff --git a/frontend_tests/node_tests/hashchange.js b/frontend_tests/node_tests/hashchange.js index e302dfbb1a..4555b81a8a 100644 --- a/frontend_tests/node_tests/hashchange.js +++ b/frontend_tests/node_tests/hashchange.js @@ -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", {}); diff --git a/static/js/admin.js b/static/js/admin.js index 93f9f9b67a..b0c6d772ec 100644 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -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; +} diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js index bca48331f9..8585826c63 100644 --- a/static/js/bundles/app.js +++ b/static/js/bundles/app.js @@ -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"; diff --git a/static/js/global.d.ts b/static/js/global.d.ts index 579d39bbfa..4ff2a3049d 100644 --- a/static/js/global.d.ts +++ b/static/js/global.d.ts @@ -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; diff --git a/static/js/hashchange.js b/static/js/hashchange.js index cab177bdf8..cb200041f1 100644 --- a/static/js/hashchange.js +++ b/static/js/hashchange.js @@ -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"; diff --git a/static/js/settings.js b/static/js/settings.js index 7fc6b7e1a2..7d8449912d 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -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";