-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Feature 15797 add secondary action button #16582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
etiennejouan
merged 16 commits into
twentyhq:main
from
Lakshayyy-m:feature-15797-add-secondary-action-button
Dec 17, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9517d9e
feat: implement action mode for field displays and settings forms
Lakshayyy-m 0109bb6
fix: Remove unnecessary commenting, console logs and inconsistencies …
Lakshayyy-m b4df3ff
refactor: improve deepMergeZod function to handle object schemas more…
Lakshayyy-m 1cb6205
feat: update icons for clipboard actions and enhance storybook decora…
Lakshayyy-m e7e1171
feat: remove disabled prop from primary action mode form in settings …
Lakshayyy-m e6aab6a
- refined the action button user message and icons
Lakshayyy-m ef1feef
feat: implement action mode for field displays and settings forms
Lakshayyy-m 5b821dd
fix: Remove unnecessary commenting, console logs and inconsistencies …
Lakshayyy-m a39241a
feat: update icons for clipboard actions and enhance storybook decora…
Lakshayyy-m 0f53f5f
Merge branch 'feature-15797-add-secondary-action-button' of https://g…
Lakshayyy-m 66b339e
- Added second action button based on field primary action type
Lakshayyy-m 171aa30
Merge branch 'twentyhq:main' into feature-15797-add-secondary-action-…
Lakshayyy-m 4028039
move logic in dedicated hook + fix lint
etiennejouan ff87bb5
restore default prop
etiennejouan 40f52f8
fix
etiennejouan 2924eb6
Merge branch 'main' into feature-15797-add-secondary-action-button
Lakshayyy-m File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 0 additions & 29 deletions
29
...modules/object-record/record-table/record-table-cell/components/RecordTableCellButton.tsx
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
...odules/object-record/record-table/record-table-cell/components/RecordTableCellButtons.tsx
This file contains hidden or 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,34 @@ | ||
| import styled from '@emotion/styled'; | ||
| import { type IconComponent } from 'twenty-ui/display'; | ||
| import { LightIconButtonGroup } from 'twenty-ui/input'; | ||
| import { MOBILE_VIEWPORT } from 'twenty-ui/theme'; | ||
| import { AnimatedContainer } from 'twenty-ui/utilities'; | ||
|
|
||
| const StyledButtonContainer = styled.div` | ||
| margin: ${({ theme }) => theme.spacing(1)}; | ||
| @media (max-width: ${MOBILE_VIEWPORT}px) { | ||
| position: relative; | ||
| right: 7px; | ||
| } | ||
| border-radius: ${({ theme }) => theme.border.radius.sm}; | ||
| border: 1px solid ${({ theme }) => theme.border.color.strong}; | ||
| `; | ||
|
|
||
| type RecordTableCellButtonsProps = { | ||
| onClick?: () => void; | ||
| Icon: IconComponent; | ||
| }[]; | ||
|
|
||
| export const RecordTableCellButtons = ({ | ||
| buttons, | ||
| }: { | ||
| buttons: RecordTableCellButtonsProps; | ||
| }) => { | ||
| return ( | ||
| <AnimatedContainer> | ||
| <StyledButtonContainer> | ||
| <LightIconButtonGroup size="small" iconButtons={buttons} /> | ||
| </StyledButtonContainer> | ||
| </AnimatedContainer> | ||
| ); | ||
| }; |
This file contains hidden or 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
88 changes: 88 additions & 0 deletions
88
...bject-record/record-table/record-table-cell/hooks/useGetSecondaryRecordTableCellButton.ts
This file contains hidden or 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,88 @@ | ||
| import { FieldContext } from '@/object-record/record-field/ui/contexts/FieldContext'; | ||
| import { | ||
| type FieldEmailsValue, | ||
| type FieldLinksValue, | ||
| type FieldPhonesValue, | ||
| } from '@/object-record/record-field/ui/types/FieldMetadata'; | ||
| import { isFieldEmails } from '@/object-record/record-field/ui/types/guards/isFieldEmails'; | ||
| import { isFieldLinks } from '@/object-record/record-field/ui/types/guards/isFieldLinks'; | ||
| import { isFieldPhones } from '@/object-record/record-field/ui/types/guards/isFieldPhones'; | ||
| import { useRecordFieldValue } from '@/object-record/record-store/hooks/useRecordFieldValue'; | ||
| import { t } from '@lingui/core/macro'; | ||
| import { useContext } from 'react'; | ||
| import { FieldMetadataSettingsOnClickAction } from 'twenty-shared/types'; | ||
| import { getAbsoluteUrl, isDefined } from 'twenty-shared/utils'; | ||
| import { IconArrowUpRight, IconCopy } from 'twenty-ui/display'; | ||
| import { useCopyToClipboard } from '~/hooks/useCopyToClipboard'; | ||
|
|
||
| export const useGetSecondaryRecordTableCellButton = () => { | ||
| const { fieldDefinition, recordId } = useContext(FieldContext); | ||
| const { copyToClipboard } = useCopyToClipboard(); | ||
|
|
||
| const fieldValue = useRecordFieldValue< | ||
| FieldPhonesValue | FieldEmailsValue | FieldLinksValue | undefined | ||
| >(recordId, fieldDefinition.metadata.fieldName, fieldDefinition); | ||
|
|
||
| if ( | ||
| (!isFieldPhones(fieldDefinition) && | ||
| !isFieldLinks(fieldDefinition) && | ||
| !isFieldEmails(fieldDefinition)) || | ||
| !isDefined(fieldValue) | ||
| ) { | ||
| return []; | ||
| } | ||
|
|
||
| const secondaryActionOnClick = | ||
| fieldDefinition.metadata.settings?.clickAction === | ||
| FieldMetadataSettingsOnClickAction.OPEN_LINK | ||
| ? FieldMetadataSettingsOnClickAction.COPY | ||
| : FieldMetadataSettingsOnClickAction.OPEN_LINK; | ||
|
|
||
| let openLinkOnClick: () => void = () => {}; | ||
| let copyOnClick: () => void = () => {}; | ||
|
|
||
| if (isFieldPhones(fieldDefinition)) { | ||
| const { primaryPhoneCallingCode = '', primaryPhoneNumber = '' } = | ||
| fieldValue as FieldPhonesValue; | ||
| const phoneNumber = `${primaryPhoneCallingCode}${primaryPhoneNumber}`; | ||
| openLinkOnClick = () => { | ||
| window.open(`tel:${phoneNumber}`, '_blank'); | ||
| }; | ||
| copyOnClick = () => { | ||
| copyToClipboard(phoneNumber, t`Phone number copied to clipboard`); | ||
| }; | ||
| } | ||
|
|
||
| if (isFieldEmails(fieldDefinition)) { | ||
| const email = (fieldValue as FieldEmailsValue).primaryEmail ?? ''; | ||
| openLinkOnClick = () => { | ||
| window.open(`mailto:${email}`, '_blank'); | ||
| }; | ||
| copyOnClick = () => { | ||
| copyToClipboard(email, t`Email copied to clipboard`); | ||
| }; | ||
| } | ||
|
|
||
| if (isFieldLinks(fieldDefinition)) { | ||
| const url = (fieldValue as FieldLinksValue).primaryLinkUrl ?? ''; | ||
| openLinkOnClick = () => { | ||
| window.open(getAbsoluteUrl(url), '_blank'); | ||
| }; | ||
| copyOnClick = () => { | ||
| copyToClipboard(url, t`Link copied to clipboard`); | ||
| }; | ||
| } | ||
|
|
||
| return [ | ||
| { | ||
| onClick: | ||
| secondaryActionOnClick === FieldMetadataSettingsOnClickAction.OPEN_LINK | ||
| ? openLinkOnClick | ||
| : copyOnClick, | ||
| Icon: | ||
| secondaryActionOnClick === FieldMetadataSettingsOnClickAction.OPEN_LINK | ||
| ? IconArrowUpRight | ||
| : IconCopy, | ||
| }, | ||
| ]; | ||
| }; |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.