feat(sdk,plugins): typage et stabilisation runtime UI/layout publique (#128)
This commit is contained in:
@ -30,7 +30,10 @@ function cell(overrides: Partial<CustomPluginLayoutCell> = {}): CustomPluginLayo
|
||||
};
|
||||
}
|
||||
|
||||
let latestLayoutProps: PluginLayoutProps | null = null;
|
||||
|
||||
function MockLayoutComponent(props: PluginLayoutProps) {
|
||||
latestLayoutProps = props;
|
||||
return (
|
||||
<div>
|
||||
<p data-testid="state">{JSON.stringify(props.state)}</p>
|
||||
@ -87,8 +90,11 @@ describe("PluginLayoutCellView", () => {
|
||||
it("renders the mock registered component when the provider is loaded", () => {
|
||||
const registry = new PluginRuntimeRegistry();
|
||||
registry.add(stubPlugin());
|
||||
latestLayoutProps = null;
|
||||
renderCell(registry);
|
||||
expect(screen.getByTestId("state").textContent).toBe(JSON.stringify({ commits: 3 }));
|
||||
expect(latestLayoutProps).not.toBeNull();
|
||||
expect(Object.prototype.hasOwnProperty.call(latestLayoutProps, "gateways")).toBe(false);
|
||||
});
|
||||
|
||||
it("round-trips state through setState → onStateChange", () => {
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
import { Component, type ErrorInfo, type ReactNode } from "react";
|
||||
|
||||
import type { CustomPluginLayoutCell, PluginAdmin } from "@/domain";
|
||||
import { useGateways } from "@/app/di";
|
||||
import { usePluginRuntime } from "./PluginRuntimeProvider";
|
||||
import { PluginLayoutFallback } from "./PluginLayoutFallback";
|
||||
import { resolvePluginLayoutAvailability } from "./layoutAvailability";
|
||||
@ -68,7 +67,6 @@ export function PluginLayoutCellView({
|
||||
onChooseAnotherLayout,
|
||||
}: PluginLayoutCellViewProps) {
|
||||
const { registry } = usePluginRuntime();
|
||||
const gateways = useGateways();
|
||||
const availability = resolvePluginLayoutAvailability(registry, cell, installedPlugins);
|
||||
const providerDisplayName =
|
||||
registry.get(cell.pluginId)?.displayName ??
|
||||
@ -108,15 +106,6 @@ export function PluginLayoutCellView({
|
||||
state={cell.state}
|
||||
setState={onStateChange}
|
||||
availability="available"
|
||||
gateways={{
|
||||
project: gateways.project,
|
||||
git: gateways.git,
|
||||
terminal: gateways.terminal,
|
||||
agents: gateways.agent,
|
||||
system: gateways.system,
|
||||
workState: gateways.workState,
|
||||
focusedProject: gateways.focusedProject,
|
||||
}}
|
||||
/>
|
||||
</PluginLayoutErrorBoundary>
|
||||
);
|
||||
|
||||
@ -75,6 +75,11 @@ export function PluginRuntimeProvider({ children, value: injected }: PluginRunti
|
||||
system: gateways.system,
|
||||
workState: gateways.workState,
|
||||
focusedProject: gateways.focusedProject,
|
||||
pluginWorkspace: gateways.pluginWorkspace,
|
||||
pluginTask: gateways.pluginTask,
|
||||
pluginToolchain: gateways.pluginToolchain,
|
||||
pluginEvents: gateways.pluginEvents,
|
||||
pluginConfig: gateways.pluginConfig,
|
||||
}),
|
||||
)
|
||||
.then((result) => {
|
||||
|
||||
Reference in New Issue
Block a user