Skip to content

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

Allow users to continue with org if integration installed (#48231)

Joshen Limd0e781a960be
diff --git a/apps/studio/pages/integrations/vercel/install.tsx b/apps/studio/pages/integrations/vercel/install.tsx
index ea4d72d9bd3..9defd01e649 100644
--- a/apps/studio/pages/integrations/vercel/install.tsx
+++ b/apps/studio/pages/integrations/vercel/install.tsx
@@ -56,13 +56,14 @@ const PAGE_TITLE = buildStudioPageTitle({
export type VercelIntegrationFlow = 'deploy-button' | 'marketing'
const VercelIntegration: NextPageWithLayout = () => {
+ const track = useTrack()
const router = useRouter()
+ const snapshot = useIntegrationInstallationSnapshot()
const { code, configurationId, currentProjectId, externalId, next, teamId, source } = useParams()
+
const [selectedOrg, setSelectedOrg] = useState<Organization | null>(null)
- const { username, primaryEmail, avatarUrl } = useProfileNameAndPicture()
- const track = useTrack()
- const snapshot = useIntegrationInstallationSnapshot()
+ const { username, primaryEmail, avatarUrl } = useProfileNameAndPicture()
const displayName = primaryEmail ?? username ?? ''
/**
@@ -85,16 +86,6 @@ const VercelIntegration: NextPageWithLayout = () => {
error: organizationsError,
} = useOrganizationsQuery()
- useEffect(() => {
- if (organizationsData !== undefined && integrationData !== undefined) {
- const firstOrg = organizationsData[0]
-
- if (firstOrg && selectedOrg === null) {
- setSelectedOrg(firstOrg)
- }
- }
- }, [organizationsData, integrationData, selectedOrg])
-
/**
* Organizations with extra `installationInstalled` attribute
*
@@ -224,12 +215,6 @@ const VercelIntegration: NextPageWithLayout = () => {
return isOrganizationsDataSuccess && organizationsData?.length === 0 ? true : false
}, [isOrganizationsDataSuccess, organizationsData])
- const alreadyInstalled = useMemo(() => {
- return selectedOrg && installed[selectedOrg.slug] && source === 'marketplace' && !dataLoading
- ? true
- : false
- }, [dataLoading, installed, selectedOrg, source])
-
const missingParams = [
!code ? 'code' : undefined,
!configurationId ? 'configurationId' : undefined,
@@ -241,13 +226,18 @@ const VercelIntegration: NextPageWithLayout = () => {
const showLoadingState = isLoadingOrganizationsQuery || isLoadingIntegrationsQuery
const disableInstallationForm =
- dataLoading ||
- // disables installation button if integration is already installed and it is Marketplace flow
- alreadyInstalled ||
- noOrganizations ||
- !selectedOrg ||
- missingParams.length > 0 ||
- isError
+ dataLoading || noOrganizations || !selectedOrg || missingParams.length > 0 || isError
+
+ useEffect(() => {
+ if (organizationsData !== undefined && integrationData !== undefined) {
+ const firstOrg = organizationsData[0]
+
+ if (firstOrg && selectedOrg === null) {
+ setSelectedOrg(firstOrg)
+ }
+ }
+ }, [organizationsData, integrationData, selectedOrg])
+
return (
<>
<Head>
@@ -290,14 +280,6 @@ const VercelIntegration: NextPageWithLayout = () => {
/>
)}
- {alreadyInstalled && (
- <Admonition
- type="warning"
- title="Vercel integration is already installed"
- description="Choose another organization to install this marketplace integration."
- />
- )}
-
{noOrganizations && (
<Admonition
type="warning"
@@ -323,7 +305,7 @@ const VercelIntegration: NextPageWithLayout = () => {
loading={dataLoading}
onClick={onInstall}
>
- Install integration
+ {selectedOrg && installed[selectedOrg.slug] ? 'Continue' : 'Install integration'}
</Button>
</div>
</div>