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

Anders Kaseorgd0ffb3732053
diff --git a/.eslintrc.json b/.eslintrc.json
index 7241203307b..9a8d6fa756f 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -156,7 +156,6 @@
"recent_topics": false,
"search_pill_widget": false,
"settings": false,
- "settings_exports": false,
"settings_linkifiers": false,
"settings_invites": false,
"settings_org": false,
diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js
index 8a42d5c1f42..0e0060978e2 100644
--- a/frontend_tests/node_tests/dispatch.js
+++ b/frontend_tests/node_tests/dispatch.js
@@ -63,7 +63,8 @@ const settings_display = {__esModule: true};
rewiremock("../../static/js/settings_display").with(settings_display);
const settings_emoji = {__esModule: true};
rewiremock("../../static/js/settings_emoji").with(settings_emoji);
-const settings_exports = set_global("settings_exports", {});
+const settings_exports = {__esModule: true};
+rewiremock("../../static/js/settings_exports").with(settings_exports);
const settings_invites = set_global("settings_invites", {});
const settings_linkifiers = set_global("settings_linkifiers", {});
const settings_notifications = {__esModule: true};
diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js
index b45ececfe54..0b8ca2efbaa 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_exports";
import "../settings_org";
import "../settings_users";
import "../settings_streams";
diff --git a/static/js/global.d.ts b/static/js/global.d.ts
index d68792aacbc..e7f336a0d4f 100644
--- a/static/js/global.d.ts
+++ b/static/js/global.d.ts
@@ -28,7 +28,6 @@ declare let reactions: any;
declare let recent_topics: any;
declare let search_pill_widget: any;
declare let settings: any;
-declare let settings_exports: any;
declare let settings_invites: any;
declare let settings_linkifiers: any;
declare let settings_org: any;
diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js
index c636d7dfcda..db6f92816aa 100644
--- a/static/js/server_events_dispatch.js
+++ b/static/js/server_events_dispatch.js
@@ -26,6 +26,7 @@ import * as settings_bots from "./settings_bots";
import * as settings_config from "./settings_config";
import * as settings_display from "./settings_display";
import * as settings_emoji from "./settings_emoji";
+import * as settings_exports from "./settings_exports";
import * as settings_notifications from "./settings_notifications";
import * as starred_messages from "./starred_messages";
import * as stream_data from "./stream_data";
diff --git a/static/js/settings_exports.js b/static/js/settings_exports.js
index 30af2cf6b05..c5bcc341122 100644
--- a/static/js/settings_exports.js
+++ b/static/js/settings_exports.js
@@ -1,21 +1,19 @@
-"use strict";
+import render_admin_export_list from "../templates/admin_export_list.hbs";
-const render_admin_export_list = require("../templates/admin_export_list.hbs");
-
-const channel = require("./channel");
-const ListWidget = require("./list_widget");
-const loading = require("./loading");
-const people = require("./people");
-const timerender = require("./timerender");
-const ui_report = require("./ui_report");
+import * as channel from "./channel";
+import * as ListWidget from "./list_widget";
+import * as loading from "./loading";
+import * as people from "./people";
+import * as timerender from "./timerender";
+import * as ui_report from "./ui_report";
const meta = {
loaded: false,
};
-exports.reset = function () {
+export function reset() {
meta.loaded = false;
-};
+}
function sort_user(a, b) {
const a_name = people.get_full_name(a.acting_user_id).toLowerCase();
@@ -28,7 +26,7 @@ function sort_user(a, b) {
return -1;
}
-exports.populate_exports_table = function (exports) {
+export function populate_exports_table(exports) {
if (!meta.loaded) {
return;
}
@@ -90,9 +88,9 @@ exports.populate_exports_table = function (exports) {
} else {
loading.destroy_indicator(spinner);
}
-};
+}
-exports.set_up = function () {
+export function set_up() {
meta.loaded = true;
$("#export-data").on("click", (e) => {
@@ -119,7 +117,7 @@ exports.set_up = function () {
channel.get({
url: "/json/export/realm",
success(data) {
- exports.populate_exports_table(data.exports);
+ populate_exports_table(data.exports);
},
});
@@ -136,6 +134,4 @@ exports.set_up = function () {
// No success function, since UI updates are done via server_events
});
});
-};
-
-window.settings_exports = exports;
+}
diff --git a/static/js/settings_sections.js b/static/js/settings_sections.js
index ae355200433..0475de3f658 100644
--- a/static/js/settings_sections.js
+++ b/static/js/settings_sections.js
@@ -4,6 +4,7 @@ import * as settings_account from "./settings_account";
import * as settings_bots from "./settings_bots";
import * as settings_display from "./settings_display";
import * as settings_emoji from "./settings_emoji";
+import * as settings_exports from "./settings_exports";
import * as settings_muting from "./settings_muting";
import * as settings_notifications from "./settings_notifications";