Skip to content

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

Add feature flag, and ensure that banner shows up in all ProjectLayout

Joshen Limf134966bbd40
diff --git a/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx b/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
index 6c70c5ced6b..68817113fd7 100644
--- a/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
+++ b/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
@@ -13,6 +13,7 @@ import { Project } from 'types'
import { IntegrationProjectConnection } from 'data/integrations/integrations.types'
import { ResourceWarning } from 'data/usage/resource-warnings-query'
import ProjectCardWarnings from './ProjectCardWarnings'
+import { useFlag } from 'hooks'
export interface ProjectCardProps {
project: Project
@@ -32,6 +33,8 @@ const ProjectCard = ({
const { name, ref: projectRef } = project
const desc = `${project.cloud_provider} | ${project.region}`
+ const showResourceExhaustionWarnings = useFlag('resourceExhaustionWarnings')
+
const isBranchingEnabled = project.preview_branch_refs.length > 0
const isGithubIntegrated = githubIntegration !== undefined
const isVercelIntegrated = vercelIntegration !== undefined
@@ -118,7 +121,7 @@ const ProjectCard = ({
</div>
}
>
- {resourceWarnings ? (
+ {showResourceExhaustionWarnings && resourceWarnings ? (
<ProjectCardWarnings resourceWarnings={resourceWarnings} />
) : (
<div className="py-2" />
diff --git a/studio/components/layouts/ProjectLayout/ProjectLayout.tsx b/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
index adeba22da72..f314cb4aae9 100644
--- a/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
+++ b/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
@@ -4,7 +4,7 @@ import { Fragment, PropsWithChildren, ReactNode } from 'react'
import { useParams } from 'common/hooks'
import Connecting from 'components/ui/Loading'
-import UsageWarningBanner from 'components/ui/UsageWarnings/UsageWarningBanner'
+import ResourceExhaustionWarningBanner from 'components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner'
import { useFlag, useSelectedOrganization, useSelectedProject, withAuth } from 'hooks'
import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'
import AppLayout from '../AppLayout/AppLayout'
@@ -69,6 +69,7 @@ const ProjectLayout = ({
const organizationName = selectedOrganization?.name
const navLayoutV2 = useFlag('navigationLayoutV2')
+ const showResourceExhaustionWarnings = useFlag('resourceExhaustionWarnings')
const isPaused = selectedProject?.status === PROJECT_STATUS.INACTIVE
const ignorePausedState =
@@ -110,7 +111,10 @@ const ProjectLayout = ({
</div>
</div>
) : (
- <ContentWrapper isLoading={isLoading}>{children}</ContentWrapper>
+ <ContentWrapper isLoading={isLoading}>
+ {showResourceExhaustionWarnings && <ResourceExhaustionWarningBanner />}
+ {children}
+ </ContentWrapper>
)}
</main>
</div>
@@ -193,10 +197,7 @@ const ContentWrapper = ({ isLoading, children }: ContentWrapperProps) => {
) : requiresDbConnection && isProjectBuilding ? (
<BuildingState />
) : (
- <>
- <UsageWarningBanner />
- <Fragment key={selectedProject?.ref}>{children}</Fragment>
- </>
+ <Fragment key={selectedProject?.ref}>{children}</Fragment>
)}
</>
)
@@ -224,6 +225,7 @@ export const ProjectLayoutNonBlocking = ({
const showPausedState = isPaused && !ignorePausedState
const navLayoutV2 = useFlag('navigationLayoutV2')
+ const showResourceExhaustionWarnings = useFlag('resourceExhaustionWarnings')
return (
<AppLayout>
@@ -251,7 +253,10 @@ export const ProjectLayoutNonBlocking = ({
</div>
</div>
) : (
- children
+ <>
+ {showResourceExhaustionWarnings && <ResourceExhaustionWarningBanner />}
+ {children}
+ </>
)}
</main>
</div>
diff --git a/studio/components/ui/UsageWarnings/UsageWarningBanner.constants.ts b/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.constants.ts
similarity index 100%
rename from studio/components/ui/UsageWarnings/UsageWarningBanner.constants.ts
rename to studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.constants.ts
diff --git a/studio/components/ui/UsageWarnings/UsageWarningBanner.tsx b/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx
similarity index 96%
rename from studio/components/ui/UsageWarnings/UsageWarningBanner.tsx
rename to studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx
index e058b084801..76a9dd279db 100644
--- a/studio/components/ui/UsageWarnings/UsageWarningBanner.tsx
+++ b/studio/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner.tsx
@@ -12,9 +12,9 @@ import {
import { useResourceWarningsQuery } from 'data/usage/resource-warnings-query'
import { useSelectedOrganization } from 'hooks'
-import { RESOURCE_WARNING_MESSAGES } from './UsageWarningBanner.constants'
+import { RESOURCE_WARNING_MESSAGES } from './ResourceExhaustionWarningBanner.constants'
-const UsageWarningBanner = () => {
+const ResourceExhaustionWarningBanner = () => {
const { ref } = useParams()
const router = useRouter()
const organization = useSelectedOrganization()
@@ -137,4 +137,4 @@ const UsageWarningBanner = () => {
)
}
-export default UsageWarningBanner
+export default ResourceExhaustionWarningBanner