Files
twenty/packages/twenty-front/src/modules/workflow/utils/getStepDefaultDefinition.ts
T
Thomas TrompetteandGitHub 5ec6cb0e6f Make workflow step name editable (#8677)
- Use TextInput in header title
- add onTitleChange prop
- rename field name instead of label

To fix :
- padding right on title comes from current TextInput component. It
needs to be refactored


https://github.com/user-attachments/assets/535cd6d3-866b-4a61-9c5d-cdbe7710396a
2024-11-22 15:25:01 +00:00

98 lines
2.3 KiB
TypeScript

import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { WorkflowStep, WorkflowStepType } from '@/workflow/types/Workflow';
import { assertUnreachable } from '@/workflow/utils/assertUnreachable';
import { v4 } from 'uuid';
export const getStepDefaultDefinition = ({
type,
activeObjectMetadataItems,
}: {
type: WorkflowStepType;
activeObjectMetadataItems: ObjectMetadataItem[];
}): WorkflowStep => {
const newStepId = v4();
switch (type) {
case 'CODE': {
return {
id: newStepId,
name: 'Code',
type: 'CODE',
valid: false,
settings: {
input: {
serverlessFunctionId: '',
serverlessFunctionVersion: '',
serverlessFunctionInput: {},
},
outputSchema: {},
errorHandlingOptions: {
continueOnFailure: {
value: false,
},
retryOnFailure: {
value: false,
},
},
},
};
}
case 'SEND_EMAIL': {
return {
id: newStepId,
name: 'Send Email',
type: 'SEND_EMAIL',
valid: false,
settings: {
input: {
connectedAccountId: '',
email: '',
subject: '',
body: '',
},
outputSchema: {},
errorHandlingOptions: {
continueOnFailure: {
value: false,
},
retryOnFailure: {
value: false,
},
},
},
};
}
case 'RECORD_CRUD.CREATE': {
return {
id: newStepId,
name: 'Create Record',
type: 'RECORD_CRUD',
valid: false,
settings: {
input: {
type: 'CREATE',
objectName: activeObjectMetadataItems[0].nameSingular,
objectRecord: {},
},
outputSchema: {},
errorHandlingOptions: {
continueOnFailure: {
value: false,
},
retryOnFailure: {
value: false,
},
},
},
};
}
case 'RECORD_CRUD.DELETE':
case 'RECORD_CRUD.UPDATE': {
throw new Error('Not implemented yet');
}
default: {
return assertUnreachable(type, `Unknown type: ${type}`);
}
}
};