Repository navigation
Add dedicated attendanceCleanupRules permission - #146
Merged
Merged
Conversation
Gate the attendance_cleanup_rule resource behind a dedicated permission instead of admin-only, on both client and server: - client/src/utils/appPermissions.js: add attendanceCleanupRules key + isAttendanceCleanupRules/useIsAttendanceCleanupRules helpers - client/src/App.jsx: gate the Resource on isAttendanceCleanupRules instead of isAdmin - server: set crudAuth: CrudAuthWithPermissionsFilter(permissions => permissions?.attendanceCleanupRules) on the entity config, with admin still allowed through as before - add crudAuth test coverage No extra wiring needed to make the permission assignable — the shared User edit screen (nra-client's user.jsx) already generates a checkbox for every key in appPermissions automatically. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011dEYULADLgGNfZ4nv6gz8s
There was a problem hiding this comment.
Pull request overview
Add dedicated attendanceCleanupRules permission, so attendance cleanup rule CRUD no longer admin-only, while keeping admin bypass.
Changes:
- Add
attendanceCleanupRulespermission key + helpers inclient/src/utils/appPermissions.js - Gate
attendance_cleanup_ruleReact-Admin<Resource>viaisAttendanceCleanupRules(permissions)inclient/src/App.jsx - Add server-side
crudAuthpermission filter + add unit tests for access outcomes
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| server/src/entity-modules/attendance-cleanup-rule.config.ts | Gate CRUD via CrudAuthWithPermissionsFilter using permissions.attendanceCleanupRules |
| server/src/entity-modules/tests/attendance-cleanup-rule.config.spec.ts | Add tests covering admin, permission granted, permission missing, missing permissions object |
| client/src/utils/appPermissions.js | Add new permission key + isAttendanceCleanupRules / useIsAttendanceCleanupRules helpers |
| client/src/App.jsx | Switch attendance_cleanup_rule resource gate from isAdmin to isAttendanceCleanupRules |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… override Addresses Copilot review comment on PR #146: the hook only checked the dedicated permission key, while the plain isAttendanceCleanupRules function also grants admins. Match the existing shared-util pattern (useIsShowUsersData, useIsEditPagesData, ...): useHasPermission(key) || useIsAdmin(). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011dEYULADLgGNfZ4nv6gz8s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
attendance_cleanup_rule(merged in #144) was admin-only. Adds a dedicated permission so it can be granted to non-admin users too.client/src/utils/appPermissions.js— newattendanceCleanupRuleskey +isAttendanceCleanupRules/useIsAttendanceCleanupRuleshelpersclient/src/App.jsx— Resource gated onisAttendanceCleanupRules(permissions)instead ofisAdmin(permissions)server/src/entity-modules/attendance-cleanup-rule.config.ts—crudAuth: CrudAuthWithPermissionsFilter(permissions => permissions?.attendanceCleanupRules)(admin still passes through)crudAuthfilter (admin, permission granted, permission missing, no permissions object)No extra wiring needed to make the permission assignable — the shared User edit screen already renders a checkbox for every key in
appPermissions.Testing
Fresh clone (
git clone --depth 1 --branch claude/attendance-cleanup-rules-permission+git submodule update --init --depth 1+yarn install):server:tsc --noEmitclean;yarn test— 109 suites / 990 tests passedclient:yarn test— 30/31 suites passed, 199 tests passed, 1 pre-existing skip, 0 failures🤖 Generated with Claude Code
Generated by Claude Code