DiskIOBandwidthWarnings.tsx118 lines · main
1import Link from 'next/link'
2import { Button } from 'ui'
3import { Admonition } from 'ui-patterns'
4
5// [Joshen] In the future, conditionals should be from resource exhaustion endpoint as single source of truth
6interface DiskIOBandwidthWarningsProps {
7 hasAccessToComputeSizes: boolean
8 hasLatest: boolean
9 upgradeUrl: string
10 currentBillingCycleSelected: boolean
11 latestIoBudgetConsumption: number
12 highestIoBudgetConsumption: number
13}
14
15export const DiskIOBandwidthWarnings = ({
16 hasAccessToComputeSizes,
17 hasLatest,
18 currentBillingCycleSelected,
19 upgradeUrl,
20 latestIoBudgetConsumption,
21 highestIoBudgetConsumption,
22}: DiskIOBandwidthWarningsProps) => {
23 if (hasLatest && latestIoBudgetConsumption >= 100) {
24 return (
25 <Admonition
26 type="destructive"
27 title="Your Disk IO Budget has been used up"
28 description={
29 <>
30 <p className="mb-4">
31 Your workload has used up all your Disk IO Budget and is now running at the baseline
32 performance. If you need consistent disk performance, consider upgrading to a larger
33 compute add-on.
34 </p>
35 <Button asChild type="danger">
36 <Link href={upgradeUrl}>
37 {hasAccessToComputeSizes ? 'Change compute add-on' : 'Upgrade project'}
38 </Link>
39 </Button>
40 </>
41 }
42 />
43 )
44 }
45
46 if (hasLatest && latestIoBudgetConsumption >= 80) {
47 return (
48 <Admonition
49 type="destructive"
50 title="You are close to running out of Disk IO Budget"
51 description={
52 <>
53 <p className="mb-4">
54 Your workload has consumed {latestIoBudgetConsumption}% of your Disk IO Budget. If you
55 use up all your Disk IO Budget, your instance will reverted to baseline performance.
56 If you need consistent disk performance, consider upgrading to a larger compute
57 add-on.
58 </p>
59 <Button asChild type="danger">
60 <Link href={upgradeUrl}>
61 {hasAccessToComputeSizes ? 'Change compute add-on' : 'Upgrade project'}
62 </Link>
63 </Button>
64 </>
65 }
66 />
67 )
68 }
69
70 if (currentBillingCycleSelected && highestIoBudgetConsumption >= 100) {
71 return (
72 <Admonition
73 type="warning"
74 title="You ran out of IO Budget at least once"
75 description={
76 <>
77 <p className="mb-4">
78 Your workload has used up all your Disk IO Budget and reverted to baseline performance
79 at least once during this billing cycle. If you need consistent disk performance,
80 consider upgrading to a larger compute add-on.
81 </p>
82 <Button asChild type="warning">
83 <Link href={upgradeUrl}>
84 {hasAccessToComputeSizes ? 'Change compute add-on' : 'Upgrade project'}
85 </Link>
86 </Button>
87 </>
88 }
89 />
90 )
91 }
92
93 if (currentBillingCycleSelected && highestIoBudgetConsumption >= 80) {
94 return (
95 <Admonition
96 type="warning"
97 title="You were close to using all your IO Budget at least once"
98 description={
99 <>
100 <p className="mb-4">
101 Your workload has consumed {highestIoBudgetConsumption}% of your Disk IO budget during
102 this billing cycle. If you use up all your Disk IO Budget, your instance will reverted
103 to baseline performance. If you need consistent disk performance, consider upgrading
104 to a larger compute add-on.
105 </p>
106 <Button asChild type="warning">
107 <Link href={upgradeUrl}>
108 {hasAccessToComputeSizes ? 'Change compute add-on' : 'Upgrade project'}
109 </Link>
110 </Button>
111 </>
112 }
113 />
114 )
115 }
116
117 return null
118}