fix: Regression in client plugins not loading (#12291)

This commit is contained in:
Tom Moor
2026-05-07 15:44:30 -04:00
committed by GitHub
parent 4aa1c3289a
commit 8371d709dd
2 changed files with 53 additions and 2 deletions
+46
View File
@@ -0,0 +1,46 @@
import { createLazyComponent } from "~/components/LazyLoad";
import { Hook, PluginManager } from "./PluginManager";
const SettingsComponent = () => null;
const Icon = () => null;
const component = createLazyComponent(async () => ({
default: SettingsComponent,
}));
describe("PluginManager", () => {
it("returns registered hooks from observable plugin arrays", () => {
PluginManager.add([
{
id: "test-settings-plugin-low",
name: "Low priority plugin",
type: Hook.Settings,
priority: 20,
value: {
group: "Integrations",
icon: Icon,
component,
},
},
{
id: "test-settings-plugin-high",
name: "High priority plugin",
type: Hook.Settings,
priority: 10,
value: {
group: "Integrations",
icon: Icon,
component,
},
},
]);
const hooks = PluginManager.getHooks(Hook.Settings).filter((plugin) =>
plugin.id.startsWith("test-settings-plugin")
);
expect(hooks.map((plugin) => plugin.id)).toEqual([
"test-settings-plugin-high",
"test-settings-plugin-low",
]);
});
});
+7 -2
View File
@@ -1,5 +1,6 @@
import { isArray, sortBy } from "es-toolkit/compat";
import { action, observable } from "mobx";
import type { IObservableArray } from "mobx";
import type Team from "~/models/Team";
import type User from "~/models/User";
import type { LazyComponent } from "~/components/LazyLoad";
@@ -116,7 +117,8 @@ export class PluginManager {
* @returns A list of plugins
*/
public static getHooks<T extends Hook>(type: T) {
return sortBy(this.plugins.get(type) || [], "priority") as Plugin<T>[];
const plugins = this.plugins.get(type) ?? [];
return sortBy([...plugins], "priority") as Plugin<T>[];
}
/**
@@ -152,7 +154,10 @@ export class PluginManager {
return this.loaded;
}
private static plugins = observable.map<Hook, Plugin<Hook>[]>();
private static plugins = observable.map<
Hook,
IObservableArray<Plugin<Hook>>
>();
@observable
private static loaded = false;