Make workflow custom fields editable (#12063)
Fixes https://github.com/twentyhq/twenty/issues/11989 <img width="1267" alt="Capture d’écran 2025-05-15 à 14 05 15" src="https://github.com/user-attachments/assets/fbb22f52-2c76-424f-8b8c-fb030fef9fa8" /> `isCustom` was not properly set everywhere because it was not mandatory in `isFieldValueReadOnly`. Removing the default value and adding it to missing places
This commit is contained in:
@ -70,6 +70,7 @@ export const ActivityRichTextEditor = ({
|
|||||||
const isReadOnly = isFieldValueReadOnly({
|
const isReadOnly = isFieldValueReadOnly({
|
||||||
objectNameSingular: activityObjectNameSingular,
|
objectNameSingular: activityObjectNameSingular,
|
||||||
isRecordReadOnly,
|
isRecordReadOnly,
|
||||||
|
isCustom: objectMetadataItemActivity.isCustom,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { deleteManyRecords: deleteAttachments } = useDeleteManyRecords({
|
const { deleteManyRecords: deleteAttachments } = useDeleteManyRecords({
|
||||||
|
|||||||
@ -39,6 +39,7 @@ export const formatFieldMetadataItemAsFieldDefinition = ({
|
|||||||
options: field.options,
|
options: field.options,
|
||||||
settings: field.settings,
|
settings: field.settings,
|
||||||
isNullable: field.isNullable,
|
isNullable: field.isNullable,
|
||||||
|
isCustom: field.isCustom ?? false,
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -51,6 +51,7 @@ export const RecordBoardCardBody = ({
|
|||||||
fieldName: fieldDefinition.metadata.fieldName,
|
fieldName: fieldDefinition.metadata.fieldName,
|
||||||
fieldType: fieldDefinition.type,
|
fieldType: fieldDefinition.type,
|
||||||
isRecordReadOnly,
|
isRecordReadOnly,
|
||||||
|
isCustom: fieldDefinition.metadata.isCustom,
|
||||||
}),
|
}),
|
||||||
fieldDefinition: {
|
fieldDefinition: {
|
||||||
disableTooltip: false,
|
disableTooltip: false,
|
||||||
|
|||||||
@ -45,6 +45,26 @@ describe('isFieldValueReadOnly', () => {
|
|||||||
expect(result).toBe(false);
|
expect(result).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return false if object is a workflow object and field is custom', () => {
|
||||||
|
const result = isFieldValueReadOnly({
|
||||||
|
objectNameSingular: CoreObjectNameSingular.Workflow,
|
||||||
|
fieldName: 'test',
|
||||||
|
isCustom: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false if object is a workflow sub object and field is custom', () => {
|
||||||
|
const result = isFieldValueReadOnly({
|
||||||
|
objectNameSingular: CoreObjectNameSingular.WorkflowVersion,
|
||||||
|
fieldName: 'test',
|
||||||
|
isCustom: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
describe('when checking field types', () => {
|
describe('when checking field types', () => {
|
||||||
it('should return true if fieldType is RICH_TEXT', () => {
|
it('should return true if fieldType is RICH_TEXT', () => {
|
||||||
const result = isFieldValueReadOnly({
|
const result = isFieldValueReadOnly({
|
||||||
|
|||||||
@ -19,8 +19,8 @@ export const isFieldValueReadOnly = ({
|
|||||||
objectNameSingular,
|
objectNameSingular,
|
||||||
fieldName,
|
fieldName,
|
||||||
fieldType,
|
fieldType,
|
||||||
|
isCustom,
|
||||||
isRecordReadOnly = false,
|
isRecordReadOnly = false,
|
||||||
isCustom = false,
|
|
||||||
}: isFieldValueReadOnlyParams) => {
|
}: isFieldValueReadOnlyParams) => {
|
||||||
if (isRecordReadOnly) {
|
if (isRecordReadOnly) {
|
||||||
return true;
|
return true;
|
||||||
@ -35,7 +35,7 @@ export const isFieldValueReadOnly = ({
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isWorkflowSubObjectMetadata(objectNameSingular)) {
|
if (isWorkflowSubObjectMetadata(objectNameSingular) && !isCustom) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -223,6 +223,7 @@ describe('useRecordData', () => {
|
|||||||
labelWidth: undefined,
|
labelWidth: undefined,
|
||||||
metadata: {
|
metadata: {
|
||||||
fieldName: 'updatedAt',
|
fieldName: 'updatedAt',
|
||||||
|
isCustom: false,
|
||||||
isNullable: false,
|
isNullable: false,
|
||||||
objectMetadataNameSingular: 'person',
|
objectMetadataNameSingular: 'person',
|
||||||
options: null,
|
options: null,
|
||||||
|
|||||||
@ -122,6 +122,7 @@ export const FieldsCard = ({
|
|||||||
objectNameSingular,
|
objectNameSingular,
|
||||||
fieldName: fieldMetadataItem.name,
|
fieldName: fieldMetadataItem.name,
|
||||||
fieldType: fieldMetadataItem.type,
|
fieldType: fieldMetadataItem.type,
|
||||||
|
isCustom: fieldMetadataItem.isCustom ?? false,
|
||||||
isRecordReadOnly,
|
isRecordReadOnly,
|
||||||
}),
|
}),
|
||||||
}}
|
}}
|
||||||
@ -164,6 +165,7 @@ export const FieldsCard = ({
|
|||||||
objectNameSingular,
|
objectNameSingular,
|
||||||
fieldName: fieldMetadataItem.name,
|
fieldName: fieldMetadataItem.name,
|
||||||
fieldType: fieldMetadataItem.type,
|
fieldType: fieldMetadataItem.type,
|
||||||
|
isCustom: fieldMetadataItem.isCustom ?? false,
|
||||||
isRecordReadOnly,
|
isRecordReadOnly,
|
||||||
}),
|
}),
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user