mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 13:18:33 +08:00
DEV: Unsilence legacy modal deprecation (#22634)
We'd like to get this deprecation unsilenced before the 3.1 release so that theme/plugin developers see the messages and can make the necessary changes during the 3.2 release cycle. To avoid the remaining legacy core modals from creating overwhelming noise in the logs, deprecation messages for them are skipped.
This commit is contained in:
parent
104baab557
commit
be62c3e323
|
@ -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);
|
||||
|
|
|
@ -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" },
|
||||
],
|
||||
};
|
||||
|
|
|
@ -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"),
|
||||
|
|
Loading…
Reference in New Issue
Block a user