2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-10-03 17:21:20 +08:00

DEV: Replace deprecated Ember's array .[]

Update deprecation workflows across several modules to handle specific
deprecations, such as `discourse.native-array-extensions.[]`. Replace
obsolete usage of array extensions in `CategoryDrop` and `AdminUser`
components with modern alternatives (`trackedArray`). Enhancements ensure
compatibility with future Ember versions, reducing technical debt.
This commit is contained in:
Sérgio Saquetim 2025-10-02 20:46:39 -03:00
parent 9ad3b0a9c4
commit 2e927f5475
No known key found for this signature in database
GPG key ID: B4E3D7F11E793062
4 changed files with 13 additions and 6 deletions

View file

@ -5,6 +5,7 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
import { propertyNotEqual } from "discourse/lib/computed";
import discourseComputed from "discourse/lib/decorators";
import getURL from "discourse/lib/get-url";
import { trackedArray } from "discourse/lib/tracked-tools";
import { userPath } from "discourse/lib/url";
import Group from "discourse/models/group";
import User from "discourse/models/user";
@ -26,6 +27,8 @@ export default class AdminUser extends User {

adminUserView = true;

@trackedArray groups;

@filter("groups", (g) => !g.automatic && Group.create(g)) customGroups;
@filter("groups", (g) => g.automatic && Group.create(g)) automaticGroups;
@or("active", "staged") canViewProfile;
@ -84,10 +87,7 @@ export default class AdminUser extends User {
return ajax(`/admin/users/${this.id}/groups/${groupId}`, {
type: "DELETE",
}).then(() => {
this.set(
"groups.[]",
this.groups.filter((group) => group.id !== groupId)
);
this.groups = this.groups.filter((group) => group.id !== groupId);
if (this.primary_group_id === groupId) {
this.set("primary_group_id", null);
}

View file

@ -257,6 +257,10 @@ const DeprecationWorkflow = new DiscourseDeprecationWorkflow([
handler: "silence",
matchId: "deprecate-import-meta-from-ember",
},
{
handler: "log",
matchId: "discourse.native-array-extensions.[]",
},
{
handler: "log",
matchId: "discourse.native-array-extensions.any",

View file

@ -1,6 +1,9 @@
const environment = require("discourse/lib/environment");
const { withSilencedDeprecations } = require("discourse/lib/deprecated");

environment.setEnvironment("qunit-testing");
require("discourse/deprecation-workflow").default.setEnvironment(environment);

require("discourse/tests/test-boot-ember-cli");
withSilencedDeprecations("discourse.native-array-extensions.[]", () => {
require("discourse/tests/test-boot-ember-cli");
});

View file

@ -48,7 +48,7 @@ const MORE_COLLECTION = "MORE_COLLECTION";
@pluginApiIdentifiers(["category-drop"])
export default class CategoryDrop extends ComboBoxComponent {
@readOnly("category.id") value;
@readOnly("categoriesWithShortcuts.[]") content;
@readOnly("categoriesWithShortcuts") content;
@readOnly("selectKit.options.parentCategory.displayName") parentCategoryName;
@readOnly("selectKit.options.shouldDisplayIcon") shouldDisplayIcon;
@setting("allow_uncategorized_topics") allowUncategorized;