In this PR 1. Enable deletion of relation fields in the product and via the api (migration part was missing in the api) 3. Change wording, only use "deactivate" and "delete" everywhere (and not a mix of the two + "disable", "erase")
68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
import { IconArchiveOff, IconDotsVertical, IconTrash } from 'twenty-ui';
|
|
|
|
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
|
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
|
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
|
|
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
|
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
|
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
|
|
|
|
type SettingsObjectInactiveMenuDropDownProps = {
|
|
isCustomObject: boolean;
|
|
onActivate: () => void;
|
|
onDelete: () => void;
|
|
scopeKey: string;
|
|
};
|
|
|
|
export const SettingsObjectInactiveMenuDropDown = ({
|
|
onActivate,
|
|
scopeKey,
|
|
onDelete,
|
|
isCustomObject,
|
|
}: SettingsObjectInactiveMenuDropDownProps) => {
|
|
const dropdownId = `${scopeKey}-settings-object-inactive-menu-dropdown`;
|
|
|
|
const { closeDropdown } = useDropdown(dropdownId);
|
|
|
|
const handleActivate = () => {
|
|
onActivate();
|
|
closeDropdown();
|
|
};
|
|
|
|
const handleDelete = () => {
|
|
onDelete();
|
|
closeDropdown();
|
|
};
|
|
|
|
return (
|
|
<Dropdown
|
|
dropdownId={dropdownId}
|
|
clickableComponent={
|
|
<LightIconButton Icon={IconDotsVertical} accent="tertiary" />
|
|
}
|
|
dropdownComponents={
|
|
<DropdownMenu width="160px">
|
|
<DropdownMenuItemsContainer>
|
|
<MenuItem
|
|
text="Activate"
|
|
LeftIcon={IconArchiveOff}
|
|
onClick={handleActivate}
|
|
/>
|
|
{isCustomObject && (
|
|
<MenuItem
|
|
text="Delete"
|
|
LeftIcon={IconTrash}
|
|
accent="danger"
|
|
onClick={handleDelete}
|
|
/>
|
|
)}
|
|
</DropdownMenuItemsContainer>
|
|
</DropdownMenu>
|
|
}
|
|
dropdownHotkeyScope={{
|
|
scope: dropdownId,
|
|
}}
|
|
/>
|
|
);
|
|
};
|