CPUWarnings.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 CPUWarningsProps {
  7. hasAccessToComputeSizes: boolean
  8. upgradeUrl: string
  9. severity?: 'warning' | 'critical' | null
  10. }
  11. export const CPUWarnings = ({
  12. hasAccessToComputeSizes,
  13. upgradeUrl,
  14. severity,
  15. }: CPUWarningsProps) => {
  16. if (severity === 'warning') {
  17. return (
  18. <Alert variant="warning">
  19. <AlertCircle />
  20. <AlertTitle>Your max CPU usage has exceeded 80%</AlertTitle>
  21. <AlertDescription>
  22. High CPU usage could result in slower queries, disruption of daily back up routines, and
  23. in rare cases, your instance may become unresponsive. If you need more resources, consider
  24. upgrading to a 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/high-cpu-usage`}>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 max CPU usage has reached 100%</AlertTitle>
  44. <AlertDescription>
  45. High CPU usage could result in slower queries, disruption of daily back up routines, and
  46. in rare cases, your instance may become unresponsive. If you need more resources, consider
  47. upgrading to a 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. }