feat: enable right-click context menu on subscription cards

This commit is contained in:
ezequielnick 2025-06-06 12:53:12 +08:00
parent daa8e7ba7e
commit d6e456302e

View File

@ -60,6 +60,7 @@ const ProfileItem: React.FC<Props> = (props) => {
const [selecting, setSelecting] = useState(false) const [selecting, setSelecting] = useState(false)
const [openInfoEditor, setOpenInfoEditor] = useState(false) const [openInfoEditor, setOpenInfoEditor] = useState(false)
const [openFileEditor, setOpenFileEditor] = useState(false) const [openFileEditor, setOpenFileEditor] = useState(false)
const [dropdownOpen, setDropdownOpen] = useState(false)
const { const {
attributes, attributes,
listeners, listeners,
@ -143,6 +144,12 @@ const ProfileItem: React.FC<Props> = (props) => {
} }
} }
const handleContextMenu = (e: React.MouseEvent) => {
e.preventDefault()
e.stopPropagation()
setDropdownOpen(true)
}
useEffect(() => { useEffect(() => {
if (isDragging) { if (isDragging) {
setTimeout(() => { setTimeout(() => {
@ -155,6 +162,8 @@ const ProfileItem: React.FC<Props> = (props) => {
} }
}, [isDragging]) }, [isDragging])
return ( return (
<div <div
className="grid col-span-1" className="grid col-span-1"
@ -173,6 +182,7 @@ const ProfileItem: React.FC<Props> = (props) => {
updateProfileItem={updateProfileItem} updateProfileItem={updateProfileItem}
/> />
)} )}
<Card <Card
as="div" as="div"
fullWidth fullWidth
@ -184,6 +194,7 @@ const ProfileItem: React.FC<Props> = (props) => {
setSelecting(false) setSelecting(false)
}) })
}} }}
onContextMenu={handleContextMenu}
className={`${isCurrent ? 'bg-primary' : ''} ${selecting ? 'blur-sm' : ''}`} className={`${isCurrent ? 'bg-primary' : ''} ${selecting ? 'blur-sm' : ''}`}
> >
<div ref={setNodeRef} {...attributes} {...listeners} className="w-full h-full"> <div ref={setNodeRef} {...attributes} {...listeners} className="w-full h-full">
@ -218,7 +229,10 @@ const ProfileItem: React.FC<Props> = (props) => {
</Tooltip> </Tooltip>
)} )}
<Dropdown> <Dropdown
isOpen={dropdownOpen}
onOpenChange={setDropdownOpen}
>
<DropdownTrigger> <DropdownTrigger>
<Button isIconOnly size="sm" variant="light" color="default"> <Button isIconOnly size="sm" variant="light" color="default">
<IoMdMore <IoMdMore