Files
fly-sprites-workers/index.client.tsx
T

72 lines
1.8 KiB
TypeScript

import {
type PluginClientContext,
type PluginSidebarItemProps,
type PluginWorkspacePanelProps,
useWorkspace,
} from "@getpaseo/plugin/client";
import { SidebarRow } from "@getpaseo/plugin/client/ui";
import { FlySpritesSettingsScreen } from "./client/settings-screen";
import { FlySpritesWorkersScreen } from "./client/workers-screen";
function WorkersSidebarItem({ currentScreen, openScreen }: PluginSidebarItemProps) {
return (
<SidebarRow
icon="Cpu"
active={currentScreen?.screenId === "workers"}
onPress={() => openScreen({ screenId: "workers" })}
/>
);
}
function WorkspaceWorkersPanel({ workspaceId, ...hostProps }: PluginWorkspacePanelProps) {
const workspace = useWorkspace(workspaceId);
return (
<FlySpritesWorkersScreen
{...hostProps}
workspaceName={workspace?.name}
workspaceDirectory={workspace?.directory}
/>
);
}
export default function contribute(client: PluginClientContext) {
client.addScreen({
id: "workers",
title: "Fly Sprites Workers",
Component: FlySpritesWorkersScreen,
});
client.addWorkspacePanel({
id: "fly-sprites-workers",
title: "Fly Sprites",
icon: "Cpu",
Component: WorkspaceWorkersPanel,
});
client.addSidebarHeaderItem({
id: "fly-sprites-workers",
title: "Fly Sprites",
Component: WorkersSidebarItem,
});
client.addCommandCenterItem({
id: "open-fly-sprites-workers",
title: "Open Fly Sprites Workers",
icon: "Cpu",
keywords: ["fly", "sprites", "workers", "vm", "sandbox", "remote"],
context: "global",
onSelect({ openScreen }) {
openScreen({ screenId: "workers" });
},
});
client.addSettingsScreen({
id: "fly-sprites",
title: "Fly Sprites Workers",
icon: "Cpu",
Component: FlySpritesSettingsScreen,
});
return () => {};
}