mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-26 02:05:31 +00:00
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>
30 lines
1.0 KiB
TypeScript
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 () => {};
|
|
}
|