[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:
@ -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 { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
||||||
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
||||||
@ -9,6 +9,7 @@ import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
|
|||||||
|
|
||||||
type SettingsObjectFieldInactiveActionDropdownProps = {
|
type SettingsObjectFieldInactiveActionDropdownProps = {
|
||||||
isCustomField?: boolean;
|
isCustomField?: boolean;
|
||||||
|
isRelationType?: boolean;
|
||||||
onActivate: () => void;
|
onActivate: () => void;
|
||||||
onErase: () => void;
|
onErase: () => void;
|
||||||
scopeKey: string;
|
scopeKey: string;
|
||||||
@ -17,6 +18,9 @@ type SettingsObjectFieldInactiveActionDropdownProps = {
|
|||||||
export const SettingsObjectFieldInactiveActionDropdown = ({
|
export const SettingsObjectFieldInactiveActionDropdown = ({
|
||||||
onActivate,
|
onActivate,
|
||||||
scopeKey,
|
scopeKey,
|
||||||
|
onErase,
|
||||||
|
isCustomField,
|
||||||
|
isRelationType,
|
||||||
}: SettingsObjectFieldInactiveActionDropdownProps) => {
|
}: SettingsObjectFieldInactiveActionDropdownProps) => {
|
||||||
const dropdownId = `${scopeKey}-settings-field-disabled-action-dropdown`;
|
const dropdownId = `${scopeKey}-settings-field-disabled-action-dropdown`;
|
||||||
|
|
||||||
@ -27,10 +31,12 @@ export const SettingsObjectFieldInactiveActionDropdown = ({
|
|||||||
closeDropdown();
|
closeDropdown();
|
||||||
};
|
};
|
||||||
|
|
||||||
// const handleErase = () => {
|
const handleErase = () => {
|
||||||
// onErase();
|
onErase();
|
||||||
// closeDropdown();
|
closeDropdown();
|
||||||
// };
|
};
|
||||||
|
|
||||||
|
const isErasable = isCustomField && !isRelationType;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropdown
|
<Dropdown
|
||||||
@ -46,14 +52,14 @@ export const SettingsObjectFieldInactiveActionDropdown = ({
|
|||||||
LeftIcon={IconArchiveOff}
|
LeftIcon={IconArchiveOff}
|
||||||
onClick={handleActivate}
|
onClick={handleActivate}
|
||||||
/>
|
/>
|
||||||
{/* {isCustomField && (
|
{isErasable && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
text="Erase"
|
text="Erase"
|
||||||
accent="danger"
|
accent="danger"
|
||||||
LeftIcon={IconTrash}
|
LeftIcon={IconTrash}
|
||||||
onClick={handleErase}
|
onClick={handleErase}
|
||||||
/>
|
/>
|
||||||
)} */}
|
)}
|
||||||
</DropdownMenuItemsContainer>
|
</DropdownMenuItemsContainer>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,7 @@ import { Table } from '@/ui/layout/table/components/Table';
|
|||||||
import { TableHeader } from '@/ui/layout/table/components/TableHeader';
|
import { TableHeader } from '@/ui/layout/table/components/TableHeader';
|
||||||
import { TableSection } from '@/ui/layout/table/components/TableSection';
|
import { TableSection } from '@/ui/layout/table/components/TableSection';
|
||||||
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||||
|
|
||||||
const StyledDiv = styled.div`
|
const StyledDiv = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -188,6 +189,10 @@ export const SettingsObjectDetail = () => {
|
|||||||
ActionIcon={
|
ActionIcon={
|
||||||
<SettingsObjectFieldInactiveActionDropdown
|
<SettingsObjectFieldInactiveActionDropdown
|
||||||
isCustomField={!!disabledMetadataField.isCustom}
|
isCustomField={!!disabledMetadataField.isCustom}
|
||||||
|
isRelationType={
|
||||||
|
disabledMetadataField.type ===
|
||||||
|
FieldMetadataType.Relation
|
||||||
|
}
|
||||||
scopeKey={disabledMetadataField.id}
|
scopeKey={disabledMetadataField.id}
|
||||||
onActivate={() =>
|
onActivate={() =>
|
||||||
activateMetadataField(disabledMetadataField)
|
activateMetadataField(disabledMetadataField)
|
||||||
|
|||||||
Reference in New Issue
Block a user