RAMWarnings.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { AlertTitle } from '@ui/components/shadcn/ui/alert'
  2. import { AlertCircle } from 'lucide-react'
  3. import Link from 'next/link'
  4. import { Alert, AlertDescription, Button } from 'ui'
  5. import { DOCS_URL } from '@/lib/constants'
  6. interface RAMWarningsProps {
  7. hasAccessToComputeSizes: boolean
  8. upgradeUrl: string
  9. severity?: 'warning' | 'critical' | null
  10. }
  11. export const RAMWarnings = ({
  12. hasAccessToComputeSizes,
  13. upgradeUrl,
  14. severity,
  15. }: RAMWarningsProps) => {
  16. if (severity === 'warning') {
  17. return (
  18. <Alert variant="warning">
  19. <AlertCircle />
  20. <AlertTitle>Your memory usage has exceeded 80%</AlertTitle>
  21. <AlertDescription>
  22. High memory usage could result in overall degraded performance, and in rare cases, your
  23. instance may become unresponsive. If you need more resources, consider upgrading to a
  24. larger compute add-on.
  25. </AlertDescription>
  26. <div className="mt-3 flex items-center space-x-2">
  27. <Button asChild type="default">
  28. <Link href={`${DOCS_URL}/guides/troubleshooting/exhaust-ram`}>Learn more</Link>
  29. </Button>
  30. <Button asChild type="warning">
  31. <Link href={upgradeUrl}>
  32. {hasAccessToComputeSizes ? 'Change compute add-on' : 'Upgrade project'}
  33. </Link>
  34. </Button>
  35. </div>
  36. </Alert>
  37. )
  38. }
  39. if (severity === 'critical') {
  40. return (
  41. <Alert variant="destructive">
  42. <AlertCircle />
  43. <AlertTitle>Your memory usage has reached 100%</AlertTitle>
  44. <AlertDescription>
  45. High memory usage could result in overall degraded performance, and in rare cases, your
  46. instance may become unresponsive. If you need more resources, consider upgrading to a
  47. larger compute add-on.
  48. </AlertDescription>
  49. <div className="mt-3 flex items-center space-x-2">
  50. <Button asChild type="default">
  51. <Link href={`${DOCS_URL}/guides/troubleshooting/high-cpu-usage`}>Learn more</Link>
  52. </Button>
  53. <Button asChild type="danger">
  54. <Link href={upgradeUrl}>
  55. {hasAccessToComputeSizes ? 'Change compute add-on' : 'Upgrade project'}
  56. </Link>
  57. </Button>
  58. </div>
  59. </Alert>
  60. )
  61. }
  62. return null
  63. }