Skip to content

Add dedicated attendanceCleanupRules permission - #146

Merged
buzz-code merged 2 commits into
mainfrom
claude/attendance-cleanup-rules-permission
Aug 21, 2026
Merged

buzz-code merged 2 commits into
mainfrom
claude/attendance-cleanup-rules-permission

Conversation

@buzz-code

Copy link
Copy Markdown
Owner

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 — new attendanceCleanupRules key + isAttendanceCleanupRules/useIsAttendanceCleanupRules helpers
  • client/src/App.jsx — Resource gated on isAttendanceCleanupRules(permissions) instead of isAdmin(permissions)
  • server/src/entity-modules/attendance-cleanup-rule.config.ts — crudAuth: CrudAuthWithPermissionsFilter(permissions => permissions?.attendanceCleanupRules) (admin still passes through)
  • test coverage for the new crudAuth filter (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 --noEmit clean; yarn test — 109 suites / 990 tests passed
  • client: yarn test — 30/31 suites passed, 199 tests passed, 1 pre-existing skip, 0 failures

🤖 Generated with Claude Code


Generated by Claude Code

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
Copilot AI lite review requested due to automatic review settings August 21, 2026 06:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Add dedicated attendanceCleanupRules permission, so attendance cleanup rule CRUD no longer admin-only, while keeping admin bypass.

Changes:

  • Add attendanceCleanupRules permission key + helpers in client/src/utils/appPermissions.js
  • Gate attendance_cleanup_rule React-Admin <Resource> via isAttendanceCleanupRules(permissions) in client/src/App.jsx
  • Add server-side crudAuth permission 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.

Comment thread client/src/utils/appPermissions.js Resolved
… 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
@buzz-code
buzz-code merged commit 06745d7 into main Aug 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants