ErrorDetailsDialog.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import {
  2. Button,
  3. cn,
  4. Dialog,
  5. DialogClose,
  6. DialogContent,
  7. DialogFooter,
  8. DialogHeader,
  9. DialogSection,
  10. DialogSectionSeparator,
  11. DialogTitle,
  12. } from 'ui'
  13. import { CodeBlock } from 'ui-patterns/CodeBlock'
  14. interface ErrorDetailsDialogProps {
  15. open: boolean
  16. onOpenChange: (open: boolean) => void
  17. tableName: string
  18. reason: string
  19. solution?: string
  20. }
  21. export const ErrorDetailsDialog = ({
  22. open,
  23. onOpenChange,
  24. tableName,
  25. reason,
  26. solution,
  27. }: ErrorDetailsDialogProps) => {
  28. return (
  29. <Dialog open={open} onOpenChange={onOpenChange}>
  30. <DialogContent size="xlarge" aria-describedby={undefined}>
  31. <DialogHeader>
  32. <DialogTitle>
  33. Replication error on <code className="text-code-inline">{tableName}</code>
  34. </DialogTitle>
  35. </DialogHeader>
  36. <DialogSectionSeparator />
  37. <DialogSection className="p-0!">
  38. <div className="px-4 py-3">
  39. <p className="text-sm text-foreground-light">
  40. The following error occurred during replication:
  41. </p>
  42. </div>
  43. <CodeBlock
  44. hideLineNumbers
  45. wrapLines={false}
  46. wrapperClassName={cn(
  47. '[&_pre]:px-4 [&_pre]:py-3 [&>pre]:border-x-0 [&>pre]:rounded-none'
  48. )}
  49. language="bash"
  50. value={reason}
  51. className="[&_code]:text-xs [&_code]:text-foreground [&_span]:text-foreground!"
  52. />
  53. {solution && (
  54. <div className="px-4 py-3">
  55. <p className="text-sm">{solution}</p>
  56. </div>
  57. )}
  58. </DialogSection>
  59. <DialogFooter>
  60. <DialogClose>
  61. <Button type="default">Close</Button>
  62. </DialogClose>
  63. </DialogFooter>
  64. </DialogContent>
  65. </Dialog>
  66. )
  67. }