feat(FN-1916): add plugin UI slots system for extensibility
- Add PluginSlot component for rendering plugin UI placeholders at designated dashboard locations - Add usePluginUiSlots hook with 60-second TTL cache for slot definitions - Add fetchPluginUiSlots API wrapper and PluginUiSlotEntry type - Add UI slots documentation section to plugin authoring guide - Add PluginSlot integration tests for TaskCard, Column, Header, SettingsModal, and TaskDetailModal - Update CI Status example plugin to demonstrate uiSlots registration - Fix JSX namespace import in PluginSlot.tsx for TypeScript compatibility
This commit is contained in:
@@ -125,6 +125,40 @@ describe("ci-status plugin", () => {
|
||||
expect(plugin.manifest.settingsSchema!.pollIntervalMs).toBeDefined();
|
||||
expect(plugin.manifest.settingsSchema!.branchPrefix).toBeDefined();
|
||||
});
|
||||
|
||||
describe("uiSlots", () => {
|
||||
it("should have uiSlots array with 2 entries", () => {
|
||||
expect(plugin.uiSlots).toBeDefined();
|
||||
expect(plugin.uiSlots!.length).toBe(2);
|
||||
});
|
||||
|
||||
it("should have task-card-badge slot", () => {
|
||||
const slot = plugin.uiSlots!.find((s) => s.slotId === "task-card-badge");
|
||||
expect(slot).toBeDefined();
|
||||
expect(slot!.label).toBe("CI Status");
|
||||
expect(slot!.icon).toBe("circle-check");
|
||||
expect(slot!.componentPath).toBe("./components/ci-badge.js");
|
||||
});
|
||||
|
||||
it("should have task-detail-tab slot", () => {
|
||||
const slot = plugin.uiSlots!.find((s) => s.slotId === "task-detail-tab");
|
||||
expect(slot).toBeDefined();
|
||||
expect(slot!.label).toBe("CI History");
|
||||
expect(slot!.icon).toBe("history");
|
||||
expect(slot!.componentPath).toBe("./components/ci-history-tab.js");
|
||||
});
|
||||
|
||||
it("should have required fields for each slot", () => {
|
||||
for (const slot of plugin.uiSlots!) {
|
||||
expect(typeof slot.slotId).toBe("string");
|
||||
expect(slot.slotId.length).toBeGreaterThan(0);
|
||||
expect(typeof slot.label).toBe("string");
|
||||
expect(slot.label.length).toBeGreaterThan(0);
|
||||
expect(typeof slot.componentPath).toBe("string");
|
||||
expect(slot.componentPath.length).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("hooks.onLoad", () => {
|
||||
|
||||
@@ -4,6 +4,7 @@ import type {
|
||||
PluginContext,
|
||||
PluginSettingSchema,
|
||||
PluginRouteDefinition,
|
||||
PluginUiSlotDefinition,
|
||||
} from "@fusion/plugin-sdk";
|
||||
|
||||
// ── Types ──────────────────────────────────────────────────────────────────────
|
||||
@@ -164,6 +165,26 @@ const routes: PluginRouteDefinition[] = [
|
||||
},
|
||||
];
|
||||
|
||||
// ── UI Slots ─────────────────────────────────────────────────────────────────
|
||||
|
||||
// UI slots declare where the plugin provides dashboard UI components.
|
||||
// The dashboard renders placeholder elements for each registered slot.
|
||||
// Full dynamic component loading will be added in a future iteration.
|
||||
const uiSlots: PluginUiSlotDefinition[] = [
|
||||
{
|
||||
slotId: "task-card-badge",
|
||||
label: "CI Status",
|
||||
icon: "circle-check",
|
||||
componentPath: "./components/ci-badge.js",
|
||||
},
|
||||
{
|
||||
slotId: "task-detail-tab",
|
||||
label: "CI History",
|
||||
icon: "history",
|
||||
componentPath: "./components/ci-history-tab.js",
|
||||
},
|
||||
];
|
||||
|
||||
// ── Plugin Definition ───────────────────────────────────────────────────────────
|
||||
|
||||
const plugin: FusionPlugin = definePlugin({
|
||||
@@ -177,6 +198,7 @@ const plugin: FusionPlugin = definePlugin({
|
||||
},
|
||||
state: "installed",
|
||||
routes,
|
||||
uiSlots,
|
||||
hooks: {
|
||||
onLoad: (ctx) => {
|
||||
pluginLogger = ctx.logger;
|
||||
|
||||
Reference in New Issue
Block a user