ProjectRowLink.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { ParsedUrlQuery } from 'querystring'
  2. import { Check } from 'lucide-react'
  3. import Link from 'next/link'
  4. import { Badge, cn } from 'ui'
  5. import { sanitizeRoute } from './ProjectDropdown.utils'
  6. import PartnerIcon from '@/components/ui/PartnerIcon'
  7. import { getManagedByFromOrganizationPartner } from '@/data/organizations/managed-by-utils'
  8. export interface ProjectRowLinkProps {
  9. project: {
  10. ref: string
  11. name: string
  12. status?: string
  13. integration_source?: string | null
  14. }
  15. selectedRef: string | undefined
  16. route: string
  17. routerQueries: ParsedUrlQuery
  18. }
  19. export function ProjectRowLink({
  20. project,
  21. selectedRef,
  22. route,
  23. routerQueries,
  24. }: ProjectRowLinkProps) {
  25. const sanitizedRoute = sanitizeRoute(route, routerQueries)
  26. const href = sanitizedRoute?.replace('[ref]', project.ref) ?? `/project/${project.ref}`
  27. const isSelected = project.ref === selectedRef
  28. const isPaused = project.status === 'INACTIVE'
  29. const managedBy = getManagedByFromOrganizationPartner(undefined, project.integration_source)
  30. return (
  31. <Link
  32. href={href}
  33. className="w-full flex items-center justify-between p-0.5 md:p-0 text-sm md:text-xs"
  34. >
  35. <span
  36. className={cn(
  37. 'flex items-center gap-2 min-w-0',
  38. isSelected ? 'md:max-w-60' : 'md:max-w-64'
  39. )}
  40. >
  41. <span className="truncate">{project.name}</span>
  42. {isPaused && <Badge className="ml-2">Paused</Badge>}
  43. <PartnerIcon organization={{ managed_by: managedBy }} />
  44. </span>
  45. {isSelected && <Check size={16} />}
  46. </Link>
  47. )
  48. }