(props: { showOwnerLabels: boolean; toolkit: ToolkitResponse })
| 451 | count === 0 ? "No connections" : `${count} ${count === 1 ? "connection" : "connections"}`; |
| 452 | |
| 453 | function ToolkitTile(props: { showOwnerLabels: boolean; toolkit: ToolkitResponse }) { |
| 454 | const toolkit = props.toolkit; |
| 455 | const tools = useAtomValue(toolsAllAtom); |
| 456 | const integrations = useAtomValue(integrationsOptimisticAtom); |
| 457 | const connections = useAtomValue(toolkitConnectionsAtom(toolkit.id)); |
| 458 | const integrationPlugins = useIntegrationPlugins(); |
| 459 | const visibleTools = useMemo( |
| 460 | () => |
| 461 | AsyncResult.isSuccess(tools) |
| 462 | ? (tools.value as readonly ToolRow[]).filter((tool) => |
| 463 | toolCanAppearInToolkit(toolkit, tool), |
| 464 | ) |
| 465 | : [], |
| 466 | [toolkit, tools], |
| 467 | ); |
| 468 | const connectionGroups = useMemo(() => buildConnectionGroups(visibleTools), [visibleTools]); |
| 469 | const connectionRows = AsyncResult.isSuccess(connections) ? connections.value.connections : []; |
| 470 | const integrationRows = AsyncResult.isSuccess(integrations) |
| 471 | ? (integrations.value as readonly Integration[]) |
| 472 | : []; |
| 473 | const tileDataReady = |
| 474 | AsyncResult.isSuccess(connections) && |
| 475 | AsyncResult.isSuccess(tools) && |
| 476 | AsyncResult.isSuccess(integrations); |
| 477 | const configuredConnections = tileDataReady |
| 478 | ? configuredConnectionViews( |
| 479 | connectionRows, |
| 480 | connectionGroups, |
| 481 | integrationRows, |
| 482 | integrationPlugins, |
| 483 | props.showOwnerLabels, |
| 484 | ) |
| 485 | : []; |
| 486 | return ( |
| 487 | <Link |
| 488 | to="/{-$orgSlug}/toolkits/$toolkitSlug" |
| 489 | params={{ toolkitSlug: toolkit.slug }} |
| 490 | aria-label={`Open toolkit ${toolkit.name}`} |
| 491 | className="group flex min-h-36 min-w-0 self-start flex-col justify-between rounded-md border border-border/70 bg-card p-3.5 text-left text-card-foreground shadow-xs transition-[border-color,background-color,box-shadow] hover:border-foreground/25 hover:bg-muted/20 hover:shadow-sm focus-visible:ring-[3px] focus-visible:ring-ring/30 focus-visible:outline-none" |
| 492 | style={toolkitCardStyle} |
| 493 | > |
| 494 | <div className="flex min-w-0 items-start gap-3"> |
| 495 | {tileDataReady ? ( |
| 496 | <ToolkitConnectionIconStack connections={configuredConnections} /> |
| 497 | ) : ( |
| 498 | <Skeleton className="size-9 shrink-0 rounded-md" /> |
| 499 | )} |
| 500 | <div className="min-w-0 flex-1"> |
| 501 | <div className="truncate text-sm font-semibold text-foreground">{toolkit.name}</div> |
| 502 | <div className="mt-1 truncate text-xs text-muted-foreground"> |
| 503 | {tileDataReady ? connectionCountLabel(configuredConnections.length) : "Loading"} |
| 504 | </div> |
| 505 | </div> |
| 506 | </div> |
| 507 | </Link> |
| 508 | ); |
| 509 | } |
| 510 |
nothing calls this directly
no test coverage detected