mirror of
https://github.com/supabase/supabase.git
synced 2026-07-06 13:44:23 +08:00
* Set up banning and unbanning user, although untested due to API CORs issue * Update search filter UI for users management V2 * Update API types * Minoir * Small fix * Update UI * Add support for resizing and re-ordering columns * Add google profile image url to csp * Revert test button * Implement toggling of columns * Fix loading * Fully implement banning/unbanning user * Fix * Update apps/studio/components/interfaces/Auth/Users/UserOverview.tsx Co-authored-by: Alaister Young <alaister@users.noreply.github.com> * Fallback non CSP supported avatar urls to user icon * Fix some bugs * Remove prism-react-renderer from studio, add to ui patterns * Migrate users query from API to studio * Address some feedback --------- Co-authored-by: Alaister Young <alaister@users.noreply.github.com>
75 lines
2.2 KiB
TypeScript
75 lines
2.2 KiB
TypeScript
import { ChevronDown, SortAsc, SortDesc } from 'lucide-react'
|
|
import { useEffect, useRef, useState } from 'react'
|
|
import {
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from 'ui'
|
|
|
|
export const HeaderCell = ({
|
|
col,
|
|
setSortByValue,
|
|
}: {
|
|
col: any
|
|
setSortByValue: (value: string) => void
|
|
}) => {
|
|
const ref = useRef<number>(0)
|
|
const [open, setOpen] = useState(false)
|
|
|
|
useEffect(() => {
|
|
ref.current = Number(new Date())
|
|
}, [open])
|
|
|
|
return (
|
|
<div className="flex items-center justify-between font-normal text-xs w-full">
|
|
<div className="flex items-center gap-x-2">
|
|
<p className="!text-foreground">{col.name}</p>
|
|
</div>
|
|
{['created_at', 'email', 'phone'].includes(col.id) && (
|
|
<DropdownMenu
|
|
open={open}
|
|
onOpenChange={(val) => {
|
|
// [Joshen] This is a temp hack between the DropdownMenu and react data grid
|
|
// as the header cell is selectable, which takes the focus away from the dropdown menu
|
|
// causing it to close immediately.
|
|
if (val === false && Number(new Date()) - ref.current > 100) setOpen(val)
|
|
}}
|
|
>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
type="text"
|
|
icon={<ChevronDown />}
|
|
className="p-0 h-5 w-5"
|
|
onClick={() => setOpen(!open)}
|
|
/>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent className="w-36">
|
|
<DropdownMenuItem
|
|
className="flex items-center gap-x-2"
|
|
onClick={() => {
|
|
setOpen(false)
|
|
setSortByValue(`${col.id}:desc`)
|
|
}}
|
|
>
|
|
<SortDesc size={14} />
|
|
Sort descending
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem
|
|
className="flex items-center gap-x-2"
|
|
onClick={() => {
|
|
setOpen(false)
|
|
setSortByValue(`${col.id}:asc`)
|
|
}}
|
|
>
|
|
<SortAsc size={14} />
|
|
Sort ascending
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|