Feat 17408 : Add remove option for object permissions rule#17601
Feat 17408 : Add remove option for object permissions rule#17601etiennejouan merged 18 commits intotwentyhq:mainfrom
Conversation
…o delete role of specific object
…ing role permission object; new dropdown added containing remove rules options
…between request and persist state on database
…low empty (deleted) permission
… as delete handling in dropdown
…or field and object permission removal
Update with new release
LogDetails |
...s/settings/roles/role-permissions/object-level-permissions/hooks/useResetObjectPermission.ts
Show resolved
Hide resolved
Greptile OverviewGreptile SummaryThis PR adds a removal option for object permission rules in the settings UI, enabling users to reset permissions back to unrestricted access. Key Changes:
Issues Found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Dropdown as SettingsRolePermissionsObjectLevelTableRowOptionsDropdown
participant Hook as useResetObjectPermission
participant UpsertObjHook as useUpsertObjectPermissionInDraftRole
participant UpsertFieldHook as useUpsertFieldPermissionInDraftRole
participant RecoilState as settingsDraftRoleFamilyState
User->>Dropdown: Click "..." options button
Dropdown->>User: Show dropdown menu
User->>Dropdown: Click "Remove rule"
Dropdown->>Hook: resetObjectPermission(objectMetadataId)
Hook->>RecoilState: Read current draft role state
RecoilState-->>Hook: Return fieldPermissions & objectPermissions
Hook->>Hook: Filter field permissions for object
Hook->>Hook: Find existing object permission
Hook->>Hook: Create reset permissions (all null)
alt No existing object permission
Hook->>UpsertObjHook: upsertObjectPermissionInDraftRole(newObjectPermission)
UpsertObjHook->>RecoilState: Update with new object permission
else Existing object permission
Hook->>UpsertObjHook: upsertObjectPermissionInDraftRole(updatedObjectPermission)
UpsertObjHook->>RecoilState: Update existing object permission
end
loop For each field permission
Hook->>UpsertFieldHook: upsertFieldPermissionInDraftRole(resetFieldPermission)
UpsertFieldHook->>RecoilState: Update field permission to null
end
RecoilState-->>User: UI updates to show unrestricted access
|
...d-permissions/components/SettingsRolePermissionsObjectLevelObjectFieldPermissionTableRow.tsx
Outdated
Show resolved
Hide resolved
...d-permissions/components/SettingsRolePermissionsObjectLevelObjectFieldPermissionTableRow.tsx
Outdated
Show resolved
Hide resolved
...d-permissions/components/SettingsRolePermissionsObjectLevelObjectFieldPermissionTableRow.tsx
Outdated
Show resolved
Hide resolved
...s/settings/roles/role-permissions/object-level-permissions/hooks/useResetObjectPermission.ts
Outdated
Show resolved
Hide resolved
...t-level-permissions/components/SettingsRolePermissionsObjectLevelTableRowOptionsDropdown.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This pull request adds the ability to remove object permission rules from roles, addressing a gap where users could add permission rules but not delete them. The implementation follows existing patterns in the codebase by creating a dropdown menu with "Remove rule" and "Edit" options, similar to the AdvancedFilterRecordFilterOptionsDropdown.
Changes:
- Adds
useResetObjectPermissionhook to reset object and field permissions to null values - Implements
SettingsRolePermissionsObjectLevelTableRowOptionsDropdowncomponent with remove and edit functionality - Adjusts table grid layout to accommodate the new options dropdown column
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
useResetObjectPermission.ts |
New hook that resets object and field permissions for a given object by setting all permission flags to null |
SettingsRolePermissionsObjectLevelTableRowOptionsDropdown.tsx |
New dropdown component providing remove and edit options for object permission rows |
SettingsRolePermissionsObjectLevelTableRow.tsx |
Integrates the new options dropdown into the permission table row |
SettingsRolePermissionsObjectLevelTableHeader.tsx |
Adds empty header cell for the new options column |
ObjectLevelPermissionTableGridAutoColumns.ts |
Adjusts grid column widths to accommodate the new options column |
SettingsRolePermissionsObjectLevelObjectFieldPermissionTableRow.tsx |
Adds documentation comments explaining permission handling behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'canDestroyObjectRecords', | ||
| ]; | ||
|
|
||
| export const useResetObjectPermission = (roleId: string) => { |
There was a problem hiding this comment.
The hook parameter structure is inconsistent with the similar hook useUpsertObjectPermission. While useUpsertObjectPermission uses destructured object parameters ({ roleId }: { roleId: string }), this hook uses a direct parameter (roleId: string). For consistency with the codebase, consider updating to use the same parameter pattern as useUpsertObjectPermission.
...s/settings/roles/role-permissions/object-level-permissions/hooks/useResetObjectPermission.ts
Outdated
Show resolved
Hide resolved
...s/settings/roles/role-permissions/object-level-permissions/hooks/useResetObjectPermission.ts
Outdated
Show resolved
Hide resolved
...d-permissions/components/SettingsRolePermissionsObjectLevelObjectFieldPermissionTableRow.tsx
Outdated
Show resolved
Hide resolved
...d-permissions/components/SettingsRolePermissionsObjectLevelObjectFieldPermissionTableRow.tsx
Outdated
Show resolved
Hide resolved
|
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:24913 This environment will automatically shut down when the PR is closed or after 5 hours. |
|
@Bonapara Ready for review. |
etiennejouan
left a comment
There was a problem hiding this comment.
Hi @LTan-101104 it works well ! Thanks and Congrats for your first contribution on Twenty repo 👏
I left small comments regarding design. Do not hesitate to reach me if not clear.
| accent="danger" | ||
| /> | ||
| </DropdownMenuItemsContainer> | ||
| <DropdownMenuItemsContainer> |
There was a problem hiding this comment.
Nitpick : Could you invert "Remove rule" and "Edit" to fit with design ? #17408 (comment)
| objectPermissionDetailUrl={navigationUrl} | ||
| /> | ||
| </TableCell> | ||
| <TableCell align="right"> |
|
@etiennejouan Hi, sorry for the late reply. I just made 2 fixes following your comment to make sure it appears similar to mentioned design Please feel free to let me know if there is anything else I need to implement. Thank you, |
etiennejouan
left a comment
There was a problem hiding this comment.
Hi @LTan-101104 Thanks for your nice contribution 👍
|
Hey @etiennejouan! After you've done the QA of your Pull Request, you can mark it as done here. Thank you! |
1 similar comment
|
Hey @etiennejouan! After you've done the QA of your Pull Request, you can mark it as done here. Thank you! |

This PR aims to fix: #17408
Main modification includes adding a new column for dropdown in the object permission rule table (containing options for editing and removal). Removal logic is implemented using existing pattern with hook
useResetObjectPermission(relies on existing hooksuseUpsertFieldPermissionInDraftRoleanduseUpsertObjectPermissionInDraftRole).Feel free to suggest any necessary changes. Functionality (unrestricted access is allowed when permission removal is applied) is already tested.
Demo video: https://drive.google.com/file/d/1M4RYHw-JEhDdJksKkL3MY_VyXAV3aS9I/view?usp=sharing