AWSPrivateLinkAccountItem.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { Edit, MoreVertical, Trash } from 'lucide-react'
  2. import {
  3. Badge,
  4. Button,
  5. CardContent,
  6. DropdownMenu,
  7. DropdownMenuContent,
  8. DropdownMenuItem,
  9. DropdownMenuSeparator,
  10. DropdownMenuTrigger,
  11. } from 'ui'
  12. interface AWSPrivateLinkAccountItemProps {
  13. aws_account_id: string
  14. account_name?: string
  15. status:
  16. | 'CREATING'
  17. | 'READY'
  18. | 'ASSOCIATION_REQUEST_EXPIRED'
  19. | 'ASSOCIATION_ACCEPTED'
  20. | 'CREATION_FAILED'
  21. | 'DELETING'
  22. shared_at: string | null
  23. onEdit: () => void
  24. onDelete: () => void
  25. }
  26. export const AWSPrivateLinkAccountItem = ({
  27. aws_account_id,
  28. account_name,
  29. status,
  30. onEdit,
  31. onDelete,
  32. }: AWSPrivateLinkAccountItemProps) => {
  33. const getStatusBadge = () => {
  34. switch (status) {
  35. case 'ASSOCIATION_ACCEPTED':
  36. return <Badge variant="success">Connected</Badge>
  37. case 'READY':
  38. return <Badge variant="success">Ready</Badge>
  39. case 'CREATING':
  40. return <Badge variant="warning">Creating</Badge>
  41. case 'DELETING':
  42. return <Badge variant="destructive">Deleting</Badge>
  43. case 'ASSOCIATION_REQUEST_EXPIRED':
  44. return <Badge variant="destructive">Expired</Badge>
  45. case 'CREATION_FAILED':
  46. return <Badge variant="destructive">Failed</Badge>
  47. default:
  48. return <Badge>Unknown</Badge>
  49. }
  50. }
  51. return (
  52. <CardContent className="flex items-center justify-between text-sm gap-4">
  53. <div className="flex-1">
  54. <div>{aws_account_id}</div>
  55. <div className="text-sm text-foreground-lighter">{account_name || 'No description'}</div>
  56. </div>
  57. {getStatusBadge()}
  58. <DropdownMenu>
  59. <DropdownMenuTrigger asChild>
  60. <Button type="text" className="px-1" icon={<MoreVertical />} />
  61. </DropdownMenuTrigger>
  62. <DropdownMenuContent align="end" className="w-40">
  63. <DropdownMenuItem onClick={onEdit} className="gap-x-2">
  64. <Edit size={14} />
  65. <span>View account</span>
  66. </DropdownMenuItem>
  67. <DropdownMenuSeparator />
  68. <DropdownMenuItem onClick={onDelete} className="gap-x-2">
  69. <Trash size={14} />
  70. <span>Delete account</span>
  71. </DropdownMenuItem>
  72. </DropdownMenuContent>
  73. </DropdownMenu>
  74. </CardContent>
  75. )
  76. }