Files
twenty/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldActiveActionDropdown.tsx
T
selango1 38a0aae030 Update SettingsObjectAboutSection.tsx changed "Disable" CTA to "Deact… (#4175)
* Update SettingsObjectAboutSection.tsx changed "Disable" CTA to "Deactivate"

* Update SettingsObjects.tsx

Additional changes: Disabled sections to inactive

* Update SettingsObjectAboutSection.tsx

I think you meant changing Disable to Deactivate

* Update and rename SettingsObjectDisabledMenuDropDown.tsx to SettingsObjectInactiveMenuDropDown.tsx

 additional changes to #4153

* Update SettingsObjects.tsx

* Update and rename SettingsObjectDisabledMenuDropDown.stories.tsx to SettingsObjectInactiveMenuDropDown.stories.tsx

* fix typescript errors

* respect issue requirements

---------

Co-authored-by: bosiraphael <raphael.bosi@gmail.com>
2024-03-04 14:59:31 +01:00

86 lines
2.3 KiB
TypeScript

import {
IconArchive,
IconDotsVertical,
IconEye,
IconPencil,
IconTextSize,
} from '@/ui/display/icon';
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 SettingsObjectFieldActiveActionDropdownProps = {
isCustomField?: boolean;
onDeactivate?: () => void;
onEdit: () => void;
onSetAsLabelIdentifier?: () => void;
scopeKey: string;
};
export const SettingsObjectFieldActiveActionDropdown = ({
isCustomField,
onDeactivate,
onEdit,
onSetAsLabelIdentifier,
scopeKey,
}: SettingsObjectFieldActiveActionDropdownProps) => {
const dropdownId = `${scopeKey}-settings-field-active-action-dropdown`;
const { closeDropdown } = useDropdown(dropdownId);
const handleEdit = () => {
onEdit();
closeDropdown();
};
const handleDeactivate = () => {
onDeactivate?.();
closeDropdown();
};
const handleSetAsLabelIdentifier = () => {
onSetAsLabelIdentifier?.();
closeDropdown();
};
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}
/>
{!!onSetAsLabelIdentifier && (
<MenuItem
text="Set as record text"
LeftIcon={IconTextSize}
onClick={handleSetAsLabelIdentifier}
/>
)}
{!!onDeactivate && (
<MenuItem
text="Deactivate"
LeftIcon={IconArchive}
onClick={handleDeactivate}
/>
)}
</DropdownMenuItemsContainer>
</DropdownMenu>
}
dropdownHotkeyScope={{
scope: dropdownId,
}}
/>
);
};