Enable deletion of relation fields (#5338)

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")
This commit is contained in:
Marie
2024-05-13 17:43:51 +02:00
committed by GitHub
parent 0018ec78b0
commit b9154f315e
30 changed files with 519 additions and 117 deletions

View File

@ -10,14 +10,14 @@ import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
type SettingsObjectInactiveMenuDropDownProps = {
isCustomObject: boolean;
onActivate: () => void;
onErase: () => void;
onDelete: () => void;
scopeKey: string;
};
export const SettingsObjectInactiveMenuDropDown = ({
onActivate,
scopeKey,
onErase,
onDelete,
isCustomObject,
}: SettingsObjectInactiveMenuDropDownProps) => {
const dropdownId = `${scopeKey}-settings-object-inactive-menu-dropdown`;
@ -29,8 +29,8 @@ export const SettingsObjectInactiveMenuDropDown = ({
closeDropdown();
};
const handleErase = () => {
onErase();
const handleDelete = () => {
onDelete();
closeDropdown();
};
@ -50,10 +50,10 @@ export const SettingsObjectInactiveMenuDropDown = ({
/>
{isCustomObject && (
<MenuItem
text="Erase"
text="Delete"
LeftIcon={IconTrash}
accent="danger"
onClick={handleErase}
onClick={handleDelete}
/>
)}
</DropdownMenuItemsContainer>

View File

@ -5,12 +5,12 @@ import { ComponentDecorator } from 'twenty-ui';
import { SettingsObjectInactiveMenuDropDown } from '../SettingsObjectInactiveMenuDropDown';
const handleActivateMockFunction = fn();
const handleEraseMockFunction = fn();
const handleDeleteMockFunction = fn();
const ClearMocksDecorator: Decorator = (Story, context) => {
if (context.parameters.clearMocks === true) {
handleActivateMockFunction.mockClear();
handleEraseMockFunction.mockClear();
handleDeleteMockFunction.mockClear();
}
return <Story />;
};
@ -21,7 +21,7 @@ const meta: Meta<typeof SettingsObjectInactiveMenuDropDown> = {
args: {
scopeKey: 'settings-object-inactive-menu-dropdown',
onActivate: handleActivateMockFunction,
onErase: handleEraseMockFunction,
onDelete: handleDeleteMockFunction,
},
decorators: [ComponentDecorator, ClearMocksDecorator],
parameters: {
@ -64,7 +64,7 @@ export const WithActivate: Story = {
},
};
export const WithErase: Story = {
export const WithDelete: Story = {
args: { isCustomObject: true },
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
@ -73,13 +73,13 @@ export const WithErase: Story = {
await userEvent.click(dropdownButton);
await expect(handleEraseMockFunction).toHaveBeenCalledTimes(0);
await expect(handleDeleteMockFunction).toHaveBeenCalledTimes(0);
const eraseMenuItem = await canvas.getByText('Erase');
const deleteMenuItem = await canvas.getByText('Delete');
await userEvent.click(eraseMenuItem);
await userEvent.click(deleteMenuItem);
await expect(handleEraseMockFunction).toHaveBeenCalledTimes(1);
await expect(handleDeleteMockFunction).toHaveBeenCalledTimes(1);
await userEvent.click(dropdownButton);
},