This PR was created by [GitStart](https://gitstart.com/) to address the requirements from this ticket: [TWNTY-7529](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-7529). --- ### Description - Migrated all button components to `twenty-ui` \ \ `Button`\ `ButtonGroup`\ `ColorPickerButton`\ `FloatingButton`\ `FloatingButtonGroup`\ `FloatingIconButton`\ `FloatingIconButtonGroup`\ `IconButton`\ `IconButtonGroup`\ `LightButton`\ `LightIconButton`\ `LightIconButtonGroup`\ `MainButton`\ \ Fixes twentyhq/private-issues#89 Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: Charles Bochet <charles@twenty.com>
90 lines
2.3 KiB
TypeScript
90 lines
2.3 KiB
TypeScript
import {
|
|
IconArchiveOff,
|
|
IconDotsVertical,
|
|
IconEye,
|
|
IconPencil,
|
|
IconTrash,
|
|
LightIconButton,
|
|
} from 'twenty-ui';
|
|
|
|
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';
|
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
|
|
|
type SettingsObjectFieldInactiveActionDropdownProps = {
|
|
isCustomField?: boolean;
|
|
fieldType?: FieldMetadataType;
|
|
onActivate: () => void;
|
|
onEdit: () => void;
|
|
onDelete: () => void;
|
|
scopeKey: string;
|
|
};
|
|
|
|
export const SettingsObjectFieldInactiveActionDropdown = ({
|
|
onActivate,
|
|
scopeKey,
|
|
onDelete,
|
|
onEdit,
|
|
isCustomField,
|
|
}: SettingsObjectFieldInactiveActionDropdownProps) => {
|
|
const dropdownId = `${scopeKey}-settings-field-disabled-action-dropdown`;
|
|
|
|
const { closeDropdown } = useDropdown(dropdownId);
|
|
|
|
const handleActivate = () => {
|
|
onActivate();
|
|
closeDropdown();
|
|
};
|
|
|
|
const handleDelete = () => {
|
|
onDelete();
|
|
closeDropdown();
|
|
};
|
|
|
|
const handleEdit = () => {
|
|
onEdit();
|
|
closeDropdown();
|
|
};
|
|
|
|
const isDeletable = isCustomField;
|
|
|
|
return (
|
|
<Dropdown
|
|
dropdownId={dropdownId}
|
|
clickableComponent={
|
|
<LightIconButton Icon={IconDotsVertical} accent="tertiary" />
|
|
}
|
|
dropdownComponents={
|
|
<DropdownMenu width="160px">
|
|
<DropdownMenuItemsContainer>
|
|
<MenuItem
|
|
text={isCustomField ? 'Edit' : 'View'}
|
|
LeftIcon={isCustomField ? IconPencil : IconEye}
|
|
onClick={handleEdit}
|
|
/>
|
|
<MenuItem
|
|
text="Activate"
|
|
LeftIcon={IconArchiveOff}
|
|
onClick={handleActivate}
|
|
/>
|
|
{isDeletable && (
|
|
<MenuItem
|
|
text="Delete"
|
|
accent="danger"
|
|
LeftIcon={IconTrash}
|
|
onClick={handleDelete}
|
|
/>
|
|
)}
|
|
</DropdownMenuItemsContainer>
|
|
</DropdownMenu>
|
|
}
|
|
dropdownHotkeyScope={{
|
|
scope: dropdownId,
|
|
}}
|
|
/>
|
|
);
|
|
};
|