Skip to content

Commit 77f3526

Browse files
Upsert based on ID field (twentyhq#16275)
1 parent 41e43bd commit 77f3526

File tree

8 files changed

+532
-317
lines changed

8 files changed

+532
-317
lines changed

packages/twenty-front/src/modules/workflow/components/WorkflowEditUpdateEventFieldsMultiSelect.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ export const WorkflowFieldsMultiSelect = ({
1616
defaultFields,
1717
placeholder,
1818
hint,
19+
actionType,
1920
}: {
2021
label: string;
2122
placeholder: string;
2223
objectMetadataItem: ObjectMetadataItem;
2324
handleFieldsChange: (field: FieldMultiSelectValue | string) => void;
2425
readonly: boolean;
2526
defaultFields: string[] | undefined | null;
27+
actionType: 'UPDATE_RECORD' | 'UPSERT_RECORD';
2628
hint?: string;
2729
}) => {
2830
const { getIcon } = useIcons();
@@ -31,7 +33,7 @@ export const WorkflowFieldsMultiSelect = ({
3133
.filter((fieldMetadataItem) =>
3234
shouldDisplayFormField({
3335
fieldMetadataItem,
34-
actionType: 'UPDATE_RECORD',
36+
actionType,
3537
}),
3638
)
3739
.sort((fieldMetadataItemA, fieldMetadataItemB) =>
@@ -55,6 +57,17 @@ export const WorkflowFieldsMultiSelect = ({
5557
label={label}
5658
defaultValue={defaultFields}
5759
options={inlineFieldDefinitions.map((field) => {
60+
const isIdField = field.metadata.fieldName === 'id';
61+
62+
if (isIdField && actionType === 'UPSERT_RECORD') {
63+
return {
64+
label: 'ID',
65+
value: field.metadata.fieldName,
66+
Icon: getIcon('IconId'),
67+
color: 'gray',
68+
};
69+
}
70+
5871
const isFieldRelationManyToOne =
5972
isFieldRelation(field) &&
6073
field.metadata.relationType === RelationType.MANY_TO_ONE;

packages/twenty-front/src/modules/workflow/components/__stories__/WorkflowFieldsMultiSelect.stories.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const Default: Story = {
9292
handleFieldsChange: () => {},
9393
readonly: false,
9494
defaultFields: [],
95+
actionType: 'UPDATE_RECORD',
9596
},
9697
play: async ({ canvasElement }) => {
9798
const canvas = within(canvasElement);
@@ -105,6 +106,7 @@ export const WithDefaultValues: Story = {
105106
args: {
106107
...Default.args,
107108
defaultFields: ['name', 'domainName'],
109+
actionType: 'UPDATE_RECORD',
108110
},
109111
play: async ({ canvasElement }) => {
110112
const canvas = within(canvasElement);
@@ -118,6 +120,7 @@ export const ReadOnly: Story = {
118120
...Default.args,
119121
readonly: true,
120122
defaultFields: ['name', 'domainName'],
123+
actionType: 'UPDATE_RECORD',
121124
},
122125
play: async ({ canvasElement }) => {
123126
const canvas = within(canvasElement);

packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/WorkflowCreateRecordBody.tsx

Lines changed: 0 additions & 266 deletions
This file was deleted.

0 commit comments

Comments
 (0)