[feat][FE] Enable deletion of custom fields in workspace (#4802)

**Context**
Fixes https://github.com/twentyhq/twenty/issues/4597
Enables deletion of custom fields that aren't active nor of type
relation ([BE PR](https://github.com/twentyhq/twenty/pull/4780))

**How was it tested?**
Locally tested

<img width="541" alt="Capture d’écran 2024-04-04 à 13 33 18"
src="https://github.com/twentyhq/twenty/assets/51697796/bc462b86-b494-409e-9836-69bdaeb812cb">
<img width="661" alt="Capture d’écran 2024-04-04 à 13 34 25"
src="https://github.com/twentyhq/twenty/assets/51697796/8fe47114-545e-48b5-a107-34be531b7ea5">
This commit is contained in:
Marie
2024-04-04 13:45:15 +02:00
committed by GitHub
parent b1a586d324
commit 357882c395
2 changed files with 24 additions and 13 deletions

View File

@ -1,4 +1,4 @@
import { IconArchiveOff, IconDotsVertical } from 'twenty-ui';
import { IconArchiveOff, IconDotsVertical, IconTrash } from 'twenty-ui';
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
@ -9,6 +9,7 @@ import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
type SettingsObjectFieldInactiveActionDropdownProps = {
isCustomField?: boolean;
isRelationType?: boolean;
onActivate: () => void;
onErase: () => void;
scopeKey: string;
@ -17,6 +18,9 @@ type SettingsObjectFieldInactiveActionDropdownProps = {
export const SettingsObjectFieldInactiveActionDropdown = ({
onActivate,
scopeKey,
onErase,
isCustomField,
isRelationType,
}: SettingsObjectFieldInactiveActionDropdownProps) => {
const dropdownId = `${scopeKey}-settings-field-disabled-action-dropdown`;
@ -27,10 +31,12 @@ export const SettingsObjectFieldInactiveActionDropdown = ({
closeDropdown();
};
// const handleErase = () => {
// onErase();
// closeDropdown();
// };
const handleErase = () => {
onErase();
closeDropdown();
};
const isErasable = isCustomField && !isRelationType;
return (
<Dropdown
@ -46,14 +52,14 @@ export const SettingsObjectFieldInactiveActionDropdown = ({
LeftIcon={IconArchiveOff}
onClick={handleActivate}
/>
{/* {isCustomField && (
<MenuItem
text="Erase"
accent="danger"
LeftIcon={IconTrash}
onClick={handleErase}
/>
)} */}
{isErasable && (
<MenuItem
text="Erase"
accent="danger"
LeftIcon={IconTrash}
onClick={handleErase}
/>
)}
</DropdownMenuItemsContainer>
</DropdownMenu>
}