mirror of
https://github.com/supabase/supabase.git
synced 2026-09-22 13:37:53 +08:00
a31ca2bad0
## What kind of change does this PR introduce? Bug fix and design-system update. Resolves DEPR-316. Follow-up rename (`text-brand` → `text-primary`) is in a dedicated PR (https://github.com/supabase/supabase/pull/50564) stacked on this one. ## What is the current behavior? `text-brand` resolves to the canonical bright brand green in places that need readable text, which fails WCAG AA on light surfaces. A separate `text-brand-display` token adds another green for large type. ## What is the new behavior? - `text-brand` maps to accessible `--primary` (light mode darkened to meet ~4.5:1 AA) - `--hue` / `--primary-hue` aligned to 157.5 - `text-brand-display` removed; former display callsites use `text-brand` - Bright fills/borders stay on `brand-default` - Design-system colour and typography docs updated | Before | After | | --- | --- | | <img width="514" height="112" alt="CleanShot 2026-09-02 at 11 13 09@2x" src="https://github.com/user-attachments/assets/4e0138a9-a32d-4e4c-a426-90736706e1e7" /> | <img width="512" height="138" alt="CleanShot 2026-09-21 at 11 42 05@2x" src="https://github.com/user-attachments/assets/164cc5b1-a0c5-4e93-95f1-80016641a114" /> | | <img width="864" height="266" alt="CleanShot 2026-09-02 at 11 13 53@2x" src="https://github.com/user-attachments/assets/3c1ca53f-bf9e-431e-bc15-816b4a275b8e" /> | <img width="882" height="248" alt="CleanShot 2026-09-21 at 11 41 37@2x" src="https://github.com/user-attachments/assets/24828e7b-ed6b-44cb-b9dc-becc3398bdfc" /> | | <img width="782" height="692" alt="CleanShot 2026-09-02 at 11 16 30@2x" src="https://github.com/user-attachments/assets/fc871977-77bc-47fb-9e0e-9284e0ecd5cc" /> | <img width="730" height="690" alt="CleanShot 2026-09-21 at 11 42 52@2x" src="https://github.com/user-attachments/assets/bf479515-d5f9-471e-b82d-f097c0f4b56c" /> | | <img width="480" height="306" alt="CleanShot 2026-09-02 at 11 18 53@2x" src="https://github.com/user-attachments/assets/03f341f4-f02e-44f8-a2b2-8c31670d0427" /> | <img width="470" height="300" alt="CleanShot 2026-09-21 at 11 43 19@2x" src="https://github.com/user-attachments/assets/9df18217-d5e6-48b8-ba0b-579d2664b94b" /> | | <img width="960" height="300" alt="CleanShot 2026-09-02 at 11 32 04@2x" src="https://github.com/user-attachments/assets/6b1d9373-7a71-4247-81ff-26441604b09d" /> | <img width="980" height="306" alt="CleanShot 2026-09-21 at 11 44 13@2x" src="https://github.com/user-attachments/assets/41ad4784-02ec-4b29-b860-32af9fa79aa8" /> | | <img width="924" height="214" alt="CleanShot 2026-09-02 at 11 34 44@2x" src="https://github.com/user-attachments/assets/1de661fe-c7b6-499b-a94f-e4737436ec79" /> | <img width="752" height="162" alt="CleanShot 2026-09-21 at 11 44 56@2x" src="https://github.com/user-attachments/assets/1811890f-0660-4445-84e9-447720954fa1" /> | ## To test Test each callsite **in light mode** (dark mode is largely unchanged). ### WWW - [Homepage](https://zone-www-dot-com-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/): “Scale to millions” uses readable brand text (display token is gone) - [Careers](https://zone-www-dot-com-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/careers): small “Careers” eyebrow readable; green dividers stay bright `brand-default` - [Contact](https://zone-www-dot-com-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/contact-us): email / policy links use readable brand text - [Regions](https://zone-www-dot-com-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/regions): “Ask about early access to BYOC” readable ### Docs - [Docs homepage](https://docs-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs): “DOCS” wordmark and resource links readable - [Database overview](https://docs-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs/guides/database/overview): nav / footer brand links readable - [JavaScript reference](https://docs-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs/reference/javascript/introduction): active sidebar treatment readable ### Design system - [Typography](https://design-system-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs/typography): documents `text-brand` only (no display) - [Colour usage](https://design-system-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs/color-usage): `text-brand` vs `bg-brand-default` - [Design-system homepage](https://design-system-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/): brand text examples across themes ### Studio - [Auth providers](https://studio-staging-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/dashboard/project/_/auth/providers): enabled provider badge text readable; status dot stays bright - [Database policies](https://studio-staging-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/dashboard/project/_/database/policies?new=true): template hover text more legible - [Database connections](https://studio-staging-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/dashboard/project/_/observability/connections): “Live” status readable; animated dot stays bright green --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
576 lines
20 KiB
TypeScript
576 lines
20 KiB
TypeScript
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
|
import { useParams } from 'common'
|
|
import dayjs from 'dayjs'
|
|
import { Ban, Check, Copy, Mail, ShieldOff, Trash, X } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { ComponentProps, ReactNode, useEffect, useState } from 'react'
|
|
import { toast } from 'sonner'
|
|
import { Button, cn, Separator } from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
|
|
|
|
import { PROVIDERS_SCHEMAS } from '../AuthProvidersFormValidation'
|
|
import { BanUserModal } from './BanUserModal'
|
|
import { DeleteUserModal } from './DeleteUserModal'
|
|
import { UserHeader } from './UserHeader'
|
|
import { PANEL_PADDING } from './Users.constants'
|
|
import { providerIconMap } from './Users.utils'
|
|
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
|
|
import CopyButton from '@/components/ui/CopyButton'
|
|
import { useAuthConfigQuery } from '@/data/auth/auth-config-query'
|
|
import { useUserDeleteMFAFactorsMutation } from '@/data/auth/user-delete-mfa-factors-mutation'
|
|
import { useUserResetPasswordMutation } from '@/data/auth/user-reset-password-mutation'
|
|
import { useUserSendMagicLinkMutation } from '@/data/auth/user-send-magic-link-mutation'
|
|
import { useUserSendOTPMutation } from '@/data/auth/user-send-otp-mutation'
|
|
import { useUserUpdateMutation } from '@/data/auth/user-update-mutation'
|
|
import { User } from '@/data/auth/users-infinite-query'
|
|
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
|
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
|
|
import { BASE_PATH } from '@/lib/constants'
|
|
import { timeout } from '@/lib/helpers'
|
|
|
|
const DATE_FORMAT = 'DD MMM, YYYY HH:mm'
|
|
const CONTAINER_CLASS = cn(
|
|
'bg-surface-100 border-default text-foreground flex items-center justify-between',
|
|
'gap-x-4 border px-5 py-4 text-sm first:rounded-tr first:rounded-tl last:rounded-br last:rounded-bl'
|
|
)
|
|
|
|
interface UserOverviewProps {
|
|
user: User
|
|
onDeleteSuccess: () => void
|
|
}
|
|
|
|
export const UserOverview = ({ user, onDeleteSuccess }: UserOverviewProps) => {
|
|
const { ref: projectRef } = useParams()
|
|
const isEmailAuth = user.email !== null
|
|
const isPhoneAuth = user.phone !== null
|
|
const isBanned = user.banned_until !== null
|
|
const isVerified = user.confirmed_at != null
|
|
|
|
const { authenticationSignInProviders } = useIsFeatureEnabled([
|
|
'authentication:sign_in_providers',
|
|
])
|
|
|
|
const providers = ((user.raw_app_meta_data?.providers as string[]) ?? []).map(
|
|
(provider: string) => {
|
|
return {
|
|
name: provider.startsWith('sso') ? 'SAML' : provider,
|
|
icon:
|
|
provider === 'email'
|
|
? `${BASE_PATH}/img/icons/email-icon2.svg`
|
|
: providerIconMap[provider]
|
|
? `${BASE_PATH}/img/icons/${providerIconMap[provider]}.svg`
|
|
: undefined,
|
|
}
|
|
}
|
|
)
|
|
|
|
const { can: canUpdateUser } = useAsyncCheckPermissions(PermissionAction.AUTH_EXECUTE, '*')
|
|
const { can: canSendMagicLink } = useAsyncCheckPermissions(
|
|
PermissionAction.AUTH_EXECUTE,
|
|
'send_magic_link'
|
|
)
|
|
const { can: canSendRecovery } = useAsyncCheckPermissions(
|
|
PermissionAction.AUTH_EXECUTE,
|
|
'send_recovery'
|
|
)
|
|
const { can: canSendOtp } = useAsyncCheckPermissions(PermissionAction.AUTH_EXECUTE, 'send_otp')
|
|
const { can: canRemoveUser } = useAsyncCheckPermissions(
|
|
PermissionAction.TENANT_SQL_DELETE,
|
|
'auth.users'
|
|
)
|
|
const { can: canRemoveMFAFactors } = useAsyncCheckPermissions(
|
|
PermissionAction.TENANT_SQL_DELETE,
|
|
'auth.mfa_factors'
|
|
)
|
|
|
|
const [successAction, setSuccessAction] = useState<
|
|
'send_magic_link' | 'send_recovery' | 'send_otp'
|
|
>()
|
|
const [isBanModalOpen, setIsBanModalOpen] = useState(false)
|
|
const [isUnbanModalOpen, setIsUnbanModalOpen] = useState(false)
|
|
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false)
|
|
const [isDeleteFactorsModalOpen, setIsDeleteFactorsModalOpen] = useState(false)
|
|
|
|
const { data } = useAuthConfigQuery({ projectRef })
|
|
|
|
const mailerOtpExpiry = data?.MAILER_OTP_EXP ?? 0
|
|
const minutes = Math.floor(mailerOtpExpiry / 60)
|
|
const seconds = Math.floor(mailerOtpExpiry % 60)
|
|
const formattedExpiry = `${mailerOtpExpiry > 60 ? `${minutes} minute${minutes > 1 ? 's' : ''} ${seconds > 0 ? 'and' : ''} ` : ''}${seconds > 0 ? `${seconds} second${seconds > 1 ? 's' : ''}` : ''}`
|
|
|
|
const { mutate: resetPassword, isPending: isResettingPassword } = useUserResetPasswordMutation({
|
|
onSuccess: (_, vars) => {
|
|
setSuccessAction('send_recovery')
|
|
toast.success(`Sent password recovery to ${vars.user.email}`)
|
|
},
|
|
onError: (err) => {
|
|
toast.error(`Failed to send password recovery: ${err.message}`)
|
|
},
|
|
})
|
|
const { mutate: sendMagicLink, isPending: isSendingMagicLink } = useUserSendMagicLinkMutation({
|
|
onSuccess: (_, vars) => {
|
|
setSuccessAction('send_magic_link')
|
|
toast.success(
|
|
isVerified
|
|
? `Sent magic link to ${vars.user.email}`
|
|
: `Sent confirmation email to ${vars.user.email}`
|
|
)
|
|
},
|
|
onError: (err) => {
|
|
toast.error(
|
|
isVerified
|
|
? `Failed to send magic link: ${err.message}`
|
|
: `Failed to send confirmation email: ${err.message}`
|
|
)
|
|
},
|
|
})
|
|
const { mutate: sendOTP, isPending: isSendingOTP } = useUserSendOTPMutation({
|
|
onSuccess: (_, vars) => {
|
|
setSuccessAction('send_otp')
|
|
toast.success(`Sent OTP to ${vars.user.phone}`)
|
|
},
|
|
onError: (err) => {
|
|
toast.error(`Failed to send OTP: ${err.message}`)
|
|
},
|
|
})
|
|
const { mutate: deleteUserMFAFactors } = useUserDeleteMFAFactorsMutation({
|
|
onSuccess: () => {
|
|
toast.success("Successfully deleted the user's factors")
|
|
setIsDeleteFactorsModalOpen(false)
|
|
},
|
|
})
|
|
const { mutate: updateUser, isPending: isUpdatingUser } = useUserUpdateMutation({
|
|
onSuccess: () => {
|
|
toast.success('Successfully unbanned user')
|
|
setIsUnbanModalOpen(false)
|
|
},
|
|
})
|
|
|
|
const handleDeleteFactors = async () => {
|
|
await timeout(200)
|
|
if (!projectRef) return console.error('Project ref is required')
|
|
deleteUserMFAFactors({ projectRef, userId: user.id as string })
|
|
}
|
|
|
|
const handleUnban = () => {
|
|
if (projectRef === undefined) return console.error('Project ref is required')
|
|
if (user.id === undefined) {
|
|
return toast.error(`Failed to ban user: User ID not found`)
|
|
}
|
|
|
|
updateUser({
|
|
projectRef,
|
|
userId: user.id,
|
|
banDuration: 'none',
|
|
})
|
|
}
|
|
|
|
useEffect(() => {
|
|
if (successAction !== undefined) {
|
|
const timer = setTimeout(() => setSuccessAction(undefined), 5000)
|
|
return () => clearTimeout(timer)
|
|
}
|
|
}, [successAction])
|
|
|
|
return (
|
|
<>
|
|
<div>
|
|
<UserHeader user={user} />
|
|
|
|
{isBanned ? (
|
|
<Admonition
|
|
type="warning"
|
|
description={`User banned until ${dayjs(user.banned_until).format(DATE_FORMAT)}`}
|
|
className="border-r-0 border-l-0 rounded-none -mt-px [&_svg]:ml-0.5"
|
|
/>
|
|
) : (
|
|
<Separator />
|
|
)}
|
|
|
|
<div className={cn('flex flex-col gap-y-1', PANEL_PADDING)}>
|
|
<RowData property="User UID" value={user.id} />
|
|
<RowData
|
|
property="Created at"
|
|
value={user.created_at ? dayjs(user.created_at).format(DATE_FORMAT) : undefined}
|
|
/>
|
|
<RowData
|
|
property="Updated at"
|
|
value={user.updated_at ? dayjs(user.updated_at).format(DATE_FORMAT) : undefined}
|
|
/>
|
|
<RowData property="Invited at" value={user.invited_at} />
|
|
<RowData property="Confirmation sent at" value={user.confirmation_sent_at} />
|
|
<RowData
|
|
property="Confirmed at"
|
|
value={user.confirmed_at ? dayjs(user.confirmed_at).format(DATE_FORMAT) : undefined}
|
|
/>
|
|
<RowData
|
|
property="Last signed in"
|
|
value={
|
|
user.last_sign_in_at ? dayjs(user.last_sign_in_at).format(DATE_FORMAT) : undefined
|
|
}
|
|
/>
|
|
<RowData property="SSO" value={user.is_sso_user} />
|
|
</div>
|
|
|
|
<div className={cn('flex flex-col pt-0!', PANEL_PADDING)}>
|
|
<p>Provider Information</p>
|
|
<p className="text-sm text-foreground-light">The user has the following providers</p>
|
|
</div>
|
|
|
|
<div className={cn('flex flex-col -space-y-1 pt-0!', PANEL_PADDING)}>
|
|
{providers.map((provider) => {
|
|
const providerMeta = PROVIDERS_SCHEMAS.find(
|
|
(x) =>
|
|
('key' in x && x.key === provider.name) || x.title.toLowerCase() === provider.name
|
|
)
|
|
const enabledProperty =
|
|
provider.name.toLowerCase() === 'web3'
|
|
? (
|
|
{
|
|
solana: 'EXTERNAL_WEB3_SOLANA_ENABLED',
|
|
ethereum: 'EXTERNAL_WEB3_ETHEREUM_ENABLED',
|
|
} as const
|
|
)[
|
|
(
|
|
(user.raw_user_meta_data?.custom_claims as { chain?: string } | undefined)
|
|
?.chain ?? ''
|
|
).toLowerCase() as 'solana' | 'ethereum'
|
|
]
|
|
: Object.keys(providerMeta?.properties ?? {}).find((x) =>
|
|
x.toLowerCase().endsWith('_enabled')
|
|
)
|
|
const providerName =
|
|
provider.name === 'email'
|
|
? provider.name.toLowerCase()
|
|
: (providerMeta?.title ?? provider.name)
|
|
const isActive = data?.[enabledProperty as keyof typeof data] ?? false
|
|
|
|
return (
|
|
<div key={provider.name} className={cn(CONTAINER_CLASS, 'items-start justify-start')}>
|
|
{provider.icon && (
|
|
<img
|
|
width={16}
|
|
src={provider.icon}
|
|
alt={`${provider.name} auth icon`}
|
|
className={cn('mt-1.5', provider.name === 'github' ? 'dark:invert' : '')}
|
|
/>
|
|
)}
|
|
<div className="grow mt-0.5">
|
|
<p className="capitalize">{providerName}</p>
|
|
<p className="text-xs text-foreground-light">
|
|
Signed in with a {providerName} account via{' '}
|
|
{providerName === 'SAML' ? 'SSO' : 'OAuth'}
|
|
</p>
|
|
{authenticationSignInProviders && (
|
|
<Button asChild className="mt-2">
|
|
<Link
|
|
href={`/project/${projectRef}/auth/providers?provider=${provider.name === 'SAML' ? 'SAML 2.0' : provider.name}`}
|
|
>
|
|
Configure {providerName} provider
|
|
</Link>
|
|
</Button>
|
|
)}
|
|
</div>
|
|
{isActive ? (
|
|
<div className="flex items-center gap-1 rounded-full border border-brand-400 bg-brand-200 py-1 px-1 text-xs text-brand">
|
|
<span className="rounded-full bg-brand-default p-0.5 text-xs text-brand-200">
|
|
<Check strokeWidth={2} size={12} />
|
|
</span>
|
|
<span className="px-1">Enabled</span>
|
|
</div>
|
|
) : (
|
|
<div className="rounded-md border border-strong bg-surface-100 py-1 px-3 text-xs text-foreground-lighter">
|
|
Disabled
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
})}
|
|
</div>
|
|
|
|
<Separator />
|
|
|
|
<div className={cn('flex flex-col -space-y-1', PANEL_PADDING)}>
|
|
{isEmailAuth && (
|
|
<>
|
|
<RowAction
|
|
title="Reset password"
|
|
description="Send a password recovery email to the user"
|
|
button={{
|
|
icon: <Mail />,
|
|
text: 'Send password recovery',
|
|
isLoading: isResettingPassword,
|
|
disabled: !canSendRecovery,
|
|
onClick: () => {
|
|
if (projectRef) resetPassword({ projectRef, user })
|
|
},
|
|
}}
|
|
success={
|
|
successAction === 'send_recovery'
|
|
? {
|
|
title: 'Password recovery sent',
|
|
description: `The link in the email is valid for ${formattedExpiry}`,
|
|
}
|
|
: undefined
|
|
}
|
|
/>
|
|
<RowAction
|
|
title={isVerified ? 'Send magic link' : 'Send confirmation email'}
|
|
description={
|
|
isVerified
|
|
? 'Send a passwordless magic link to the user'
|
|
: 'Send a confirmation email to the user'
|
|
}
|
|
button={{
|
|
icon: <Mail />,
|
|
text: isVerified ? 'Send magic link' : 'Send confirmation email',
|
|
isLoading: isSendingMagicLink,
|
|
disabled: !canSendMagicLink,
|
|
onClick: () => {
|
|
if (projectRef) sendMagicLink({ projectRef, user })
|
|
},
|
|
}}
|
|
success={
|
|
successAction === 'send_magic_link'
|
|
? {
|
|
title: isVerified ? 'Magic link sent' : 'Confirmation email sent',
|
|
description: isVerified
|
|
? `The link in the email is valid for ${formattedExpiry}`
|
|
: 'The confirmation email has been sent to the user',
|
|
}
|
|
: undefined
|
|
}
|
|
/>
|
|
</>
|
|
)}
|
|
{isPhoneAuth && (
|
|
<RowAction
|
|
title="Send OTP"
|
|
description="Passwordless login via phone for the user"
|
|
button={{
|
|
icon: <Mail />,
|
|
text: 'Send OTP',
|
|
isLoading: isSendingOTP,
|
|
disabled: !canSendOtp,
|
|
onClick: () => {
|
|
if (projectRef) sendOTP({ projectRef, user })
|
|
},
|
|
}}
|
|
success={
|
|
successAction === 'send_otp'
|
|
? {
|
|
title: 'OTP sent',
|
|
description: `The link in the OTP SMS is valid for ${formattedExpiry}`,
|
|
}
|
|
: undefined
|
|
}
|
|
/>
|
|
)}
|
|
</div>
|
|
|
|
<Separator />
|
|
|
|
<div className={cn('flex flex-col', PANEL_PADDING)}>
|
|
<p>Danger zone</p>
|
|
<p className="text-sm text-foreground-light">
|
|
Be wary of the following features as they cannot be undone.
|
|
</p>
|
|
</div>
|
|
|
|
<div className={cn('flex flex-col -space-y-1 pt-0!', PANEL_PADDING)}>
|
|
<RowAction
|
|
title="Remove MFA factors"
|
|
description="Removes all MFA factors associated with the user"
|
|
button={{
|
|
icon: <ShieldOff />,
|
|
text: 'Remove MFA factors',
|
|
disabled: !canRemoveMFAFactors,
|
|
onClick: () => setIsDeleteFactorsModalOpen(true),
|
|
}}
|
|
className="!bg border-destructive-400"
|
|
/>
|
|
<RowAction
|
|
title={
|
|
isBanned
|
|
? `User is banned until ${dayjs(user.banned_until).format(DATE_FORMAT)}`
|
|
: 'Ban user'
|
|
}
|
|
description={
|
|
isBanned
|
|
? 'User has no access to the project until after this date'
|
|
: 'Revoke access to the project for a set duration'
|
|
}
|
|
button={{
|
|
icon: <Ban />,
|
|
text: isBanned ? 'Unban user' : 'Ban user',
|
|
disabled: !canUpdateUser,
|
|
onClick: () => {
|
|
if (isBanned) {
|
|
setIsUnbanModalOpen(true)
|
|
} else {
|
|
setIsBanModalOpen(true)
|
|
}
|
|
},
|
|
}}
|
|
className="!bg border-destructive-400"
|
|
/>
|
|
<RowAction
|
|
title="Delete user"
|
|
description="User will no longer have access to the project"
|
|
button={{
|
|
icon: <Trash />,
|
|
variant: 'danger',
|
|
text: 'Delete user',
|
|
disabled: !canRemoveUser,
|
|
onClick: () => setIsDeleteModalOpen(true),
|
|
}}
|
|
className="!bg border-destructive-400"
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<DeleteUserModal
|
|
visible={isDeleteModalOpen}
|
|
selectedUser={user}
|
|
onClose={() => setIsDeleteModalOpen(false)}
|
|
onDeleteSuccess={() => {
|
|
setIsDeleteModalOpen(false)
|
|
onDeleteSuccess()
|
|
}}
|
|
/>
|
|
|
|
<ConfirmationModal
|
|
visible={isDeleteFactorsModalOpen}
|
|
variant="warning"
|
|
title="Confirm to remove MFA factors"
|
|
confirmLabel="Remove factors"
|
|
confirmLabelLoading="Removing"
|
|
onCancel={() => setIsDeleteFactorsModalOpen(false)}
|
|
onConfirm={() => handleDeleteFactors()}
|
|
alert={{
|
|
base: { variant: 'warning' },
|
|
title:
|
|
"Removing MFA factors will drop the user's authentication assurance level (AAL) to AAL1",
|
|
description: 'Note that this does not sign the user out',
|
|
}}
|
|
>
|
|
<p className="text-sm text-foreground-light">
|
|
Are you sure you want to remove the MFA factors for the user{' '}
|
|
<span className="text-foreground">{user.email ?? user.phone ?? 'this user'}</span>?
|
|
</p>
|
|
</ConfirmationModal>
|
|
|
|
<BanUserModal visible={isBanModalOpen} user={user} onClose={() => setIsBanModalOpen(false)} />
|
|
|
|
<ConfirmationModal
|
|
variant="warning"
|
|
visible={isUnbanModalOpen}
|
|
title="Confirm to unban user"
|
|
loading={isUpdatingUser}
|
|
confirmLabel="Unban user"
|
|
confirmLabelLoading="Unbanning"
|
|
onCancel={() => setIsUnbanModalOpen(false)}
|
|
onConfirm={() => handleUnban()}
|
|
>
|
|
<p className="text-sm text-foreground-light">
|
|
The user will have access to your project again once unbanned. Are you sure you want to
|
|
unban this user?
|
|
</p>
|
|
</ConfirmationModal>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export const RowData = ({ property, value }: { property: string; value?: string | boolean }) => {
|
|
return (
|
|
<>
|
|
<div className="flex items-center gap-x-2 group justify-between">
|
|
<p className=" text-foreground-lighter text-xs">{property}</p>
|
|
{typeof value === 'boolean' ? (
|
|
<div className="h-[26px] flex items-center justify-center min-w-[70px]">
|
|
{value ? (
|
|
<div className="rounded-full w-4 h-4 dark:bg-white bg-black flex items-center justify-center">
|
|
<Check size={10} className="text-contrast" strokeWidth={4} />
|
|
</div>
|
|
) : (
|
|
<div className="rounded-full w-4 h-4 dark:bg-white bg-black flex items-center justify-center">
|
|
<X size={10} className="text-contrast" strokeWidth={4} />
|
|
</div>
|
|
)}
|
|
</div>
|
|
) : (
|
|
<div className="flex items-center gap-x-2 h-[26px] font-mono min-w-[40px]">
|
|
<p className="text-xs">{!value ? '-' : value}</p>
|
|
{!!value && (
|
|
<CopyButton
|
|
iconOnly
|
|
variant="text"
|
|
icon={<Copy />}
|
|
className="transition opacity-0 group-hover:opacity-100 px-1"
|
|
text={value}
|
|
/>
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
<Separator />
|
|
</>
|
|
)
|
|
}
|
|
|
|
export const RowAction = ({
|
|
title,
|
|
description,
|
|
button,
|
|
success,
|
|
className,
|
|
}: {
|
|
title: string
|
|
description: string
|
|
button: {
|
|
icon: ReactNode
|
|
variant?: ComponentProps<typeof Button>['variant']
|
|
text: string
|
|
disabled?: boolean
|
|
isLoading?: boolean
|
|
onClick: () => void
|
|
}
|
|
success?: {
|
|
title: string
|
|
description: string
|
|
}
|
|
className?: string
|
|
}) => {
|
|
const disabled = button?.disabled ?? false
|
|
|
|
return (
|
|
<div className={cn(CONTAINER_CLASS, className)}>
|
|
<div>
|
|
<p>{success ? success.title : title}</p>
|
|
<p className="text-xs text-foreground-light">
|
|
{success ? success.description : description}
|
|
</p>
|
|
</div>
|
|
|
|
<ButtonTooltip
|
|
variant={button?.variant ?? 'default'}
|
|
icon={success ? <Check className="text-brand" /> : button.icon}
|
|
loading={button.isLoading ?? false}
|
|
onClick={button.onClick}
|
|
disabled={disabled}
|
|
tooltip={{
|
|
content: {
|
|
side: 'bottom',
|
|
text: disabled
|
|
? `You need additional permissions to ${button.text.toLowerCase()}`
|
|
: undefined,
|
|
},
|
|
}}
|
|
>
|
|
{button.text}
|
|
</ButtonTooltip>
|
|
</div>
|
|
)
|
|
}
|