The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Improve member invite UI (#38851)
Joshen Lim584a3622b941
diff --git a/apps/studio/components/interfaces/OrganizationInvite/OrganizationInvite.tsx b/apps/studio/components/interfaces/OrganizationInvite/OrganizationInvite.tsxindex 89bae87a18e..f9abc67e8a7 100644--- a/apps/studio/components/interfaces/OrganizationInvite/OrganizationInvite.tsx+++ b/apps/studio/components/interfaces/OrganizationInvite/OrganizationInvite.tsx@@ -7,27 +7,36 @@ import { useParams } from 'common'import { useOrganizationAcceptInvitationMutation } from 'data/organization-members/organization-invitation-accept-mutation'import { useOrganizationInvitationTokenQuery } from 'data/organization-members/organization-invitation-token-query'import { useProfile } from 'lib/profile'-import { ResponseError } from 'types'-import { Button, Loading, cn } from 'ui'+import { Button, cn } from 'ui'+import { Admonition, GenericSkeletonLoader } from 'ui-patterns'import { OrganizationInviteError } from './OrganizationInviteError'export const OrganizationInvite = () => {const router = useRouter()const { profile } = useProfile()- const { slug, token, name } = useParams()+ const { slug, token } = useParams()- const { data, error, isSuccess, isError, isLoading } = useOrganizationInvitationTokenQuery(+ const {+ data,+ error,+ isSuccess: isSuccessInvitation,+ isError: isErrorInvitation,+ isLoading: isLoadingInvitation,+ } = useOrganizationInvitationTokenQuery({ slug, token },{retry: false,refetchOnWindowFocus: false,+ enabled: !!profile,})const hasError =- isError || (isSuccess && (data.token_does_not_exist || data.expired_token || !data.email_match))- const isNotSignedInError = error?.message.includes('No authorization token was found')+ isErrorInvitation ||+ (isSuccessInvitation && (data.token_does_not_exist || data.expired_token || !data.email_match))+ const inviteIsNoLongerValid =+ error?.code === 401 && error?.message.includes('Failed to retrieve organization')- const organizationName = isSuccess ? data?.organization_name : 'an organization'+ const organizationName = isSuccessInvitation ? data?.organization_name : 'An organization'const loginRedirectLink = `/sign-in?returnTo=${encodeURIComponent(`/join?token=${token}&slug=${slug}`)}`const { mutate: joinOrganization, isLoading: isJoining } =@@ -47,57 +56,89 @@ export const OrganizationInvite = () => {}return (- <Loading active={profile !== undefined && isLoading}>- <div className="flex flex-col gap-2 px-6 py-8">- <p className="text-sm text-foreground">You have been invited to join </p>- <p className="text-3xl text-foreground">{organizationName}</p>- {isSuccess && slug && (- <p className="text-xs text-foreground-lighter">{`organization slug: ${slug}`}</p>- )}- </div>-- <div className={cn('border-t border-muted', hasError ? 'bg-alternative' : 'bg-transparent')}>- {profile === undefined && (- <div className="flex flex-col gap-3 py-4">- <p className="text-xs text-foreground-lighter">- You will need to sign in to accept this invitation+ <div+ className={cn(+ 'mx-auto overflow-hidden rounded-md border',+ 'border-muted bg-alternative text-center shadow',+ 'md:w-[400px]'+ )}+ >+ {isLoadingInvitation ? (+ <div className="p-5">+ <GenericSkeletonLoader />+ </div>+ ) : inviteIsNoLongerValid ? (+ <>+ <Admonition+ type="default"+ title="Invalid invitation"+ description="This organization invite is no longer valid as it has either been accepted or declined"+ className="mb-0 border-0 rounded-none text-left"+ />+ <div className="p-4 border-muted border-t">+ <Button type="default" asChild>+ <Link href="/">Back to dashboard</Link>+ </Button>+ </div>+ </>+ ) : (+ <>+ <div className="flex flex-col gap-y-1 px-6 py-6">+ <p className="text-sm text-foreground-light">You have been invited to join </p>+ <p className={cn('text-foreground', !!profile ? 'text-2xl' : 'text-3xl')}>+ {organizationName}</p>- <div className="flex justify-center gap-3">- <Button asChild type="default">- <Link href={loginRedirectLink}>Sign in</Link>- </Button>- <Button asChild type="default">- <Link href={loginRedirectLink}>Create an account</Link>- </Button>- </div>+ {isSuccessInvitation && (+ <p className="text-xs text-foreground-lighter">{`Organization slug: ${slug}`}</p>+ )}</div>- )}- <div className={cn('flex flex-col gap-4', !isLoading && !hasError && 'px-6 py-4')}>- {hasError && !isNotSignedInError && (- <OrganizationInviteError- data={data}- error={error as unknown as ResponseError}- isError={isError}- />- )}- {isSuccess && !hasError && (- <div className="flex flex-row items-center justify-center gap-3">- <Button type="default" disabled={isJoining} asChild>- <Link href="/projects">Decline</Link>- </Button>- <Button- type="primary"- loading={isJoining}- disabled={isJoining}- onClick={handleJoinOrganization}- icon={<CheckSquare />}- >- Join organization- </Button>+ <div+ className={cn('border-t border-muted', hasError ? 'bg-alternative' : 'bg-transparent')}+ >+ {profile === undefined && (+ <div className="flex flex-col gap-y-4 p-4">+ <p className="text-sm text-foreground">+ Sign in or create an account first to view this invitation+ </p>+ <div className="flex justify-center gap-3">+ <Button asChild type="default">+ <Link href={loginRedirectLink}>Sign in</Link>+ </Button>+ <Button asChild type="default">+ <Link href={loginRedirectLink}>Create an account</Link>+ </Button>+ </div>+ </div>+ )}+ <div+ className={cn(+ 'flex flex-col gap-4',+ !isLoadingInvitation && !hasError && 'px-6 py-4'+ )}+ >+ {!!profile && hasError && (+ <OrganizationInviteError data={data} error={error} isError={isErrorInvitation} />+ )}+ {isSuccessInvitation && !hasError && (+ <div className="flex flex-row items-center justify-center gap-3">+ <Button type="default" disabled={isJoining} asChild>+ <Link href="/projects">Decline</Link>+ </Button>+ <Button+ type="primary"+ loading={isJoining}+ disabled={isJoining}+ onClick={handleJoinOrganization}+ icon={<CheckSquare />}+ >+ Join organization+ </Button>+ </div>+ )}</div>- )}- </div>- </div>- </Loading>+ </div>+ </>+ )}+ </div>)}diff --git a/apps/studio/components/interfaces/OrganizationInvite/OrganizationInviteError.tsx b/apps/studio/components/interfaces/OrganizationInvite/OrganizationInviteError.tsxindex 32d5bc01de2..0e4907cd7fd 100644--- a/apps/studio/components/interfaces/OrganizationInvite/OrganizationInviteError.tsx+++ b/apps/studio/components/interfaces/OrganizationInvite/OrganizationInviteError.tsx@@ -9,7 +9,7 @@ import { cn } from 'ui'interface OrganizationInviteError {data?: OrganizationInviteByToken- error?: ResponseError+ error?: ResponseError | nullisError: boolean}diff --git a/apps/studio/components/ui/ActionCard.tsx b/apps/studio/components/ui/ActionCard.tsxindex 549e51a2ad7..401112986a1 100644--- a/apps/studio/components/ui/ActionCard.tsx+++ b/apps/studio/components/ui/ActionCard.tsx@@ -29,8 +29,10 @@ export const ActionCard = (card: {>{card.icon}</div>- <div className="flex flex-col gap-0 w-full">- <h3 className="text-sm text-foreground mb-0">{card.title}</h3>+ <div className="flex-grow flex flex-col gap-0 min-w-0">+ <h3 title={card.title} className="text-sm text-foreground mb-0 truncate max-w-full">+ {card.title}+ </h3>{typeof card.description === 'string' ? (<pre className="text-xs text-foreground-light font-sans">{card.description}</pre>) : (diff --git a/apps/studio/pages/join.tsx b/apps/studio/pages/join.tsxindex 58f63aa217c..75823e77d9d 100644--- a/apps/studio/pages/join.tsx+++ b/apps/studio/pages/join.tsx@@ -1,39 +1,48 @@import Link from 'next/link'-import { useRouter } from 'next/router'import { OrganizationInvite } from 'components/interfaces/OrganizationInvite/OrganizationInvite'+import { BASE_PATH } from 'lib/constants'+import { useTheme } from 'next-themes'+import { useEffect, useMemo, useState } from 'react'import { NextPageWithLayout } from 'types'import { cn } from 'ui'const JoinOrganizationPage: NextPageWithLayout = () => {- const router = useRouter()+ const { resolvedTheme } = useTheme()+ const isDarkMode = resolvedTheme?.includes('dark')++ const [mounted, setMounted] = useState(false)++ const imgUrl = useMemo(+ () =>+ isDarkMode ? `${BASE_PATH}/img/supabase-dark.svg` : `${BASE_PATH}/img/supabase-light.svg`,+ [isDarkMode]+ )++ useEffect(() => setMounted(true), [])return (- <div- className={cn(- 'flex h-full min-h-screen bg-studio',- 'w-full flex-col place-items-center',- 'items-center justify-center gap-8 px-5'- )}- >+ <><Link href="/projects" className="flex items-center justify-center gap-4">- <img- src={`${router.basePath}/img/supabase-logo.svg`}- alt="Supabase"- className="block h-[24px] cursor-pointer rounded"- />- </Link>- <div- className={cn(- 'mx-auto overflow-hidden rounded-md border',- 'border-muted bg-alternative text-center shadow',- 'md:w-[400px]'+ {mounted && (+ <img src={imgUrl} alt="Supabase" className="block h-[24px] cursor-pointer rounded" />)}- >- <OrganizationInvite />- </div>- </div>+ </Link>+ <OrganizationInvite />+ </>)}+JoinOrganizationPage.getLayout = (page) => (+ <div+ className={cn(+ 'flex h-full min-h-screen bg-studio',+ 'w-full flex-col place-items-center',+ 'items-center justify-center gap-8 px-5'+ )}+ >+ {page}+ </div>+)+export default JoinOrganizationPage