mirror of
https://github.com/supabase/supabase.git
synced 2026-06-16 11:58:16 +08:00
## What kind of change does this PR introduce? Feature. Resolves DEPR-556. ## What is the current behavior? AWS Marketplace onboarding uses a separate scaffold and AWS-specific organization selection UI, so it does not match the newer shared connect interstitial pattern used by Redeem Credits. ## What is the new behavior? - Moves `/aws-marketplace-onboarding` onto the shared connect interstitial shell with AWS and Supabase branding - Reuses the shared organization selector behaviour from Redeem Credits, including last-visited organization promotion, selected organization promotion, the create-organization card, and compact overflow disclosure - Keeps the existing AWS data path for buyer eligibility, onboarding info, organization linking, AWS-managed organization creation, and success/error/ineligible states - Removes the now-unused legacy AWS Marketplace layout/scaffold components - Removes the temporary reviewer mocks from the branch before merge ## Additional context This PR preserves the current AWS-managed organization creation modal so the AWS flow keeps working while adopting the shared connect sheet. FE-3216 should move that creation path into the general organization form later, likely replacing the AWS-specific modal with a preconfigured `/new` flow that can still return to AWS Marketplace onboarding and link automatically. --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
135 lines
4.0 KiB
TypeScript
135 lines
4.0 KiB
TypeScript
import { useIsMFAEnabled } from 'common'
|
|
import { Boxes, Lock, Plus } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { Fragment, type ReactNode } from 'react'
|
|
import { cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
|
|
|
import { ActionCard } from '@/components/ui/ActionCard'
|
|
import PartnerIcon from '@/components/ui/PartnerIcon'
|
|
import { useOrgProjectsInfiniteQuery } from '@/data/projects/org-projects-infinite-query'
|
|
import type { Organization } from '@/types'
|
|
|
|
export const OrganizationCard = ({
|
|
organization,
|
|
href,
|
|
isLink = true,
|
|
className,
|
|
onClick,
|
|
description,
|
|
}: {
|
|
organization: Organization
|
|
href?: string
|
|
isLink?: boolean
|
|
className?: string
|
|
onClick?: () => void
|
|
description?: ReactNode
|
|
}) => {
|
|
const isUserMFAEnabled = useIsMFAEnabled()
|
|
const isPlatformOrg = organization.plan?.id === 'platform'
|
|
const shouldRenderDefaultDescription = description === undefined
|
|
const { data } = useOrgProjectsInfiniteQuery(
|
|
{ slug: organization.slug },
|
|
{ enabled: !isPlatformOrg && shouldRenderDefaultDescription }
|
|
)
|
|
const numProjects = data?.pages[0].pagination.count ?? 0
|
|
const isMfaRequired = organization.organization_requires_mfa
|
|
|
|
const renderContent = () => (
|
|
<ActionCard
|
|
bgColor="bg border"
|
|
className={cn(
|
|
'flex items-center min-h-[70px] [&>div]:w-full [&>div]:items-center max-h-min',
|
|
className
|
|
)}
|
|
icon={<Boxes size={18} strokeWidth={1} className="text-foreground" />}
|
|
title={organization.name}
|
|
onClick={onClick}
|
|
description={
|
|
shouldRenderDefaultDescription ? (
|
|
<div className="flex items-center justify-between text-xs text-foreground-light font-sans">
|
|
<div className="flex items-center gap-x-1">
|
|
<span>{organization.plan.name} Plan</span>
|
|
{numProjects > 0 && (
|
|
<>
|
|
<span className="text-foreground-lighter">·</span>
|
|
<span>
|
|
{numProjects} project{numProjects > 1 ? 's' : ''}
|
|
</span>
|
|
</>
|
|
)}
|
|
</div>
|
|
<div className="flex items-center gap-x-2">
|
|
<PartnerIcon organization={organization} />
|
|
{isMfaRequired && (
|
|
<Tooltip>
|
|
<TooltipTrigger className="cursor-default">
|
|
<Lock size={12} />
|
|
</TooltipTrigger>
|
|
<TooltipContent side="bottom" className={!isUserMFAEnabled ? 'w-80' : ''}>
|
|
MFA enforced
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)}
|
|
</div>
|
|
</div>
|
|
) : (
|
|
description
|
|
)
|
|
}
|
|
/>
|
|
)
|
|
|
|
if (isLink) {
|
|
return <Link href={href ?? `/org/${organization.slug}`}>{renderContent()}</Link>
|
|
} else {
|
|
return <Fragment>{renderContent()}</Fragment>
|
|
}
|
|
}
|
|
|
|
export const CreateOrganizationCard = ({
|
|
params = {},
|
|
label = 'Create new organization',
|
|
onClick,
|
|
disabled,
|
|
}: {
|
|
params?: { [key: string]: string }
|
|
label?: string
|
|
onClick?: () => void
|
|
disabled?: boolean
|
|
}) => {
|
|
const createOrganizationHref = `/new${Object.keys(params).length > 0 ? `?${new URLSearchParams(params).toString()}` : ''}`
|
|
const card = (
|
|
<ActionCard
|
|
bgColor="bg border"
|
|
className={cn(
|
|
'flex items-center min-h-[70px] [&>div]:w-full [&>div]:items-center max-h-min',
|
|
'border-dashed shadow-none transition-colors group-hover:border-default group-hover:bg-surface-200'
|
|
)}
|
|
icon={<Plus size={18} strokeWidth={1} className="text-foreground" />}
|
|
title={label}
|
|
/>
|
|
)
|
|
|
|
if (onClick) {
|
|
return (
|
|
<button
|
|
type="button"
|
|
disabled={disabled}
|
|
onClick={onClick}
|
|
className={cn(
|
|
'group block w-full cursor-pointer text-left disabled:cursor-not-allowed disabled:opacity-50',
|
|
disabled && 'pointer-events-none'
|
|
)}
|
|
>
|
|
{card}
|
|
</button>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Link href={createOrganizationHref} className="group block">
|
|
{card}
|
|
</Link>
|
|
)
|
|
}
|