chore: Decouple core plugins (#14340)

* chore: Move plugin-specific integration code into plugins

Core no longer imports from or names the settings of individual plugins.
Plugins now register mention providers, issue status icons, instance URLs,
settings keys, settings and import schemas, and OAuth clients through hooks.

* fix: Recompute embed instance URLs after plugins load and match legacy issue icons by URL

* fix: Skip logo upload jobs queued without a settings path

* chore: Choose issue status icons from the unfurl state
This commit is contained in:
Tom Moor authored and GitHub committed 2026-11-02 19:42:48 -05:00
1 parent 5901b1213c
commit 6d7cd455e9
80 files changed
+1222 -856

No files matched your search

+11
View File
@@ -1,6 +1,8 @@
import { IntegrationService } from "@shared/types";
import { createLazyComponent } from "~/components/LazyLoad";
import { Hook, PluginManager } from "~/utils/PluginManager";
import config from "../plugin.json";
import { GitHubUtils } from "../shared/GitHubUtils";
import Icon from "./Icon";
PluginManager.add([
@@ -15,4 +17,13 @@ PluginManager.add([
component: createLazyComponent(() => import("./Settings")),
},
},
{
...config,
type: Hook.MentionProvider,
value: {
service: IntegrationService.GitHub,
isMentionable: (url) => url.hostname === "github.com",
mentionType: (url) => GitHubUtils.mentionType(url),
},
},
]);
+66 -2
View File
@@ -1,6 +1,13 @@
import { IntegrationService } from "@shared/types";
import { IntegrationService, IntegrationType } from "@shared/types";
import { Integration } from "@server/models";
import { buildAdmin, buildUser, buildViewer } from "@server/test/factories";
import {
buildAdmin,
buildGuestUser,
buildIntegration,
buildTeam,
buildUser,
buildViewer,
} from "@server/test/factories";
import { getTestServer } from "@server/test/support";
import { GitHub, InstallationAccess } from "../github";
import { SetupAction } from "./schema";
@@ -136,3 +143,60 @@ describe("#github.callback", () => {
expect(res.status).toEqual(403);
});
});
describe("#integrations.list", () => {
it("should expose the github settings of the integration", async () => {
const team = await buildTeam();
const member = await buildUser({ teamId: team.id });
const installation = {
id: 1,
account: { id: 2, name: "outline", avatarUrl: "https://example.com" },
};
await buildIntegration({
userId: member.id,
teamId: team.id,
service: IntegrationService.GitHub,
type: IntegrationType.Embed,
settings: {
github: { installation },
url: "https://example.com",
},
});
const res = await server.post("/api/integrations.list", member);
const body = await res.json();
expect(res.status).toEqual(200);
expect(body.data[0].settings).toEqual({
url: "https://example.com",
github: { installation },
});
});
it("should not expose github settings to guests", async () => {
const team = await buildTeam();
const admin = await buildAdmin({ teamId: team.id });
const guest = await buildGuestUser({ teamId: team.id });
await buildIntegration({
userId: admin.id,
teamId: team.id,
service: IntegrationService.GitHub,
type: IntegrationType.Embed,
settings: {
url: "https://example.com",
github: {
installation: {
id: 123,
account: { id: 456, name: "acme", avatarUrl: "" },
},
},
},
});
const res = await server.post("/api/integrations.list", guest);
const body = await res.json();
expect(res.status).toEqual(200);
expect(body.data[0].settings).toEqual({ url: "https://example.com" });
});
});
+6
View File
@@ -1,3 +1,4 @@
import { IntegrationService } from "@shared/types";
import { Minute } from "@shared/utils/time";
import { PluginManager, Hook } from "@server/utils/PluginManager";
import config from "../plugin.json";
@@ -9,6 +10,11 @@ import { GitHub } from "./github";
import GitHubWebhookTask from "./tasks/GitHubWebhookTask";
import { uninstall } from "./uninstall";
PluginManager.add({
type: Hook.IntegrationSettings,
value: { service: IntegrationService.GitHub, keys: ["github"] },
});
const enabled =
!!env.GITHUB_CLIENT_ID &&
!!env.GITHUB_CLIENT_SECRET &&
+12
View File
@@ -0,0 +1,12 @@
declare module "@shared/types" {
interface EmbedIntegrationSettings {
github?: {
installation: {
id: number;
account: { id: number; name: string; avatarUrl: string };
};
};
}
}
export {};