-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix: soft deleted records are read only #8198
fix: soft deleted records are read only #8198
Conversation
/award 500 |
Awarding pau-not-paul: 500 points 🕹️ Well done! Check out your new contribution on oss.gg/pau-not-paul |
0f166da
to
a2d53b3
Compare
8548ecf
to
f029e44
Compare
f029e44
to
b64611c
Compare
@@ -82,7 +82,8 @@ export const FieldsCard = ({ | |||
objectNameSingular !== CoreObjectNameSingular.Task && | |||
fieldMetadataItem.name !== 'taskTargets', | |||
); | |||
const isReadOnly = objectMetadataItem.isRemote; | |||
const isReadOnly = | |||
objectMetadataItem.isRemote || isDefined(recordFromStore?.deletedAt); |
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.
let's introduce a util for that isRecordReadOnly, this will help keep the code maintainable
@@ -45,7 +45,8 @@ export const SummaryCard = ({ | |||
|
|||
const { Icon, IconColor } = useGetStandardObjectIcon(objectNameSingular); | |||
const isMobile = useIsMobile() || isInRightDrawer; | |||
const isReadOnly = objectMetadataItem.isRemote; | |||
const isReadOnly = | |||
objectMetadataItem.isRemote || isDefined(recordFromStore?.deletedAt); |
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.
same
const canEdit = !isFieldMetadataReadOnly(fieldDefinition.metadata); | ||
const record = useRecoilValue(recordStoreFamilyState(recordId)); | ||
|
||
const canEdit = |
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.
same
@@ -158,7 +159,9 @@ export const RecordDetailRelationSection = ({ | |||
recordId, | |||
}); | |||
|
|||
const canEdit = !isFieldMetadataReadOnly(fieldDefinition.metadata); | |||
const canEdit = |
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.
same
isReadOnly: objectMetadataItem.isRemote ?? false, | ||
isReadOnly: | ||
objectMetadataItem.isRemote || | ||
isDefined(recordFromStore?.deletedAt), |
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.
same
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.
Hi @pau-not-paul, thanks for the PR and sorry for the slow review.
Overall the approach looks good, I'm going to rebase this PR and try to merge it
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 adds comprehensive checks for soft-deleted records across the application's UI components, preventing edits to records that have been soft-deleted by checking the deletedAt
field.
- Added
deletedAt
field to GraphQL queries inuseRecordBoardRecordGqlFields.ts
anduseRecordTableRecordGqlFields.ts
- Implemented
isReadOnly
logic inFieldsCard.tsx
andSummaryCard.tsx
to prevent edits on soft-deleted records - Added deletion checks in relation components to prevent modifications of relations for soft-deleted records
- Aligned frontend behavior with backend restrictions by making soft-deleted records read-only throughout the UI
7 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
const canEdit = | ||
!isFieldMetadataReadOnly(fieldDefinition.metadata) && | ||
!isDefined(record?.deletedAt); |
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 adding a visual indicator or tooltip to explain why editing is disabled when record is soft-deleted
const [recordFromStore] = useRecoilState<any>( | ||
recordStoreFamilyState(recordId), | ||
); |
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: Type any used for recordFromStore could be made more specific with proper record type
Todo before merge: fix and complete tests on useIsFieldValueReadOnly hook and isFieldValueEmpty util |
Log
|
TODO:
Fix for #7172
Note for reviewer:
deletedAt
is now always included inrecordGqlFields
.--- Edit from Charles --
In this PR:
Note: as all cells are listening to the record (for isDeleted), updating a field will trigger a re-rendering of the row which is not an issue right now. It will be if we introduce bulk edition. In this case we would need to use a selector on fields on top of record store