mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
Whenever customers run into their 2 Free Plan project limit, we were previously just listed the affected members: <img width="1044" height="566" alt="image" src="https://github.com/user-attachments/assets/d1c1327d-2532-4d8e-8af2-425da9ce1ee5" /> While this lists the affected members, it is pretty unclear which organizations are affected or which projects contribute to this and what the best course of action is. This PR revamps all components that are displayed in this situation (new project launch, downgrade to Free, project unpause) to show the affected organizations + projects primarily and give more actionable tips: <img width="1014" height="638" alt="Screenshot 2026-11-11 at 3 57 45 PM (1)" src="https://github.com/user-attachments/assets/ae38f71d-bbde-4181-a623-24bef778afee" /> <img width="768" height="152" alt="image" src="https://github.com/user-attachments/assets/b3b0efd7-678b-4ac0-9602-4cc5d735a9aa" /> --- Additionally, this contains small improvements to the downgrade flow: - Rename button to "Downgrade Now" as opposed to "Confirm" to make it more clear that this is immediate - Explicitly mention downgrades are immediate and there is still another invoice for unbilled usage - Larger modal width for improved readability
65 lines
2.5 KiB
TypeScript
65 lines
2.5 KiB
TypeScript
import {
|
|
AlertDialog,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogTitle,
|
|
} from 'ui'
|
|
|
|
import { ExceedFreeProjectLimitMembers } from '@/components/ui/ExceedFreeProjectLimitMembers'
|
|
import { FreeProjectLimitActions } from '@/components/ui/FreeProjectLimitActions'
|
|
import { useFreeProjectLimitCheckQuery } from '@/data/organizations/free-project-limit-check-query'
|
|
import { useOrganizationMembersQuery } from '@/data/organizations/organization-members-query'
|
|
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
|
|
import { pluralize } from '@/lib/helpers'
|
|
|
|
export interface MembersExceedLimitModalProps {
|
|
visible: boolean
|
|
onClose: () => void
|
|
}
|
|
|
|
export const MembersExceedLimitModal = ({ visible, onClose }: MembersExceedLimitModalProps) => {
|
|
const { data: selectedOrganization } = useSelectedOrganizationQuery()
|
|
const slug = selectedOrganization?.slug
|
|
const { data: membersExceededLimit } = useFreeProjectLimitCheckQuery(
|
|
{ slug },
|
|
{ enabled: visible }
|
|
)
|
|
const { data: orgMembers } = useOrganizationMembersQuery({ slug }, { enabled: visible })
|
|
const hasMultipleMembers = (orgMembers ?? []).filter((member) => !member.invited_id).length > 1
|
|
|
|
return (
|
|
<AlertDialog open={visible} onOpenChange={onClose}>
|
|
<AlertDialogContent size="medium">
|
|
<AlertDialogHeader>
|
|
<AlertDialogTitle>Unable to downgrade organization</AlertDialogTitle>
|
|
<AlertDialogDescription>
|
|
<div className="flex flex-col space-y-2">
|
|
<p className="text-sm text-foreground-light">
|
|
Downgrading this organization would cause {membersExceededLimit?.length}{' '}
|
|
{pluralize(membersExceededLimit?.length ?? 0, 'member')} to exceed the limit of{' '}
|
|
<span className="text-foreground">2 active Free Plan projects</span> per member
|
|
across all organizations.
|
|
</p>
|
|
|
|
<ExceedFreeProjectLimitMembers membersExceededLimit={membersExceededLimit ?? []} />
|
|
|
|
<FreeProjectLimitActions
|
|
goal="downgrade to the Free Plan"
|
|
hasMultipleMembers={hasMultipleMembers}
|
|
/>
|
|
</div>
|
|
</AlertDialogDescription>
|
|
</AlertDialogHeader>
|
|
<AlertDialogFooter>
|
|
<AlertDialogCancel onClick={onClose} type="button">
|
|
Understood
|
|
</AlertDialogCancel>
|
|
</AlertDialogFooter>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
)
|
|
}
|