Files
paseo/plugin-examples/workspace-row-badges/index.client.tsx
T
Jack Tomaszewski a30b784eb2 feat(plugins): let plugins add items to sidebar workspace rows (#7645)
Plugins can register workspace-row badge render slots, control them from a separated Show menu group, and use the shared WorkspaceRowBadge UI.

Co-authored-by: Jacek Tomaszewski <jacek@fullstack.house>
2026-11-13 17:12:39 +07:00

30 lines
1.0 KiB
TypeScript

import { useWorkspace } from "@getpaseo/plugin/client";
import type {
PluginClientContext,
PluginWorkspaceRowBadgeItemProps,
} from "@getpaseo/plugin/client";
import { WorkspaceRowBadge } from "@getpaseo/plugin/client/ui";
function WorkspaceAttention({ workspaceId }: PluginWorkspaceRowBadgeItemProps) {
const status = useWorkspace(workspaceId, (workspace) => workspace.status);
if (status === "needs_input") {
return <WorkspaceRowBadge icon="CircleHelp" label="Needs input" tone="warning" />;
}
if (status === "failed") {
return <WorkspaceRowBadge icon="CircleAlert" label="Failed" tone="danger" />;
}
return null;
}
export default function contribute(client: PluginClientContext) {
// Apps older than this API do not have the method, and requirements.paseo cannot exclude them.
if (!client.addWorkspaceRowBadgeItem) return () => {};
client.addWorkspaceRowBadgeItem({
id: "attention",
title: "Workspace attention",
icon: "CircleAlert",
Component: WorkspaceAttention,
});
return () => {};
}