The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Prevent client from crashing when new params are added to resource warnings endpoint (#18979)
Joshen Limdb1e1b1690c7
diff --git a/studio/components/interfaces/Home/ProjectList/ProjectCardStatus.tsx b/studio/components/interfaces/Home/ProjectList/ProjectCardStatus.tsxindex bc049891786..0e567e40380 100644--- a/studio/components/interfaces/Home/ProjectList/ProjectCardStatus.tsx+++ b/studio/components/interfaces/Home/ProjectList/ProjectCardStatus.tsx@@ -31,6 +31,10 @@ export const ProjectCardStatus = ({(x) => resourceWarnings?.[x as keyof typeof resourceWarnings] === 'critical')const isCritical = activeWarnings.includes('is_readonly_mode_enabled') || hasCriticalWarning+ const warningContent =+ resourceWarnings !== undefined+ ? getWarningContent(resourceWarnings, activeWarnings[0], 'cardContent')+ : undefinedconst getTitle = () => {if (projectStatus === 'isPaused') return 'Project is paused'@@ -45,7 +49,7 @@ export const ProjectCardStatus = ({? RESOURCE_WARNING_MESSAGES.multiple_resource_warnings.cardContent[hasCriticalWarning ? 'critical' : 'warning'].title- : getWarningContent(resourceWarnings, activeWarnings[0], 'cardContent')?.title+ : warningContent?.title}const getDescription = () => {@@ -61,7 +65,7 @@ export const ProjectCardStatus = ({? RESOURCE_WARNING_MESSAGES.multiple_resource_warnings.cardContent[hasCriticalWarning ? 'critical' : 'warning'].description- : getWarningContent(resourceWarnings, activeWarnings[0], 'cardContent')?.description+ : warningContent?.description}const alertTitle = getTitle()@@ -72,7 +76,12 @@ export const ProjectCardStatus = ({? 'default': 'warning'- if (activeWarnings.length === 0 && projectStatus === 'isHealthy') return null+ if (+ (activeWarnings.length === 0 && projectStatus === 'isHealthy') ||+ warningContent === undefined+ ) {+ return null+ }return (<Alert_Shadcn_diff --git a/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx b/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsxindex 784a3e3b2e6..fc07f656e50 100644--- a/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx+++ b/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx@@ -11,14 +11,12 @@ import {} from 'ui'import { useResourceWarningsQuery } from 'data/usage/resource-warnings-query'-import { useSelectedOrganization } from 'hooks'import { RESOURCE_WARNING_MESSAGES } from './ResourceExhaustionWarningBanner.constants'import { getWarningContent } from './ResourceExhaustionWarningBanner.utils'const ResourceExhaustionWarningBanner = () => {const { ref } = useParams()const router = useRouter()- const organization = useSelectedOrganization()const { data: resourceWarnings } = useResourceWarningsQuery()const projectResourceWarnings = (resourceWarnings ?? [])?.find((warning) => warning.project === ref@@ -45,23 +43,24 @@ const ResourceExhaustionWarningBanner = () => {: falseconst isCritical = activeWarnings.includes('is_readonly_mode_enabled') || hasCriticalWarning+ const warningContent =+ projectResourceWarnings !== undefined+ ? getWarningContent(projectResourceWarnings, activeWarnings[0], 'bannerContent')+ : undefined+const title =activeWarnings.length > 1? RESOURCE_WARNING_MESSAGES.multiple_resource_warnings.bannerContent[hasCriticalWarning ? 'critical' : 'warning'].title- : projectResourceWarnings !== undefined- ? getWarningContent(projectResourceWarnings, activeWarnings[0], 'bannerContent')?.title- : null+ : warningContent?.titleconst description =activeWarnings.length > 1? RESOURCE_WARNING_MESSAGES.multiple_resource_warnings.bannerContent[hasCriticalWarning ? 'critical' : 'warning'].description- : projectResourceWarnings !== undefined- ? getWarningContent(projectResourceWarnings, activeWarnings[0], 'bannerContent')?.description- : null+ : warningContent?.descriptionconst learnMoreUrl =activeWarnings.length > 1@@ -96,6 +95,7 @@ const ResourceExhaustionWarningBanner = () => {// Don't show banner if no warnings, or on usage/infra pageif (activeWarnings.length === 0 ||+ warningContent === undefined ||((router.pathname.endsWith('/usage') || router.pathname.endsWith('/infrastructure')) &&!activeWarnings.includes('is_readonly_mode_enabled')) ||(activeWarnings.includes('is_readonly_mode_enabled') &&diff --git a/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.utils.ts b/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.utils.tsindex 0b3dd8b77e7..8665089241b 100644--- a/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.utils.ts+++ b/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.utils.ts@@ -13,7 +13,7 @@ export const getWarningContent = (const severity = resourceWarnings[metric as keyof typeof resourceWarnings]if (typeof severity !== 'string') return undefined- return RESOURCE_WARNING_MESSAGES[metric as keyof typeof RESOURCE_WARNING_MESSAGES][contentType][- severity as 'warning' | 'critical'- ]+ return RESOURCE_WARNING_MESSAGES[metric as keyof typeof RESOURCE_WARNING_MESSAGES]?.[+ contentType+ ]?.[severity as 'warning' | 'critical']}