Skip to content

A platform for community discussion. Free, open, simple.

DEV: Unsilence legacy modal deprecation (#22634)

David Taylorbe62c3e323db
diff --git a/app/assets/javascripts/discourse/app/services/modal.js b/app/assets/javascripts/discourse/app/services/modal.js
index 6cd7f4d3c59..6c52d6447dc 100644
--- a/app/assets/javascripts/discourse/app/services/modal.js
+++ b/app/assets/javascripts/discourse/app/services/modal.js
@@ -8,6 +8,79 @@ import { disableImplicitInjections } from "discourse/lib/implicit-injections";
import { CLOSE_INITIATED_BY_MODAL_SHOW } from "discourse/components/d-modal";
import deprecated from "discourse-common/lib/deprecated";
+// Known legacy modals in core. Silence deprecation warnings for these so the messages
+// don't cause unnecessary noise.
+const KNOWN_LEGACY_MODALS = [
+ "associate-account-confirm",
+ "auth-token",
+ "avatar-selector",
+ "bulk-actions-buttons",
+ "bulk-change-category",
+ "bulk-notification-level",
+ "bulk-progress",
+ "change-owner",
+ "change-post-notice",
+ "change-timestamp",
+ "convert-to-public-topic",
+ "create-account",
+ "create-invite-bulk",
+ "create-invite",
+ "delete-topic-confirm",
+ "delete-topic-disallowed",
+ "discard-draft",
+ "download-calendar",
+ "edit-slow-mode",
+ "edit-topic-timer",
+ "edit-user-directory-columns",
+ "explain-reviewable",
+ "feature-topic-on-profile",
+ "feature-topic",
+ "flag",
+ "forgot-password",
+ "grant-badge",
+ "group-default-notifications",
+ "history",
+ "ignore-duration-with-username",
+ "ignore-duration",
+ "insert-hyperlink",
+ "jump-to-post",
+ "login",
+ "move-to-topic",
+ "post-enqueued",
+ "publish-page",
+ "raw-email",
+ "reject-reason-reviewable",
+ "reorder-categories",
+ "request-group-membership-form",
+ "share-and-invite",
+ "tag-upload",
+ "topic-bulk-actions",
+ "topic-summary",
+ "user-status",
+ "admin-add-upload",
+ "admin-delete-posts-confirmation",
+ "admin-incoming-email",
+ "admin-merge-users-prompt",
+ "admin-start-backup",
+ "admin-watched-word-test",
+ "admin-api-key-urls",
+ "admin-delete-user-posts-progress",
+ "admin-install-theme",
+ "admin-penalize-user",
+ "admin-theme-change",
+ "site-setting-default-categories",
+ "admin-badge-preview",
+ "admin-edit-badge-groupings",
+ "admin-merge-users-confirmation",
+ "admin-reseed",
+ "admin-theme-item",
+ "admin-color-scheme-select-base",
+ "admin-form-template-validation-options",
+ "admin-merge-users-progress",
+ "admin-staff-action-log-details",
+ "admin-uploaded-image-list",
+];
+
const LEGACY_OPTS = new Set([
"admin",
"templateName",
@@ -120,15 +193,17 @@ export default class ModalServiceWithLegacySupport extends ModalService {
return super.show(modal, opts);
}
- deprecated(
- "Defining modals using a controller is deprecated. Use the component-based API instead.",
- {
- id: "discourse.modal-controllers",
- since: "3.1",
- dropFrom: "3.2",
- url: "https://meta.discourse.org/t/268057",
- }
- );
+ if (!KNOWN_LEGACY_MODALS.includes(modal)) {
+ deprecated(
+ `Defining modals using a controller is deprecated. Use the component-based API instead. (modal: ${modal})`,
+ {
+ id: "discourse.modal-controllers",
+ since: "3.1",
+ dropFrom: "3.2",
+ url: "https://meta.discourse.org/t/268057",
+ }
+ );
+ }
const name = modal;
const container = getOwner(this);
diff --git a/app/assets/javascripts/discourse/config/deprecation-workflow.js b/app/assets/javascripts/discourse/config/deprecation-workflow.js
index bf06b2d4990..7b1f40b93a5 100644
--- a/app/assets/javascripts/discourse/config/deprecation-workflow.js
+++ b/app/assets/javascripts/discourse/config/deprecation-workflow.js
@@ -8,6 +8,5 @@ globalThis.deprecationWorkflow.config = {
{ handler: "silence", matchId: "route-disconnect-outlet" },
{ handler: "silence", matchId: "this-property-fallback" },
{ handler: "silence", matchId: "discourse.select-kit" },
- { handler: "silence", matchId: "discourse.modal-controllers" },
],
};
diff --git a/app/assets/javascripts/discourse/tests/acceptance/modal-legacy-test.js b/app/assets/javascripts/discourse/tests/acceptance/modal-legacy-test.js
index fcaa35bba9a..cc0033443fe 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/modal-legacy-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/modal-legacy-test.js
@@ -11,6 +11,13 @@ import { hbs } from "ember-cli-htmlbars";
import showModal from "discourse/lib/show-modal";
import { registerTemporaryModule } from "../helpers/temporary-module-helper";
import { getOwner } from "discourse-common/lib/get-owner";
+import { withSilencedDeprecations } from "discourse-common/lib/deprecated";
+
+function silencedShowModal() {
+ return withSilencedDeprecations("discourse.modal-controllers", () =>
+ showModal(...arguments)
+ );
+}
acceptance("Legacy Modal", function (needs) {
let _translations;
@@ -59,7 +66,7 @@ acceptance("Legacy Modal", function (needs) {
hbs`{{#d-modal-body title="" class="" dismissable=false}}test{{/d-modal-body}}`
);
- showModal("not-dismissable", {});
+ silencedShowModal("not-dismissable", {});
await settled();
assert.strictEqual(count(".d-modal:visible"), 1, "modal should appear");
@@ -89,7 +96,7 @@ acceptance("Legacy Modal", function (needs) {
];
await visit("/");
- showModal("test-raw-title-panels", { panels });
+ silencedShowModal("test-raw-title-panels", { panels });
await settled();
assert.strictEqual(
@@ -108,7 +115,7 @@ acceptance("Legacy Modal", function (needs) {
await visit("/");
- showModal("test-title", { title: "test_title" });
+ silencedShowModal("test-title", { title: "test_title" });
await settled();
assert.strictEqual(
query(".d-modal .title").innerText.trim(),
@@ -118,7 +125,7 @@ acceptance("Legacy Modal", function (needs) {
await click(".d-modal .close");
- showModal("test-title-with-body", { title: "test_title" });
+ silencedShowModal("test-title-with-body", { title: "test_title" });
await settled();
assert.strictEqual(
query(".d-modal .title").innerText.trim(),
@@ -128,7 +135,7 @@ acceptance("Legacy Modal", function (needs) {
await click(".d-modal .close");
- showModal("test-title");
+ silencedShowModal("test-title");
await settled();
assert.ok(
!exists(".d-modal .title"),