(props: { integrations: readonly Integration[] })
| 483 | // --------------------------------------------------------------------------- |
| 484 | |
| 485 | function IntegrationGrid(props: { integrations: readonly Integration[] }) { |
| 486 | const integrationPlugins = useIntegrationPlugins(); |
| 487 | const pluginByKind = useMemo(() => { |
| 488 | const out = new Map<string, IntegrationPlugin>(); |
| 489 | for (const p of integrationPlugins) out.set(p.key, p); |
| 490 | return out; |
| 491 | }, [integrationPlugins]); |
| 492 | |
| 493 | const items = useMemo(() => groupIntegrations(props.integrations), [props.integrations]); |
| 494 | |
| 495 | const renderEntry = (integration: Integration) => { |
| 496 | const pluginKey = KIND_TO_PLUGIN_KEY[integration.kind] ?? integration.kind; |
| 497 | const plugin = pluginByKind.get(pluginKey); |
| 498 | const SummaryComponent = plugin?.summary; |
| 499 | const slug = String(integration.slug); |
| 500 | const name = integration.name || slug; |
| 501 | return ( |
| 502 | <CardStackEntry key={slug} asChild searchText={`${name} ${slug} ${integration.kind}`}> |
| 503 | <Link |
| 504 | to="/{-$orgSlug}/integrations/$namespace" |
| 505 | params={{ namespace: slug }} |
| 506 | data-testid={`integration-entry-${slug}`} |
| 507 | > |
| 508 | <IntegrationIconWithAccount |
| 509 | icon={integrationPresetIconUrl( |
| 510 | { id: slug, kind: integration.kind, name, url: integration.displayUrl }, |
| 511 | integrationPlugins, |
| 512 | )} |
| 513 | integrationId={slug} |
| 514 | url={integration.displayUrl ?? integrationInferredUrl({ id: slug, name }) ?? undefined} |
| 515 | /> |
| 516 | <CardStackEntryContent> |
| 517 | <CardStackEntryTitle>{name}</CardStackEntryTitle> |
| 518 | <CardStackEntryDescription>{slug}</CardStackEntryDescription> |
| 519 | </CardStackEntryContent> |
| 520 | <CardStackEntryActions> |
| 521 | {SummaryComponent && ( |
| 522 | <Suspense fallback={null}> |
| 523 | <SummaryComponent integrationId={slug} /> |
| 524 | </Suspense> |
| 525 | )} |
| 526 | <IntegrationHealthSummary integration={integration.slug} /> |
| 527 | </CardStackEntryActions> |
| 528 | </Link> |
| 529 | </CardStackEntry> |
| 530 | ); |
| 531 | }; |
| 532 | |
| 533 | const rendered: ReactNode[] = []; |
| 534 | let flatRun: Integration[] = []; |
| 535 | const flushFlat = () => { |
| 536 | if (flatRun.length === 0) return; |
| 537 | const run = flatRun; |
| 538 | flatRun = []; |
| 539 | rendered.push( |
| 540 | <CardStack key={`flat-${String(run[0]!.slug)}`} searchable> |
| 541 | <CardStackContent>{run.map(renderEntry)}</CardStackContent> |
| 542 | </CardStack>, |
nothing calls this directly
no test coverage detected