({ organizationId }: IntegrationsHubProps)
| 18 | }; |
| 19 | |
| 20 | export function IntegrationsHub({ organizationId }: IntegrationsHubProps) { |
| 21 | const router = useRouter(); |
| 22 | const trpc = useTRPC(); |
| 23 | const input = organizationId ? { organizationId } : undefined; |
| 24 | |
| 25 | const { data: installationStatuses, isLoading: installationStatusesLoading } = useQuery( |
| 26 | trpc.platformIntegrations.listSetupStatus.queryOptions(input) |
| 27 | ); |
| 28 | const { data: githubAuthorization, isLoading: githubAuthorizationLoading } = useQuery({ |
| 29 | ...trpc.githubApps.getUserAuthorization.queryOptions(), |
| 30 | enabled: !organizationId, |
| 31 | }); |
| 32 | |
| 33 | const isLoading = installationStatusesLoading || (!organizationId && githubAuthorizationLoading); |
| 34 | |
| 35 | if (isLoading) { |
| 36 | return ( |
| 37 | <div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3"> |
| 38 | {Array.from({ length: getPlatformDefinitionCountForOwner(organizationId) }, (_, index) => ( |
| 39 | <Card key={index}> |
| 40 | <CardContent className="pt-6"> |
| 41 | <div className="animate-pulse space-y-4"> |
| 42 | <div className="bg-muted h-20 rounded" /> |
| 43 | <div className="bg-muted h-12 rounded" /> |
| 44 | </div> |
| 45 | </CardContent> |
| 46 | </Card> |
| 47 | ))} |
| 48 | </div> |
| 49 | ); |
| 50 | } |
| 51 | |
| 52 | const platforms = buildPlatforms(installationStatuses ?? [], organizationId); |
| 53 | |
| 54 | const handleNavigate = (platformId: string) => { |
| 55 | const platform = platforms.find(p => p.id === platformId); |
| 56 | if (platform?.route) { |
| 57 | router.push(platform.route); |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | const githubIdentityStatus: GitHubIdentityStatus | undefined = organizationId |
| 62 | ? undefined |
| 63 | : githubAuthorization?.connected |
| 64 | ? 'connected' |
| 65 | : githubAuthorization?.revoked |
| 66 | ? 'revoked' |
| 67 | : undefined; |
| 68 | |
| 69 | return ( |
| 70 | <div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3"> |
| 71 | {platforms.map(platform => ( |
| 72 | <PlatformCard |
| 73 | key={platform.id} |
| 74 | platform={platform} |
| 75 | githubIdentityStatus={platform.id === 'github' ? githubIdentityStatus : undefined} |
| 76 | onNavigate={handleNavigate} |
| 77 | /> |
nothing calls this directly
no test coverage detected