Skip to content

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

chore: Revert "Update GH integration in project settings (#44008)" (#44142)

Ivan Vasilov6f36043111cf
diff --git a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx
index 2d1208afb45..1d9d98afe9d 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx
@@ -1,6 +1,6 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { InlineLink } from 'components/ui/InlineLink'
+import { IS_PLATFORM } from 'common'
import { useBranchCreateMutation } from 'data/branches/branch-create-mutation'
import { useBranchUpdateMutation } from 'data/branches/branch-update-mutation'
import { useBranchesQuery } from 'data/branches/branches-query'
@@ -11,7 +11,6 @@ import { useGitHubConnectionDeleteMutation } from 'data/integrations/github-conn
import { useGitHubConnectionUpdateMutation } from 'data/integrations/github-connection-update-mutation'
import { useGitHubRepositoriesQuery } from 'data/integrations/github-repositories-query'
import type { GitHubConnection } from 'data/integrations/integrations.types'
-import { AnimatePresence, motion } from 'framer-motion'
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
@@ -23,6 +22,9 @@ import { useEffect, useMemo, useState } from 'react'
import { useForm } from 'react-hook-form'
import { toast } from 'sonner'
import {
+ Alert_Shadcn_,
+ AlertDescription_Shadcn_,
+ AlertTitle_Shadcn_,
Button,
Card,
CardContent,
@@ -44,12 +46,10 @@ import {
PopoverTrigger_Shadcn_,
Switch,
} from 'ui'
-import { Admonition } from 'ui-patterns'
+import { InlineLink } from 'components/ui/InlineLink'
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import * as z from 'zod'
-
-import { UpgradeToPro } from '@/components/ui/UpgradeToPro'
import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
const GITHUB_ICON = (
@@ -65,10 +65,12 @@ const GITHUB_ICON = (
)
interface GitHubIntegrationConnectionFormProps {
+ disabled?: boolean
connection?: GitHubConnection
}
-export const GitHubIntegrationConnectionForm = ({
+const GitHubIntegrationConnectionForm = ({
+ disabled = false,
connection,
}: GitHubIntegrationConnectionFormProps) => {
const { data: selectedProject } = useSelectedProjectQuery()
@@ -80,8 +82,8 @@ export const GitHubIntegrationConnectionForm = ({
const { hasAccess: hasAccessToGitHubIntegration, isLoading: isLoadingEntitlements } =
useCheckEntitlements('integrations.github_connections')
-
- const { hasAccess: hasAccessToBranching } = useCheckEntitlements('branching_limit')
+ const promptProPlanUpgrade =
+ IS_PLATFORM && !isLoadingEntitlements && !hasAccessToGitHubIntegration
const { can: canUpdateGitHubConnection } = useAsyncCheckPermissions(
PermissionAction.UPDATE,
@@ -458,7 +460,7 @@ export const GitHubIntegrationConnectionForm = ({
<Button
type="default"
className="justify-start h-[34px] w-full"
- disabled={isLoadingGitHubRepos}
+ disabled={disabled || isLoadingGitHubRepos}
loading={isLoadingGitHubRepos}
icon={
<div className="bg-black shadow rounded p-1 w-6 h-6 flex justify-center items-center">
@@ -551,244 +553,213 @@ export const GitHubIntegrationConnectionForm = ({
)}
/>
</CardContent>
-
- <AnimatePresence>
- {!!currentRepositoryId && (
- <motion.div
- initial={{ opacity: 0, y: -16 }}
- animate={{ opacity: 1, y: 0 }}
- exit={{ opacity: 0, y: -16 }}
+ <CardContent className={cn(!currentRepositoryId && 'opacity-25 pointer-events-none')}>
+ <FormField_Shadcn_
+ control={githubSettingsForm.control}
+ name="supabaseDirectory"
+ render={({ field }) => (
+ <FormItemLayout
+ layout="flex-row-reverse"
+ label="Working directory"
+ description="Path to working directory with your supabase folder"
+ >
+ <FormControl_Shadcn_>
+ <Input_Shadcn_
+ {...field}
+ placeholder="supabase"
+ autoComplete="off"
+ disabled={disabled || !canUpdateGitHubConnection}
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </CardContent>
+ <CardContent className={cn(!currentRepositoryId && 'opacity-25 pointer-events-none')}>
+ {/* Production Branch Sync Section */}
+ <div className="space-y-4">
+ <FormField_Shadcn_
+ control={githubSettingsForm.control}
+ name="enableProductionSync"
+ render={({ field }) => (
+ <FormItemLayout
+ layout="flex-row-reverse"
+ label="Deploy to production"
+ description="Deploy changes to production on push including PR merges"
+ >
+ <FormControl_Shadcn_>
+ <Switch
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ disabled={disabled || !canUpdateGitHubConnection}
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+
+ <div
+ className={cn(
+ 'space-y-4 pl-6 border-l',
+ (!enableProductionSync || disabled) && 'opacity-25 pointer-events-none'
+ )}
>
- <CardContent>
- <FormField_Shadcn_
- control={githubSettingsForm.control}
- name="supabaseDirectory"
- render={({ field }) => (
- <FormItemLayout
- layout="flex-row-reverse"
- label="Working directory"
- description="Path to working directory with your supabase folder"
- >
+ <FormField_Shadcn_
+ control={githubSettingsForm.control}
+ name="branchName"
+ render={({ field }) => (
+ <FormItemLayout
+ layout="flex-row-reverse"
+ label="Production branch name"
+ description="The GitHub branch to sync with your production database (e.g., main, master)"
+ >
+ <div className="relative w-full">
<FormControl_Shadcn_>
<Input_Shadcn_
{...field}
- placeholder="supabase"
autoComplete="off"
- disabled={!canUpdateGitHubConnection}
+ disabled={
+ disabled || !canUpdateGitHubConnection || !enableProductionSync
+ }
/>
</FormControl_Shadcn_>
- </FormItemLayout>
- )}
- />
- </CardContent>
- <CardContent>
- {/* Production Branch Sync Section */}
- <div className="space-y-4">
- <FormField_Shadcn_
- control={githubSettingsForm.control}
- name="enableProductionSync"
- render={({ field }) => (
- <FormItemLayout
- layout="flex-row-reverse"
- label="Deploy to production"
- description="Deploy changes to production on push including PR merges"
- >
- <FormControl_Shadcn_>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- disabled={!canUpdateGitHubConnection}
- />
- </FormControl_Shadcn_>
- </FormItemLayout>
- )}
- />
-
- <div
- className={cn(
- 'space-y-4 pl-6 border-l',
- !enableProductionSync && 'opacity-25 pointer-events-none'
- )}
- >
- <FormField_Shadcn_
- control={githubSettingsForm.control}
- name="branchName"
- render={({ field }) => (
- <FormItemLayout
- layout="flex-row-reverse"
- label="Production branch name"
- description="The GitHub branch to sync with your production database (e.g., main, master)"
- >
- <div className="relative w-full">
- <FormControl_Shadcn_>
- <Input_Shadcn_
- {...field}
- autoComplete="off"
- disabled={!canUpdateGitHubConnection || !enableProductionSync}
- />
- </FormControl_Shadcn_>
- <div className="absolute top-2.5 right-3 flex items-center gap-2">
- {isCheckingBranch && (
- <Loader2 size={14} className="animate-spin" />
- )}
- </div>
- </div>
- </FormItemLayout>
- )}
- />
- </div>
- </div>
- </CardContent>
- <CardContent>
- {hasAccessToBranching ? (
- <Admonition type="warning" title="Branching and billing" className="mb-4">
- Branching Compute is not covered by your organization&apos;s Spend Cap.
- Costs should be closely monitored, as they may be incurred.{' '}
- <InlineLink
- href={`${DOCS_URL}/guides/platform/cost-control#usage-items-not-covered-by-the-spend-cap`}
- >
- Learn more
- </InlineLink>
- </Admonition>
- ) : (
- <UpgradeToPro
- className="mb-4"
- layout="vertical"
- source="projectIntegrations"
- featureProposition="automatically create preview branches from pull requests"
- primaryText="Branching with GitHub integration"
- secondaryText="Upgrade to the Pro Plan to enable branching and automatically create preview branches for every pull request"
- docsUrl={`${DOCS_URL}/guides/deployment/branching`}
- />
+ <div className="absolute top-2.5 right-3 flex items-center gap-2">
+ {isCheckingBranch && <Loader2 size={14} className="animate-spin" />}
+ </div>
+ </div>
+ </FormItemLayout>
)}
-
- {/* Automatic Branching Section */}
- <div className="space-y-4">
- <FormField_Shadcn_
- disabled={!hasAccessToBranching}
- control={githubSettingsForm.control}
- name="new_branch_per_pr"
- render={({ field }) => (
- <FormItemLayout
- layout="flex-row-reverse"
- label="Automatic branching"
- className={cn(!hasAccessToBranching && 'opacity-25')}
- description="Create preview branches for every pull request"
- >
- <FormControl_Shadcn_>
- <Switch
- checked={!hasAccessToBranching ? false : field.value}
- onCheckedChange={field.onChange}
- disabled={!hasAccessToBranching || !canCreateGitHubConnection}
- />
- </FormControl_Shadcn_>
- </FormItemLayout>
- )}
- />
-
- <div
- className={cn(
- 'space-y-4 pl-6 border-l',
- (!hasAccessToBranching || !newBranchPerPr) &&
- 'opacity-25 pointer-events-none'
- )}
- >
- <FormField_Shadcn_
- control={githubSettingsForm.control}
- name="branchLimit"
- render={({ field }) => (
- <FormItemLayout
- layout="flex-row-reverse"
- label="Branch limit"
- description="Maximum number of preview branches"
- >
- <FormControl_Shadcn_>
- <Input_Shadcn_
- {...field}
- type="number"
- autoComplete="off"
- value={!hasAccessToBranching ? 0 : field.value}
- disabled={
- !hasAccessToBranching ||
- !newBranchPerPr ||
- !canUpdateGitHubConnection
- }
- />
- </FormControl_Shadcn_>
- </FormItemLayout>
- )}
- />
-
- <FormField_Shadcn_
- control={githubSettingsForm.control}
- name="supabaseChangesOnly"
- render={({ field }) => (
- <FormItemLayout
- layout="flex-row-reverse"
- label="Supabase changes only"
- description="Only create branches when Supabase files change"
- >
- <FormControl_Shadcn_>
- <Switch
- checked={!hasAccessToBranching ? false : field.value}
- onCheckedChange={(val) => field.onChange(val)}
- disabled={
- !hasAccessToBranching ||
- !newBranchPerPr ||
- !canUpdateGitHubConnection
- }
- />
- </FormControl_Shadcn_>
- </FormItemLayout>
- )}
+ />
+ </div>
+ </div>
+ </CardContent>
+ <CardContent className={cn(!currentRepositoryId && 'opacity-25 pointer-events-none')}>
+ <Alert_Shadcn_ variant="warning" className="mb-4">
+ <AlertTitle_Shadcn_>Branching and billing</AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ Branching Compute is not covered by your organization&apos;s Spend Cap. Costs
+ should be closely monitored, as they may be incurred.{' '}
+ <InlineLink
+ href={`${DOCS_URL}/guides/platform/cost-control#usage-items-not-covered-by-the-spend-cap`}
+ >
+ Learn more
+ </InlineLink>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ {/* Automatic Branching Section */}
+ <div className="space-y-4">
+ <FormField_Shadcn_
+ control={githubSettingsForm.control}
+ name="new_branch_per_pr"
+ render={({ field }) => (
+ <FormItemLayout
+ layout="flex-row-reverse"
+ label="Automatic branching"
+ description="Create preview branches for every pull request"
+ >
+ <FormControl_Shadcn_>
+ <Switch
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ disabled={disabled || !canCreateGitHubConnection}
/>
- </div>
- </div>
- </CardContent>
- <CardFooter className="flex justify-between items-center">
- <div>
- {connection && (
- <Button
- type="outline"
- onClick={handleRemoveIntegration}
- disabled={isDeletingConnection}
- loading={isDeletingConnection}
- >
- Disable integration
- </Button>
- )}
- </div>
- <div className="flex space-x-2">
- {githubSettingsForm.formState.isDirty && (
- <Button
- type="default"
- onClick={() => githubSettingsForm.reset()}
- disabled={!canUpdateGitHubConnection}
- >
- Cancel
- </Button>
- )}
- <Button
- type="default"
- htmlType="submit"
- disabled={
- !hasAccessToGitHubIntegration ||
- (!connection && !canCreateGitHubConnection) ||
- (connection && !canUpdateGitHubConnection) ||
- isCheckingBranch ||
- isLoading ||
- (!connection && !githubSettingsForm.getValues().repositoryId) ||
- (connection && !githubSettingsForm.formState.isDirty)
- }
- loading={isCheckingBranch || isLoading}
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+
+ <div
+ className={cn(
+ 'space-y-4 pl-6 border-l',
+ (!newBranchPerPr || disabled) && 'opacity-25 pointer-events-none'
+ )}
+ >
+ <FormField_Shadcn_
+ control={githubSettingsForm.control}
+ name="branchLimit"
+ render={({ field }) => (
+ <FormItemLayout
+ layout="flex-row-reverse"
+ label="Branch limit"
+ description="Maximum number of preview branches"
+ >
+ <FormControl_Shadcn_>
+ <Input_Shadcn_
+ {...field}
+ type="number"
+ autoComplete="off"
+ disabled={!newBranchPerPr || disabled || !canUpdateGitHubConnection}
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+
+ <FormField_Shadcn_
+ control={githubSettingsForm.control}
+ name="supabaseChangesOnly"
+ render={({ field }) => (
+ <FormItemLayout
+ layout="flex-row-reverse"
+ label="Supabase changes only"
+ description="Only create branches when Supabase files change"
>
- {connection ? 'Save changes' : 'Enable integration'}
- </Button>
- </div>
- </CardFooter>
- </motion.div>
- )}
- </AnimatePresence>
+ <FormControl_Shadcn_>
+ <Switch
+ checked={field.value}
+ onCheckedChange={(val) => field.onChange(val)}
+ disabled={!newBranchPerPr || disabled || !canUpdateGitHubConnection}
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </div>
+ </div>
+ </CardContent>
+ <CardFooter className="flex justify-between items-center">
+ <div>
+ {connection && (
+ <Button
+ type="outline"
+ onClick={handleRemoveIntegration}
+ disabled={isDeletingConnection}
+ loading={isDeletingConnection}
+ >
+ Disable integration
+ </Button>
+ )}
+ </div>
+ <div className="flex space-x-2">
+ {githubSettingsForm.formState.isDirty && (
+ <Button
+ type="default"
+ onClick={() => {
+ githubSettingsForm.reset()
+ }}
+ disabled={disabled || !canUpdateGitHubConnection}
+ >
+ Cancel
+ </Button>
+ )}
+ <Button
+ type={promptProPlanUpgrade ? 'default' : 'primary'}
+ htmlType="submit"
+ disabled={
+ disabled ||
+ (!connection && !canCreateGitHubConnection) ||
+ (connection && !canUpdateGitHubConnection) ||
+ isCheckingBranch ||
+ isLoading ||
+ (!connection && !githubSettingsForm.getValues().repositoryId) ||
+ (connection && !githubSettingsForm.formState.isDirty)
+ }
+ loading={isCheckingBranch || isLoading}
+ >
+ {connection ? 'Save changes' : 'Enable integration'}
+ </Button>
+ </div>
+ </CardFooter>
</Card>
</form>
</Form_Shadcn_>
@@ -830,3 +801,5 @@ export const GitHubIntegrationConnectionForm = ({
</>
)
}
+
+export default GitHubIntegrationConnectionForm
diff --git a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
index f13f091d7c0..9ce834daa0b 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
@@ -1,4 +1,7 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
+import { useMemo } from 'react'
+
+import { useGitHubAuthorizationQuery } from '@/data/integrations/github-authorization-query'
import { useParams } from 'common'
import {
ScaffoldContainer,
@@ -7,14 +10,13 @@ import {
ScaffoldSectionDetail,
} from 'components/layouts/Scaffold'
import NoPermission from 'components/ui/NoPermission'
+import { UpgradeToPro } from 'components/ui/UpgradeToPro'
import { useGitHubConnectionsQuery } from 'data/integrations/github-connections-query'
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
-import { BASE_PATH } from 'lib/constants'
-import { useMemo } from 'react'
+import { BASE_PATH, IS_PLATFORM } from 'lib/constants'
import { GenericSkeletonLoader } from 'ui-patterns'
-
-import { GitHubIntegrationConnectionForm } from './GitHubIntegrationConnectionForm'
+import GitHubIntegrationConnectionForm from './GitHubIntegrationConnectionForm'
const IntegrationImageHandler = ({ title }: { title: 'vercel' | 'github' }) => {
return (
@@ -33,6 +35,11 @@ export const GitHubSection = () => {
const { can: canReadGitHubConnection, isLoading: isLoadingPermissions } =
useAsyncCheckPermissions(PermissionAction.READ, 'integrations.github_connections')
+ const isProPlanAndUp = organization?.plan?.id !== 'free'
+ const promptProPlanUpgrade = IS_PLATFORM && !isProPlanAndUp
+
+ const { data: gitHubAuthorization } = useGitHubAuthorizationQuery()
+
const { data: connections } = useGitHubConnectionsQuery(
{ organizationId: organization?.id },
{ enabled: !!projectRef && !!organization?.id }
@@ -59,13 +66,35 @@ export const GitHubSection = () => {
<NoPermission resourceText="view this organization's GitHub connections" />
) : (
<div className="space-y-6">
- <h5 className="text-foreground">How does the GitHub integration work?</h5>
- <p className="text-foreground-light text-sm !mt-2">
- Connecting to GitHub allows you to sync preview branches with a chosen GitHub
- branch, keep your production branch in sync, and automatically create preview
- branches for every pull request.
- </p>
- <GitHubIntegrationConnectionForm connection={existingConnection} />
+ <div>
+ <h5 className="text-foreground mb-2">How does the GitHub integration work?</h5>
+ <p className="text-foreground-light text-sm mb-6">
+ Connecting to GitHub allows you to sync preview branches with a chosen GitHub
+ branch, keep your production branch in sync, and automatically create preview
+ branches for every pull request.
+ </p>
+
+ {promptProPlanUpgrade && (
+ <div className="mb-6">
+ <UpgradeToPro
+ layout="vertical"
+ source="github-integration"
+ featureProposition="use GitHub integrations"
+ primaryText={`Upgrade to ${!!existingConnection ? 'manage' : 'unlock'} GitHub integration`}
+ secondaryText="Connect your GitHub repository to automatically sync preview branches and deploy changes."
+ />
+ </div>
+ )}
+
+ {/* [Joshen] Show connection form if GH has already been authorized OR no GH authorization but on a paid plan */}
+ {/* So this shouldn't render if there's no GH authorization and on a free plan */}
+ {(!!gitHubAuthorization || !promptProPlanUpgrade) && (
+ <GitHubIntegrationConnectionForm
+ disabled={promptProPlanUpgrade}
+ connection={existingConnection}
+ />
+ )}
+ </div>
</div>
)}
</ScaffoldSectionContent>
diff --git a/apps/studio/components/ui/UpgradeToPro.tsx b/apps/studio/components/ui/UpgradeToPro.tsx
index c7e8b5ebf28..e7059d417d9 100644
--- a/apps/studio/components/ui/UpgradeToPro.tsx
+++ b/apps/studio/components/ui/UpgradeToPro.tsx
@@ -1,8 +1,7 @@
import { ReactNode } from 'react'
+
import { cn } from 'ui'
import { Admonition } from 'ui-patterns'
-
-import { DocsButton } from './DocsButton'
import { UpgradePlanButton } from './UpgradePlanButton'
interface UpgradeToProProps {
@@ -22,7 +21,6 @@ interface UpgradeToProProps {
layout?: 'vertical' | 'horizontal'
variant?: 'default' | 'primary'
className?: string
- docsUrl?: string
}
export const UpgradeToPro = ({
@@ -39,7 +37,6 @@ export const UpgradeToPro = ({
layout = 'horizontal',
variant = 'primary',
className,
- docsUrl,
}: UpgradeToProProps) => {
return (
<Admonition
@@ -50,19 +47,16 @@ export const UpgradeToPro = ({
description={secondaryText}
className={cn(fullWidth && 'border-0 rounded-none border-b', className)}
actions={
- <>
- <UpgradePlanButton
- plan={planToUpgrade}
- addon={addon}
- source={source}
- featureProposition={featureProposition}
- disabled={disabled}
- variant={variant}
- >
- {buttonText}
- </UpgradePlanButton>
- {!!docsUrl && <DocsButton href={docsUrl} />}
- </>
+ <UpgradePlanButton
+ plan={planToUpgrade}
+ addon={addon}
+ source={source}
+ featureProposition={featureProposition}
+ disabled={disabled}
+ variant={variant}
+ >
+ {buttonText}
+ </UpgradePlanButton>
}
/>
)