Skip to content

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

Update hasAccessToBranching to check opt in tags

Joshen Lim59c67d289b64
diff --git a/studio/components/interfaces/BranchManagement/BranchManagement.tsx b/studio/components/interfaces/BranchManagement/BranchManagement.tsx
index 3936a1f7917..e7380832d15 100644
--- a/studio/components/interfaces/BranchManagement/BranchManagement.tsx
+++ b/studio/components/interfaces/BranchManagement/BranchManagement.tsx
@@ -39,8 +39,8 @@ const BranchManagement = () => {
const projectDetails = useSelectedProject()
const selectedOrg = useSelectedOrganization()
- // [Joshen TODO] To be dynamic
- const isBranchingAllowed = true
+ const hasAccessToBranching =
+ selectedOrg?.opt_in_tags?.includes('PREVIEW_BRANCHES_OPT_IN') ?? false
const isBranch = projectDetails?.parent_project_ref !== undefined
const hasBranchEnabled = projectDetails?.is_branch_enabled
@@ -122,11 +122,11 @@ const BranchManagement = () => {
return (
<ProductEmptyState title="Database Branching">
<p className="text-sm text-light">
- {isBranchingAllowed
+ {hasAccessToBranching
? 'Create preview branches to experiment changes to your database schema in a safe, non-destructible environment.'
: "Register for early access and you'll be contacted by email when your organization is enrolled in database branching."}
</p>
- {isBranchingAllowed ? (
+ {hasAccessToBranching ? (
<div className="!mt-4">
<Button
icon={<IconGitBranch strokeWidth={1.5} />}
diff --git a/studio/components/layouts/AppLayout/AppHeader.tsx b/studio/components/layouts/AppLayout/AppHeader.tsx
index dfa8b1950f1..5aad1f9f248 100644
--- a/studio/components/layouts/AppLayout/AppHeader.tsx
+++ b/studio/components/layouts/AppLayout/AppHeader.tsx
@@ -20,7 +20,7 @@ const AppHeader = () => {
const organization = useSelectedOrganization()
const enableBranchManagement = useFlag('branchManagement')
- const isBranchingAllowed = project?.cloud_provider === 'FLY'
+ const isBranchingSupported = project?.cloud_provider === 'FLY'
const isBranchingEnabled =
project?.is_branch_enabled === true || project?.parent_project_ref !== undefined
@@ -38,7 +38,7 @@ const AppHeader = () => {
</Link>
<OrganizationDropdown />
{ref !== undefined && <ProjectDropdown />}
- {ref !== undefined && isBranchingAllowed && enableBranchManagement && (
+ {ref !== undefined && isBranchingSupported && enableBranchManagement && (
<>{isBranchingEnabled ? <BranchDropdown /> : <EnableBranchingButton />}</>
)}
</div>
diff --git a/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingButton.tsx b/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingButton.tsx
index f86e96b19b1..7d0e54ed9ab 100644
--- a/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingButton.tsx
+++ b/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingButton.tsx
@@ -43,8 +43,8 @@ const EnableBranchingButton = () => {
},
})
- // [Joshen TODO] To be dynamic
- const isBranchingAllowed = true
+ const hasAccessToBranching =
+ selectedOrg?.opt_in_tags?.includes('PREVIEW_BRANCHES_OPT_IN') ?? false
const githubIntegration = integrations?.find(
(integration) =>
@@ -66,7 +66,7 @@ const EnableBranchingButton = () => {
createBranch({ projectRef: ref, branchName: selectedBranch, gitBranch: selectedBranch })
}
- if (!isBranchingAllowed) {
+ if (!hasAccessToBranching) {
return <BranchingWaitlistPopover />
}