-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Object conversion functionality #10459
base: main
Are you sure you want to change the base?
Conversation
Welcome!
Hello there, congrats on your first PR! We're excited to have you contributing to this project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
working on object to object conversion functionality - see issue #10422.
Some testing taking place still
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
working on object to object conversion functionality - see issue #10422.
Some testing taking place still
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR introduces a comprehensive lead conversion system with templates and field mapping functionality. The implementation spans both frontend and backend, enabling conversion of leads to other object types with customizable templates and field mappings.
- Added
ConversionTemplateEntity
in/packages/twenty-server/src/modules/lead/conversion-templates/conversion-template.entity.ts
with field mapping rules, conversion settings, and matching rules - Implemented
LeadConversionService
in/packages/twenty-server/src/modules/lead/services/lead-conversion.service.ts
with transaction management and field mapping logic, thoughcreateRelations
method needs implementation - Added frontend components in
/packages/twenty-front/src/modules/lead/components/ConversionTemplates/
for template management UI with drag-and-drop functionality - Introduced GraphQL operations in
/packages/twenty-front/src/modules/lead/graphql/
for template CRUD and lead conversion, but lacks proper type definitions forfieldMappingRules
- Added standard object metadata in
/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/
for lead entity configuration, including icons and field IDs
💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!
20 file(s) reviewed, 32 comment(s)
Edit PR Review Bot Settings | Greptile
); | ||
|
||
const handleDragEnd = useCallback( | ||
(result: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Replace 'any' with proper type definition from react-beautiful-dnd (DragEndResult)
(result: any) => { | |
(result: DragEndResult) => { |
<Droppable droppableId="templates"> | ||
{(provided) => ( | ||
<div {...provided.droppableProps} ref={provided.innerRef}> | ||
{data?.conversionTemplates.map((template: any, index: number) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Replace 'any' with proper interface for template object
|
||
const selectedTemplate = selectedTemplateId | ||
? templatesData?.availableTemplatesForLead.find( | ||
(t: any) => t.id === selectedTemplateId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: avoid using 'any' type - define an interface for the template object structure
(t: any) => t.id === selectedTemplateId, | |
(t: { id: string; name: string; targetObjectType: string; description?: string }) => t.id === selectedTemplateId, |
if (data.convertLead.success) { | ||
enqueueSnackBar('Lead converted successfully', { | ||
variant: 'success', | ||
}); | ||
onConversionSuccess?.( | ||
data.convertLead.convertedObjectId, | ||
data.convertLead.convertedObjectType, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: should handle case where data.convertLead exists but success is false - currently modal closes without error message
if (data.convertLead.success) { | |
enqueueSnackBar('Lead converted successfully', { | |
variant: 'success', | |
}); | |
onConversionSuccess?.( | |
data.convertLead.convertedObjectId, | |
data.convertLead.convertedObjectType, | |
); | |
} | |
if (data.convertLead.success) { | |
enqueueSnackBar('Lead converted successfully', { | |
variant: 'success', | |
}); | |
onConversionSuccess?.( | |
data.convertLead.convertedObjectId, | |
data.convertLead.convertedObjectType, | |
); | |
handleCloseModal(); | |
} else { | |
enqueueSnackBar('Failed to convert lead', { variant: 'error' }); | |
} |
<Button | ||
variant="secondary" | ||
onClick={handleOpenModal} | ||
icon={<IconArrowRight />} | ||
> | ||
Convert | ||
</Button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: consider disabling button when no templates are available
private async createRelations( | ||
queryRunner: any, | ||
workspaceId: string, | ||
lead: LeadWorkspaceEntity, | ||
convertedObjectId: string, | ||
targetObjectMetadata: any, | ||
) { | ||
// Implementation will depend on the specific relations needed | ||
// For example, creating task relations, note relations, etc. | ||
// This would involve: | ||
// 1. Identifying relevant relations from the lead | ||
// 2. Creating corresponding relations for the converted object | ||
// 3. Updating any reference tables as needed | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: createRelations method is incomplete and needs implementation before production use
sourceField: leadField.name, | ||
targetField: matchingFields[0].name, // Use the first match | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Taking first match without considering field compatibility could lead to incorrect mappings
import { WorkspaceIsNotAuditLogged } from 'src/engine/twenty-orm/decorators/workspace-is-not-audit-logged.decorator'; | ||
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator'; | ||
import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator'; | ||
import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: WorkspaceJoinColumn is imported but never used in this file
import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator'; |
getTsVectorColumnExpressionFromFields, | ||
} from 'src/engine/workspace-manager/workspace-sync-metadata/utils/get-ts-vector-column-expression.util'; | ||
import { AttachmentWorkspaceEntity } from 'src/modules/attachment/standard-objects/attachment.workspace-entity'; | ||
import { CompanyWorkspaceEntity } from 'src/modules/company/standard-objects/company.workspace-entity'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: CompanyWorkspaceEntity is imported but never used in this file
import { CompanyWorkspaceEntity } from 'src/modules/company/standard-objects/company.workspace-entity'; |
MessagingModule, | ||
LeadModule, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: LeadModule depends on FavoriteModule (via lead.workspace-entity.ts) but is imported before it. Consider moving LeadModule after FavoriteModule to avoid potential initialization issues.
Are you an AI :) ? Thanks for this. We love contributions, but please work with us before putting too much time into this because we're usually quite opioniated about how we want to build things, so this might end up being closed. Could you please share a screenshot? I couldn't start the project locally on your branch, there were frontend errors. |
Nope not an AI - just a CRM nerd. This was my first PR ever! I'm still
going through testing on my side so will work out the fixes sure and re
submit. If you don't like the changes I can always keep a local copy for
myself as I need this function 😅
…On Mon, 24 Feb 2025, 21:20 Félix Malfait, ***@***.***> wrote:
Are you an AI :) ?
Thanks for this. We love contributions, but please work with us before
putting too much time into this because we're usually quite opioniated
about how we want to build things, so this might end up being closed. Could
you please share a screenshot? I couldn't start the project locally on your
branch, there were frontend errors.
—
Reply to this email directly, view it on GitHub
<#10459 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFKPXTE2WMAXW673KWF2L32ROEJHAVCNFSM6AAAAABXYWBWSWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZZGY3TINBQGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
[image: FelixMalfait]*FelixMalfait* left a comment (twentyhq/twenty#10459)
<#10459 (comment)>
Are you an AI :) ?
Thanks for this. We love contributions, but please work with us before
putting too much time into this because we're usually quite opioniated
about how we want to build things, so this might end up being closed. Could
you please share a screenshot? I couldn't start the project locally on your
branch, there were frontend errors.
—
Reply to this email directly, view it on GitHub
<#10459 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFKPXTE2WMAXW673KWF2L32ROEJHAVCNFSM6AAAAABXYWBWSWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZZGY3TINBQGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
No description provided.