DEV: remove bootbox dependency (#27443)

This commit is contained in:
Kelv
2024-06-12 15:56:17 +08:00
committed by GitHub
parent 5963c03643
commit 7e31a8104d
8 changed files with 0 additions and 845 deletions

View File

@@ -1,10 +1,6 @@
import "bootstrap/js/modal";
import bootbox from "bootbox";
import $ from "jquery";
import autocomplete from "discourse/lib/autocomplete";
import { caret, caretPosition } from "discourse/lib/caret-position";
import deprecated from "discourse-common/lib/deprecated";
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
let jqueryPluginsConfigured = false;
@@ -14,44 +10,6 @@ export default {
return;
}
// Settings for bootbox
bootbox.animate(false);
bootbox.backdrop(true);
// Monkey-patching simple alerts
const originalAlert = bootbox.alert;
bootbox.alert = function () {
if (arguments.length === 1) {
const dialog = getOwnerWithFallback(this).lookup("service:dialog");
if (dialog) {
deprecated(
"`bootbox.alert` is deprecated, please use the dialog service instead.",
{
id: "discourse.bootbox",
dropFrom: "3.1.0.beta5",
url: "https://meta.discourse.org/t/244902",
}
);
return dialog.alert(arguments[0]);
}
}
return originalAlert(...arguments);
};
// adding deprecation notice for all other dialogs
const originalDialog = bootbox.dialog;
bootbox.dialog = function () {
deprecated(
"`bootbox` is now deprecated, please use the dialog service instead.",
{
id: "discourse.bootbox",
dropFrom: "3.1.0.beta5",
url: "https://meta.discourse.org/t/244902",
}
);
return originalDialog(...arguments);
};
// Initialize the autocomplete tool
$.fn.autocomplete = autocomplete;

View File

@@ -1,4 +1,3 @@
import bootbox from "bootbox";
import I18n from "discourse-i18n";
export default {
@@ -45,12 +44,5 @@ export default {
key = key.replace(/^[a-z_]*js\./, "");
I18n._compiledMFs[key] = value;
}
bootbox.addLocale(I18n.currentLocale(), {
OK: I18n.t("composer.modal_ok"),
CANCEL: I18n.t("composer.modal_cancel"),
CONFIRM: I18n.t("composer.modal_ok"),
});
bootbox.setLocale(I18n.currentLocale());
},
};

View File

@@ -78,7 +78,6 @@ module.exports = function (defaults) {
});
// WARNING: We should only import scripts here if they are not in NPM.
app.import(vendorJs + "bootbox.js");
app.import(discourseRoot + "/app/assets/javascripts/polyfills.js");
app.import(
@@ -178,22 +177,6 @@ module.exports = function (defaults) {
exportsPresence: "error",
},
},
rules: [
{
test: require.resolve("bootstrap/js/modal"),
use: [
{
loader: "imports-loader",
options: {
imports: {
moduleName: "jquery",
name: "jQuery",
},
},
},
],
},
],
},
plugins: [
// The server use this output to map each asset to its chunks

View File

@@ -10,8 +10,6 @@ import {
setApplication,
setResolver,
} from "@ember/test-helpers";
import "bootstrap/js/modal";
import bootbox from "bootbox";
import { addModuleExcludeMatcher } from "ember-cli-test-loader/test-support/index";
import $ from "jquery";
import MessageBus from "message-bus-client";
@@ -51,34 +49,7 @@ import { loadSprites } from "../lib/svg-sprite-loader";
import * as FakerModule from "@faker-js/faker";
import { setLoadedFaker } from "discourse/lib/load-faker";
const Plugin = $.fn.modal;
const Modal = Plugin.Constructor;
let cancelled = false;
function AcceptanceModal(option, _relatedTarget) {
return this.each(function () {
let $this = $(this);
let data = $this.data("bs.modal");
let options = Object.assign(
{},
Modal.DEFAULTS,
$this.data(),
typeof option === "object" && option
);
if (!data) {
$this.data("bs.modal", (data = new Modal(this, options)));
}
data.$body = $("#ember-testing");
if (typeof option === "string") {
data[option](_relatedTarget);
} else if (options.show) {
data.show(_relatedTarget);
}
});
}
let started = false;
function createApplication(config, settings) {
@@ -255,8 +226,6 @@ export default function setupTests(config) {
window.Logster = { enabled: false };
}
$.fn.modal = AcceptanceModal;
Object.defineProperty(window, "exists", {
get() {
deprecated(
@@ -280,7 +249,6 @@ export default function setupTests(config) {
let app;
QUnit.testStart(function (ctx) {
bootbox.$body = $("#ember-testing");
let settings = resetSettings();
resetThemeSettings();