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.

settings_profile_fields: Use SortableJS as a module.

Anders Kaseorg114cc1ec2500
diff --git a/.eslintrc.json b/.eslintrc.json
index 27f4d2204d6..81de7d68b85 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -105,7 +105,6 @@
"MessageListData": false,
"MessageListView": false,
"Plotly": false,
- "Sortable": false,
"UserSearch": false,
"WinChan": false,
"activity": false,
diff --git a/frontend_tests/node_tests/settings_profile_fields.js b/frontend_tests/node_tests/settings_profile_fields.js
index 61d9db52b71..650045a2f38 100644
--- a/frontend_tests/node_tests/settings_profile_fields.js
+++ b/frontend_tests/node_tests/settings_profile_fields.js
@@ -1,7 +1,8 @@
+const rewiremock = require("rewiremock/node");
+
set_global("page_params", {});
set_global("$", global.make_zjquery());
set_global("loading", {});
-set_global("Sortable", {create: () => {}});
const SHORT_TEXT_ID = 1;
const CHOICE_ID = 3;
@@ -29,7 +30,9 @@ page_params.custom_profile_field_types = {
},
};
-zrequire("settings_profile_fields");
+rewiremock.proxy(() => zrequire("settings_profile_fields"), {
+ sortablejs: {create: () => {}},
+});
function test_populate(opts) {
const fields_data = opts.fields_data;
diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js
index 7b6998744e2..06b0104d4c6 100644
--- a/static/js/bundles/app.js
+++ b/static/js/bundles/app.js
@@ -11,7 +11,6 @@ import "winchan/winchan.js";
import "handlebars/dist/cjs/handlebars.runtime.js";
import "flatpickr/dist/flatpickr.js";
import "flatpickr/dist/plugins/confirmDate/confirmDate.js";
-import "sortablejs/Sortable.js";
// Import App JS
import "../i18n.js";
diff --git a/static/js/bundles/common.js b/static/js/bundles/common.js
index a5eed263e13..85882eee348 100644
--- a/static/js/bundles/common.js
+++ b/static/js/bundles/common.js
@@ -9,7 +9,6 @@ import "../../third/bootstrap/js/bootstrap.js";
import "../common.js";
import "moment/min/moment.min.js";
import "moment-timezone/builds/moment-timezone-with-data.min.js";
-import "sortablejs/Sortable.js";
import "../../third/bootstrap/css/bootstrap.css";
import "../../third/bootstrap/css/bootstrap-btn.css";
import "../../third/bootstrap/css/bootstrap-responsive.css";
diff --git a/static/js/settings_profile_fields.js b/static/js/settings_profile_fields.js
index d5a095c7dbe..beafee767ba 100644
--- a/static/js/settings_profile_fields.js
+++ b/static/js/settings_profile_fields.js
@@ -1,3 +1,5 @@
+const Sortable = require("sortablejs");
+
const render_admin_profile_field_list = require("../templates/admin_profile_field_list.hbs");
const render_settings_profile_field_choice = require("../templates/settings/profile_field_choice.hbs");
diff --git a/tools/webpack.config.ts b/tools/webpack.config.ts
index 79a9464ed74..12342d9d729 100644
--- a/tools/webpack.config.ts
+++ b/tools/webpack.config.ts
@@ -247,7 +247,6 @@ export default (env?: string): webpack.Configuration[] => {
{path: "../static/js/debug.js"},
{path: "jquery/dist/jquery.js", name: ["$", "jQuery"]},
{path: "handlebars/dist/cjs/handlebars.runtime.js", name: "Handlebars"},
- {path: "sortablejs/Sortable.js"},
{path: "winchan/winchan.js", name: "WinChan"},
];
config.module.rules.unshift(...getExposeLoaders(exposeOptions));