forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove a link from a Links field (twentyhq#5313)
Closes twentyhq#5117 TO FIX in another PR: right now, the "Vertical Dots" LightIconButton inside the Dropdown menu sometimes needs to be clicked twice to open the nested dropdown, not sure why 🤔 Maybe an `event.preventDefault()` is needed somewhere? <img width="369" alt="image" src="https://github.com/twentyhq/twenty/assets/3098428/dd0c771a-c18d-4eb2-8ed6-b107f56711e9"> --------- Co-authored-by: Jérémy Magrin <[email protected]> Co-authored-by: Charles Bochet <[email protected]>
- Loading branch information
1 parent
beaaf33
commit 4800388
Showing
11 changed files
with
159 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...src/modules/object-record/record-field/meta-types/input/components/LinksFieldMenuItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import styled from '@emotion/styled'; | ||
import { | ||
IconBookmark, | ||
IconComponent, | ||
IconDotsVertical, | ||
IconTrash, | ||
} from 'twenty-ui'; | ||
|
||
import { LinkDisplay } from '@/ui/field/display/components/LinkDisplay'; | ||
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; | ||
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 LinksFieldMenuItemProps = { | ||
dropdownId: string; | ||
isPrimary?: boolean; | ||
label: string; | ||
onDelete: () => void; | ||
url: string; | ||
}; | ||
|
||
const StyledIconBookmark = styled(IconBookmark)` | ||
color: ${({ theme }) => theme.font.color.light}; | ||
height: ${({ theme }) => theme.icon.size.sm}px; | ||
width: ${({ theme }) => theme.icon.size.sm}px; | ||
`; | ||
|
||
export const LinksFieldMenuItem = ({ | ||
dropdownId, | ||
isPrimary, | ||
label, | ||
onDelete, | ||
url, | ||
}: LinksFieldMenuItemProps) => { | ||
const { isDropdownOpen } = useDropdown(dropdownId); | ||
|
||
return ( | ||
<MenuItem | ||
text={<LinkDisplay value={{ label, url }} />} | ||
isIconDisplayedOnHoverOnly={!isPrimary && !isDropdownOpen} | ||
iconButtons={[ | ||
{ | ||
Wrapper: isPrimary | ||
? undefined | ||
: ({ iconButton }) => ( | ||
<Dropdown | ||
dropdownId={dropdownId} | ||
dropdownHotkeyScope={{ | ||
scope: dropdownId, | ||
}} | ||
dropdownPlacement="right-start" | ||
dropdownStrategy="fixed" | ||
disableBlur | ||
clickableComponent={iconButton} | ||
dropdownComponents={ | ||
<DropdownMenuItemsContainer> | ||
<MenuItem | ||
accent="danger" | ||
LeftIcon={IconTrash} | ||
text="Delete" | ||
onClick={onDelete} | ||
/> | ||
</DropdownMenuItemsContainer> | ||
} | ||
/> | ||
), | ||
Icon: isPrimary | ||
? (StyledIconBookmark as IconComponent) | ||
: IconDotsVertical, | ||
accent: 'tertiary', | ||
onClick: isPrimary ? undefined : () => {}, | ||
}, | ||
]} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.