(props: PluginPageProps)
| 1376 | } |
| 1377 | |
| 1378 | export function ToolkitsPage(props: PluginPageProps) { |
| 1379 | const navigate = useNavigate(); |
| 1380 | const organizationSlug = useOrganizationSlug(); |
| 1381 | const ownerDisplay = useOwnerDisplay(); |
| 1382 | const integrationPlugins = useIntegrationPlugins(); |
| 1383 | const toolkits = useAtomValue(toolkitsAtom); |
| 1384 | const tools = useAtomValue(toolsAllAtom); |
| 1385 | const integrations = useAtomValue(integrationsOptimisticAtom); |
| 1386 | const doCreateToolkit = useAtomSet(createToolkit, { mode: "promiseExit" }); |
| 1387 | const doRemoveToolkit = useAtomSet(removeToolkit, { mode: "promiseExit" }); |
| 1388 | const selectedToolkitSlug = props.params.toolkitSlug ?? null; |
| 1389 | |
| 1390 | const toolkitRows = AsyncResult.isSuccess(toolkits) ? toolkits.value.toolkits : []; |
| 1391 | const selectedToolkit = |
| 1392 | selectedToolkitSlug === null ? null : toolkitByRouteSlug(toolkitRows, selectedToolkitSlug); |
| 1393 | |
| 1394 | const toolRows = AsyncResult.isSuccess(tools) ? (tools.value as readonly ToolRow[]) : []; |
| 1395 | const integrationRows = AsyncResult.isSuccess(integrations) |
| 1396 | ? (integrations.value as readonly Integration[]) |
| 1397 | : []; |
| 1398 | const toolkitsReady = AsyncResult.isSuccess(toolkits); |
| 1399 | const toolkitsFailed = AsyncResult.isFailure(toolkits); |
| 1400 | const toolsReady = AsyncResult.isSuccess(tools); |
| 1401 | const toolsFailed = AsyncResult.isFailure(tools); |
| 1402 | const navigateToIndex = () => |
| 1403 | navigate({ |
| 1404 | to: "/{-$orgSlug}/toolkits", |
| 1405 | }); |
| 1406 | |
| 1407 | const createToolkitHandler = async (input: { owner: Owner; name: string }) => { |
| 1408 | await doCreateToolkit({ |
| 1409 | payload: input, |
| 1410 | reactivityKeys: toolkitWriteKeys, |
| 1411 | }); |
| 1412 | }; |
| 1413 | |
| 1414 | const removeToolkitHandler = async (toolkit: ToolkitResponse) => { |
| 1415 | await doRemoveToolkit({ |
| 1416 | params: { toolkitId: toolkit.id }, |
| 1417 | reactivityKeys: toolkitWriteKeys, |
| 1418 | }); |
| 1419 | await navigateToIndex(); |
| 1420 | }; |
| 1421 | |
| 1422 | return ( |
| 1423 | <div className="flex min-h-0 flex-1 flex-col overflow-hidden"> |
| 1424 | {selectedToolkitSlug === null ? ( |
| 1425 | <div className="flex h-12 shrink-0 items-center gap-3 border-b border-border bg-background/95 px-4 backdrop-blur-sm"> |
| 1426 | <div className="flex min-w-0 items-center gap-3"> |
| 1427 | <h1 className="truncate text-sm font-semibold text-foreground">Toolkits</h1> |
| 1428 | {AsyncResult.isSuccess(toolkits) && ( |
| 1429 | <span className="hidden text-xs tabular-nums text-muted-foreground sm:block"> |
| 1430 | {toolkitRows.length} {toolkitRows.length === 1 ? "toolkit" : "toolkits"} |
| 1431 | </span> |
| 1432 | )} |
| 1433 | </div> |
| 1434 | </div> |
| 1435 | ) : null} |
nothing calls this directly
no test coverage detected