Files
fusion/packages/dashboard/app/plugins/registerBundledPluginViews.ts
Fusion 6769b836f6 feat(FN-3763): add cli printing press wizard plugin
Implements a new `fusion-plugin-cli-printing-press` plugin with a multi-step wizard UI for authoring CLI commands, including draft storage, route registration, and validation — plus integration wiring in the dashboard's plugin view registry. Includes TypeScript build and ESM import fixes for the plu

Fusion-Task-Id: FN-3763
2026-05-10 15:34:09 -07:00

78 lines
3.0 KiB
TypeScript

import { createElement, lazy, type ReactElement } from "react";
import type { ComponentType } from "react";
import type { PluginDashboardViewContext } from "./types";
import { registerPluginView } from "./pluginViewRegistry";
let registered = false;
type PluginViewComponent = ({ context }: { context?: PluginDashboardViewContext }) => ReactElement;
function createMissingPluginView(moduleId: string, exportName: string): PluginViewComponent {
return function MissingPluginView() {
return createElement("span", null, `Bundled plugin view unavailable: ${moduleId}#${exportName}`);
};
}
async function loadDependencyGraphView(): Promise<{ default: PluginViewComponent }> {
const moduleId = "@fusion-plugin-examples/dependency-graph/dashboard-view";
const exportName = "DependencyGraphDashboardView";
const mod = await import("@fusion-plugin-examples/dependency-graph/dashboard-view") as unknown as Record<string, ComponentType<{ context?: PluginDashboardViewContext }>>;
const component = mod[exportName];
if (!component) {
console.warn(`[plugin-views] Missing export ${exportName} from ${moduleId}`);
return { default: createMissingPluginView(moduleId, exportName) };
}
return { default: component as PluginViewComponent };
}
async function loadRoadmapView(): Promise<{ default: PluginViewComponent }> {
const moduleId = "@fusion-plugin-examples/roadmap/dashboard-view";
const exportName = "RoadmapDashboardView";
const mod = await import("@fusion-plugin-examples/roadmap/dashboard-view") as unknown as Record<string, ComponentType<{ context?: PluginDashboardViewContext }>>;
const component = mod[exportName];
if (!component) {
console.warn(`[plugin-views] Missing export ${exportName} from ${moduleId}`);
return { default: createMissingPluginView(moduleId, exportName) };
}
return { default: component as PluginViewComponent };
}
async function loadCliPrintingPressWizardView(): Promise<{ default: PluginViewComponent }> {
const moduleId = "@fusion-plugin-examples/cli-printing-press/dashboard-view";
const exportName = "CliPrintingPressWizardView";
const mod = await import("@fusion-plugin-examples/cli-printing-press/dashboard-view") as unknown as Record<string, ComponentType<{ context?: PluginDashboardViewContext }>>;
const component = mod[exportName];
if (!component) {
console.warn(`[plugin-views] Missing export ${exportName} from ${moduleId}`);
return { default: createMissingPluginView(moduleId, exportName) };
}
return { default: component as PluginViewComponent };
}
export function registerBundledPluginViews(): void {
if (registered) return;
registered = true;
registerPluginView(
"fusion-plugin-dependency-graph",
"graph",
lazy(loadDependencyGraphView),
);
registerPluginView(
"roadmap-planner",
"roadmaps",
lazy(loadRoadmapView),
);
registerPluginView(
"fusion-plugin-cli-printing-press",
"wizard",
lazy(loadCliPrintingPressWizardView),
);
}
export function __test_resetBundledPluginViewRegistration(): void {
registered = false;
}