Refactor isReadOnly + introduce restrictedFields (#13533)
Closes https://github.com/twentyhq/core-team-issues/issues/1276 We now need to take fields permissions into account when determining if a cell is editable or not. a record field (= a cell) is read only if one of the condition is met: - the object of the record is read-only (can be determined at table level) by permission setting - the field of the object is read-only (can be determined at column level) - either by permission settings or by system (some workflows fields for intance) - the record is deleted (can be determined at row level) we reorganized the code to avoid re-computing known information as much as possible. --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@@ -92,6 +92,8 @@ const InternalTableContextProviders = ({
|
||||
recordTableId: objectMetadataItem.namePlural,
|
||||
viewBarId: 'view-bar',
|
||||
visibleTableColumns: visibleTableColumns,
|
||||
objectPermissions:
|
||||
objectPermissionsByObjectMetadataId[objectMetadataItem.id],
|
||||
}}
|
||||
>
|
||||
<RecordTableBodyContextProvider
|
||||
|
||||
@@ -136,7 +136,7 @@ export const getFieldDecorator =
|
||||
position: 0,
|
||||
objectMetadataItem,
|
||||
}),
|
||||
isReadOnly: false,
|
||||
isRecordFieldReadOnly: false,
|
||||
}}
|
||||
>
|
||||
<RecordMockSetterEffect
|
||||
|
||||
@@ -51,7 +51,7 @@ export const useMockFieldContext = ({
|
||||
}),
|
||||
useUpdateRecord: useUpdateOneObjectMutation,
|
||||
clearable,
|
||||
isReadOnly: false,
|
||||
isRecordFieldReadOnly: false,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -136,6 +136,7 @@ export const mockedUserData: MockedUser = {
|
||||
canUpdateObjectRecords: true,
|
||||
canSoftDeleteObjectRecords: true,
|
||||
canDestroyObjectRecords: true,
|
||||
restrictedFields: {},
|
||||
})),
|
||||
},
|
||||
locale: 'en',
|
||||
@@ -165,6 +166,7 @@ export const mockedLimitedPermissionsUserData: MockedUser = {
|
||||
canUpdateObjectRecords: true,
|
||||
canSoftDeleteObjectRecords: true,
|
||||
canDestroyObjectRecords: true,
|
||||
restrictedFields: {},
|
||||
})),
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user