mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
Extract shared Auth user cards and copyable detail fields, and use the shared raw-JSON display in the user panel. The existing Logs view remains available; unified activity timelines and log-user filtering arrive separately in #50837. This includes display-name/initials coverage and the Auth panel's component and browser tests. The browser test now verifies keyboard copying and Escape panel dismissal separately: the existing Auth Escape shortcut closes the details panel, so expecting it to restore focus to a field was incorrect. Its Raw JSON check reads the copied JSON's fields, since the code view's text includes line numbers. `UserCard` is Studio's first `Avatar`, so `vite.config.ts` pins `avatar.tsx` to its own chunk, like `field`, `drawer` and `slider`. Otherwise Rolldown pools it into the Auth `users` page chunk that the `ui` barrel then imports back, a chunk cycle that fails the TanStack build. ### How to test 1. Open an existing user in Authentication → Users. Check the profile card, overview fields, and name/avatar fallbacks for a user without profile metadata. 2. Open a copyable field using both mouse and keyboard (Enter), choose Copy, and check the clipboard value. 3. Open Raw JSON, scroll, and use the floating copy button. Confirm the existing Logs tab still opens and Escape closes the user panel. ### Validation - Final head `f4f8cb22e97fefac56c68b4676184d8358d8080e` targets master without conflicts. - Focused local tests: 13 passed across three files, retries disabled, including independent shuffled seed 5084131. Real panel/MSW tests cover field copying and complete nested JSON; fallback and Unicode regressions detect the original broken behavior. - Browser QA passed on `6b49434339`: nameless profile fallback, overview fields, mouse/keyboard copying, Raw JSON scrolling/copying, existing Logs tab, and Escape dismissal. Later commits change only the E2E test; application code is identical. - All GitHub checks passed on the final head, including four unit-test shards, four Next/TanStack E2E shards, typecheck, formatting, lint ratchet, knip, and Studio Docker build. - Independent review found no remaining issues; all review threads are resolved. - Fresh final-head studio-staging preview is blocked during dependency installation: the registry returns HTTP 451 for `react-hook-form@7.72.1`. The earlier matching application preview passed browser QA; this deployment failure remains visible. ### Stack Based on the logs table building blocks stack, which merges first: #50953 → #50954 → #50955 → #50957 → #50958 → #52281. Then merge in order: 1. #50835 — grouped log overviews and raw JSON 2. #50840 — request correlation queries 3. #50836 — request timeline UI and folding 4. #50841 — shared Auth user details 5. #50837 — log user correlation and Auth activity --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Jordi Enric <jordi.err@gmail.com>
78 lines
2.4 KiB
TypeScript
78 lines
2.4 KiB
TypeScript
import { ChevronRightIcon, UserRoundIcon } from 'lucide-react'
|
|
import type { ReactNode } from 'react'
|
|
import { Avatar, AvatarFallback, AvatarImage, cn } from 'ui'
|
|
|
|
import { getUserInitials, getUserPrimaryLabel } from './UserCard.utils'
|
|
import { getAvatarUrl, getDisplayName } from './Users.utils'
|
|
import type { User } from '@/data/auth/users-infinite-query'
|
|
|
|
interface UserCardProps {
|
|
user: User
|
|
variant?: 'default' | 'outline'
|
|
href?: string
|
|
linkLabel?: string
|
|
actions?: ReactNode
|
|
className?: string
|
|
}
|
|
|
|
export function UserCard({
|
|
user,
|
|
variant = 'default',
|
|
href,
|
|
linkLabel,
|
|
actions,
|
|
className,
|
|
}: UserCardProps) {
|
|
const primaryLabel = getUserPrimaryLabel(user)
|
|
const hasDisplayName = !!getDisplayName(user, '').trim()
|
|
const secondaryLabel = hasDisplayName ? (user.email ?? user.phone) : undefined
|
|
const initials = getUserInitials(user)
|
|
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'relative flex min-w-0 items-center gap-3 px-4 py-3',
|
|
variant === 'outline' && 'rounded-md border border-strong px-3 py-2.5',
|
|
!!href && 'transition hover:border-foreground-muted hover:bg-surface-100',
|
|
className
|
|
)}
|
|
>
|
|
{href && (
|
|
<a
|
|
href={href}
|
|
aria-label={linkLabel ?? primaryLabel}
|
|
className={cn(
|
|
'absolute inset-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground-muted',
|
|
variant === 'outline' && 'rounded-md'
|
|
)}
|
|
/>
|
|
)}
|
|
<Avatar className="h-7 w-7 shrink-0">
|
|
<AvatarImage src={getAvatarUrl(user)} alt="" />
|
|
<AvatarFallback className="bg-surface-300 text-xs text-foreground-light">
|
|
{initials || <UserRoundIcon size={14} strokeWidth={1.5} aria-hidden />}
|
|
</AvatarFallback>
|
|
</Avatar>
|
|
<div className="flex min-w-0 flex-1 flex-col">
|
|
<p className="truncate text-sm text-foreground" title={primaryLabel}>
|
|
{primaryLabel}
|
|
</p>
|
|
{secondaryLabel && (
|
|
<p className="truncate text-xs text-foreground-lighter" title={secondaryLabel}>
|
|
{secondaryLabel}
|
|
</p>
|
|
)}
|
|
</div>
|
|
{actions && <div className="relative flex shrink-0 items-center gap-1">{actions}</div>}
|
|
{href && (
|
|
<ChevronRightIcon
|
|
size={14}
|
|
strokeWidth={1.5}
|
|
aria-hidden
|
|
className="shrink-0 text-foreground-lighter"
|
|
/>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|