Files
twenty/packages/twenty-front/src/modules/activities/files/components/AttachmentDropdown.tsx
T
Harsh Singh 6d62dd9fd1 fix: object activate dropdown (#8438)
Fixes: #8436 
Fixes: #8435 
& other duplicate ```DropdownMenu```
2024-11-11 09:26:07 +01:00

79 lines
1.7 KiB
TypeScript

import {
IconDotsVertical,
IconDownload,
IconPencil,
IconTrash,
LightIconButton,
MenuItem,
} from 'twenty-ui';
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
type AttachmentDropdownProps = {
onDownload: () => void;
onDelete: () => void;
onRename: () => void;
scopeKey: string;
};
export const AttachmentDropdown = ({
onDownload,
onDelete,
onRename,
scopeKey,
}: AttachmentDropdownProps) => {
const dropdownId = `${scopeKey}-settings-field-active-action-dropdown`;
const { closeDropdown } = useDropdown(dropdownId);
const handleDownload = () => {
onDownload();
closeDropdown();
};
const handleDelete = () => {
onDelete();
closeDropdown();
};
const handleRename = () => {
onRename();
closeDropdown();
};
return (
<Dropdown
dropdownId={dropdownId}
clickableComponent={
<LightIconButton Icon={IconDotsVertical} accent="tertiary" />
}
dropdownMenuWidth={160}
dropdownComponents={
<DropdownMenuItemsContainer>
<MenuItem
text="Download"
LeftIcon={IconDownload}
onClick={handleDownload}
/>
<MenuItem
text="Rename"
LeftIcon={IconPencil}
onClick={handleRename}
/>
<MenuItem
text="Delete"
accent="danger"
LeftIcon={IconTrash}
onClick={handleDelete}
/>
</DropdownMenuItemsContainer>
}
dropdownHotkeyScope={{
scope: dropdownId,
}}
/>
);
};