Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Wrap up updates according to endpoint changes

Joshen Lime0b554a2472d
diff --git a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx
index 2789f1e139b..39c3c24459a 100644
--- a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx
@@ -186,16 +186,14 @@ const Infrastructure = ({
<CPUWarnings
isFreePlan={isFreePlan}
upgradeUrl={upgradeUrl}
- isBeyondThreshold={projectResourceWarnings?.is_cpu_load_beyond_threshold ?? false}
+ severity={projectResourceWarnings?.cpu_exhaustion}
/>
)}
{attribute.key === 'ram_usage' && (
<RAMWarnings
isFreePlan={isFreePlan}
upgradeUrl={upgradeUrl}
- isBeyondThreshold={
- projectResourceWarnings?.is_memory_and_swap_usage_beyond_threshold ?? false
- }
+ severity={projectResourceWarnings?.memory_and_swap_exhaustion}
/>
)}
diff --git a/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/CPUWarnings.tsx b/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/CPUWarnings.tsx
index 818e649f4ac..8a207e12518 100644
--- a/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/CPUWarnings.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/CPUWarnings.tsx
@@ -5,16 +5,11 @@ import { AlertDescription_Shadcn_, Alert_Shadcn_, Button, IconAlertCircle } from
interface CPUWarningsProps {
isFreePlan: boolean
upgradeUrl: string
- isBeyondThreshold: boolean
+ severity?: 'warning' | 'critical' | null
}
-const CPUWarnings = ({ isFreePlan, upgradeUrl, isBeyondThreshold }: CPUWarningsProps) => {
- // [Joshen TODO] Need to implement the necessary conditionals for rendering the warnings once
- // endpoint is updated to return text instead of boolean
- const isApproaching = isBeyondThreshold
- const isExceeded = false
-
- if (isApproaching) {
+const CPUWarnings = ({ isFreePlan, upgradeUrl, severity }: CPUWarningsProps) => {
+ if (severity === 'warning') {
return (
<Alert_Shadcn_ variant="warning">
<IconAlertCircle />
@@ -42,7 +37,7 @@ const CPUWarnings = ({ isFreePlan, upgradeUrl, isBeyondThreshold }: CPUWarningsP
)
}
- if (isExceeded) {
+ if (severity === 'critical') {
return (
<Alert_Shadcn_ variant="destructive">
<IconAlertCircle />
diff --git a/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/RAMWarnings.tsx b/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/RAMWarnings.tsx
index 8006c3d079d..fe233f08695 100644
--- a/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/RAMWarnings.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/UsageWarningAlerts/RAMWarnings.tsx
@@ -5,16 +5,11 @@ import { AlertDescription_Shadcn_, Alert_Shadcn_, Button, IconAlertCircle } from
interface RAMWarningsProps {
isFreePlan: boolean
upgradeUrl: string
- isBeyondThreshold: boolean
+ severity?: 'warning' | 'critical' | null
}
-const RAMWarnings = ({ isFreePlan, upgradeUrl, isBeyondThreshold }: RAMWarningsProps) => {
- // [Joshen TODO] Need to implement the necessary conditionals for rendering the warnings once
- // endpoint is updated to return text instead of boolean
- const isApproaching = isBeyondThreshold
- const isExceeded = false
-
- if (isApproaching) {
+const RAMWarnings = ({ isFreePlan, upgradeUrl, severity }: RAMWarningsProps) => {
+ if (severity === 'warning') {
return (
<Alert_Shadcn_ variant="warning">
<IconAlertCircle />
@@ -42,7 +37,7 @@ const RAMWarnings = ({ isFreePlan, upgradeUrl, isBeyondThreshold }: RAMWarningsP
)
}
- if (isExceeded) {
+ if (severity === 'critical') {
return (
<Alert_Shadcn_ variant="destructive">
<IconAlertCircle />
diff --git a/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx b/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx
index 28e6dce7415..1594655f2da 100644
--- a/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx
+++ b/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx
@@ -308,18 +308,14 @@ const InfrastructureActivity = () => {
<CPUWarnings
isFreePlan={isFreePlan}
upgradeUrl={upgradeUrl}
- isBeyondThreshold={
- projectResourceWarnings?.is_cpu_load_beyond_threshold ?? false
- }
+ severity={projectResourceWarnings?.cpu_exhaustion}
/>
)}
{attribute.key === 'ram_usage' && (
<RAMWarnings
isFreePlan={isFreePlan}
upgradeUrl={upgradeUrl}
- isBeyondThreshold={
- projectResourceWarnings?.is_memory_and_swap_usage_beyond_threshold ?? false
- }
+ severity={projectResourceWarnings?.memory_and_swap_exhaustion}
/>
)}
diff --git a/studio/components/ui/UsageWarnings/UsageWarningBanner.tsx b/studio/components/ui/UsageWarnings/UsageWarningBanner.tsx
index 647882dd84c..19b7fd6e1d8 100644
--- a/studio/components/ui/UsageWarnings/UsageWarningBanner.tsx
+++ b/studio/components/ui/UsageWarnings/UsageWarningBanner.tsx
@@ -100,8 +100,8 @@ const UsageWarningBanner = () => {
// Don't show banner if no warnings, or on usage/infra page
if (
activeWarnings.length === 0 ||
- router.pathname.endsWith('/usage') ||
- router.pathname.endsWith('/infrastructure')
+ ((router.pathname.endsWith('/usage') || router.pathname.endsWith('/infrastructure')) &&
+ !activeWarnings.includes('is_readonly_mode_enabled'))
)
return null
diff --git a/studio/data/usage/resource-warnings-query.ts b/studio/data/usage/resource-warnings-query.ts
index 7249b41e989..d7ecd7c350e 100644
--- a/studio/data/usage/resource-warnings-query.ts
+++ b/studio/data/usage/resource-warnings-query.ts
@@ -8,25 +8,6 @@ import { components } from 'data/api'
export async function getResourceWarnings(signal?: AbortSignal) {
const { data, error } = await get(`/platform/projects-resource-warnings`, { signal })
if (error) throw error
-
- return [
- {
- project: 'iqixcyokaezexqncgirb',
- is_readonly_mode_enabled: false,
- disk_io_exhaustion: null,
- disk_space_exhaustion: null,
- cpu_exhaustion: null,
- memory_and_swap_exhaustion: null,
- },
- {
- project: 'yhkgeeesimzjzbigwxwv',
- is_readonly_mode_enabled: false,
- disk_io_exhaustion: null,
- disk_space_exhaustion: null,
- cpu_exhaustion: 'critical',
- memory_and_swap_exhaustion: null,
- },
- ] as ResourceWarning[]
return data
}
diff --git a/studio/pages/projects.tsx b/studio/pages/projects.tsx
index 909a567dad3..c7e183eced8 100644
--- a/studio/pages/projects.tsx
+++ b/studio/pages/projects.tsx
@@ -48,7 +48,7 @@ const ProjectsPage: NextPageWithLayout = () => {
</div>
)}
- {true && (
+ {isError && (
<div
className={`py-4 px-5 ${navLayoutV2 ? 'h-full flex items-center justify-center' : ''}`}
>