Repository navigation
feat: add policy management for permission-binding junctions - #2992
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 49 minutes and 41 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe PR adds update functionality for permission-binding junction entities ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds end-to-end support for managing junction-level policies (policy_id) on permission-binding entities (role/user/client/robot-permission), enabling the UI to assign/clear a single policy per binding and the server/API to persist those changes.
Changes:
- Introduces new
*_PERMISSION_UPDATEpermission names and adds server-sideupdate()support (service + controller) to update onlypolicy_id. - Extends
core-http-kitjunction APIs withupdate()and switches toEntityAPIwhere needed. - Updates assignment UI components to show a new policy-management button + modal for assigned bindings, and adds unit tests for update behavior.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core-kit/src/domains/permission/constants.ts | Adds *_PERMISSION_UPDATE permission names for junction policy updates. |
| packages/core-http-kit/src/domains/entities/user-permission/module.ts | Adds update() to UserPermissionAPI and implements EntityAPI. |
| packages/core-http-kit/src/domains/entities/role-permission/module.ts | Adds update() to RolePermissionAPI and implements EntityAPI. |
| packages/core-http-kit/src/domains/entities/robot-permission/module.ts | Adds update() to RobotPermissionAPI and implements EntityAPI. |
| packages/core-http-kit/src/domains/entities/client-permission/module.ts | Adds update() to ClientPermissionAPI and implements EntityAPI. |
| packages/client-web-kit/src/components/entities/user-permission/AUserPermissionAssignment.ts | Renders policy button + modal entry point when binding exists. |
| packages/client-web-kit/src/components/entities/role-permission/ARolePermissionAssignment.ts | Renders policy button + modal entry point when binding exists. |
| packages/client-web-kit/src/components/entities/robot-permission/ARobotPermissionAssignment.ts | Renders policy button + modal entry point when binding exists. |
| packages/client-web-kit/src/components/entities/client-permission/AClientPermissionAssignment.ts | Renders policy button + modal entry point when binding exists. |
| packages/client-web-kit/src/components/entities/permission-binding-policy/index.ts | Exports new policy-management button component. |
| packages/client-web-kit/src/components/entities/permission-binding-policy/APermissionBindingPolicyButton.ts | Implements modal UI to set/clear policy_id via api.update(). |
| packages/client-web-kit/src/components/entities/index.ts | Exposes permission-binding-policy components via entities barrel export. |
| apps/server-core/test/unit/core/entities/user-permission/service.spec.ts | Adds unit tests for update() policy_id behavior and authorization. |
| apps/server-core/test/unit/core/entities/role-permission/service.spec.ts | Adds unit tests for update() policy_id behavior and authorization. |
| apps/server-core/test/unit/core/entities/robot-permission/service.spec.ts | Adds unit tests for update() policy_id behavior and authorization. |
| apps/server-core/test/unit/core/entities/client-permission/service.spec.ts | Adds unit tests for update() policy_id behavior and authorization. |
| apps/server-core/src/core/entities/user-permission/types.ts | Adds update() to IUserPermissionService. |
| apps/server-core/src/core/entities/user-permission/service.ts | Implements update() to change only policy_id. |
| apps/server-core/src/core/entities/role-permission/types.ts | Adds update() to IRolePermissionService. |
| apps/server-core/src/core/entities/role-permission/service.ts | Implements update() to change only policy_id. |
| apps/server-core/src/core/entities/robot-permission/types.ts | Adds update() to IRobotPermissionService. |
| apps/server-core/src/core/entities/robot-permission/service.ts | Implements update() to change only policy_id. |
| apps/server-core/src/core/entities/client-permission/types.ts | Adds update() to IClientPermissionService. |
| apps/server-core/src/core/entities/client-permission/service.ts | Implements update() to change only policy_id. |
| apps/server-core/src/adapters/http/controllers/entities/user-permission/module.ts | Adds POST /user-permissions/:id edit endpoint calling service.update(). |
| apps/server-core/src/adapters/http/controllers/entities/role-permission/module.ts | Adds POST /role-permissions/:id edit endpoint calling service.update(). |
| apps/server-core/src/adapters/http/controllers/entities/robot-permission/module.ts | Adds POST /robot-permissions/:id edit endpoint calling service.update(). |
| apps/server-core/src/adapters/http/controllers/entities/client-permission/module.ts | Adds POST /client-permissions/:id edit endpoint calling service.update(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@packages/client-web-kit/src/components/entities/permission-binding-policy/APermissionBindingPolicyButton.ts`:
- Around line 94-107: The settings button rendered in
APermissionBindingPolicyButton is icon-only and lacks an accessible name; update
the h('button', ...) call to include an accessible label (e.g., add
aria-label="Open policy settings" or a descriptive title) and mark the icon
element as decorative (set the <i> element's props to { 'aria-hidden': 'true' })
so screen readers get the button label only; ensure you update the button props
object (where class, disabled, onClick are defined) to include the
aria-label/title and adjust the h('i', ...) props accordingly.
- Around line 80-83: The catch in APermissionBindingPolicyButton currently
ignores throwables that are not instances of Error; change the handler so it
always emits a failure Error: inside the catch replace the conditional with code
that creates an Error when e is not an Error (e.g. const err = e instanceof
Error ? e : new Error(String(e)); and, if supported, attach the original value
as a property or cause), then call emit('failed', err); this ensures
emit('failed', ...) is always called for any thrown value in the
APermissionBindingPolicyButton catch block.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5b58ee0b-5ed5-4dde-b181-eef3ba224f5e
📒 Files selected for processing (28)
apps/server-core/src/adapters/http/controllers/entities/client-permission/module.tsapps/server-core/src/adapters/http/controllers/entities/robot-permission/module.tsapps/server-core/src/adapters/http/controllers/entities/role-permission/module.tsapps/server-core/src/adapters/http/controllers/entities/user-permission/module.tsapps/server-core/src/core/entities/client-permission/service.tsapps/server-core/src/core/entities/client-permission/types.tsapps/server-core/src/core/entities/robot-permission/service.tsapps/server-core/src/core/entities/robot-permission/types.tsapps/server-core/src/core/entities/role-permission/service.tsapps/server-core/src/core/entities/role-permission/types.tsapps/server-core/src/core/entities/user-permission/service.tsapps/server-core/src/core/entities/user-permission/types.tsapps/server-core/test/unit/core/entities/client-permission/service.spec.tsapps/server-core/test/unit/core/entities/robot-permission/service.spec.tsapps/server-core/test/unit/core/entities/role-permission/service.spec.tsapps/server-core/test/unit/core/entities/user-permission/service.spec.tspackages/client-web-kit/src/components/entities/client-permission/AClientPermissionAssignment.tspackages/client-web-kit/src/components/entities/index.tspackages/client-web-kit/src/components/entities/permission-binding-policy/APermissionBindingPolicyButton.tspackages/client-web-kit/src/components/entities/permission-binding-policy/index.tspackages/client-web-kit/src/components/entities/robot-permission/ARobotPermissionAssignment.tspackages/client-web-kit/src/components/entities/role-permission/ARolePermissionAssignment.tspackages/client-web-kit/src/components/entities/user-permission/AUserPermissionAssignment.tspackages/core-http-kit/src/domains/entities/client-permission/module.tspackages/core-http-kit/src/domains/entities/robot-permission/module.tspackages/core-http-kit/src/domains/entities/role-permission/module.tspackages/core-http-kit/src/domains/entities/user-permission/module.tspackages/core-kit/src/domains/permission/constants.ts
| } catch (e) { | ||
| if (e instanceof Error) { | ||
| emit('failed', e); | ||
| } |
There was a problem hiding this comment.
Don’t silently drop non-Error throwables.
At Lines 80-83, thrown values that are not Error are ignored, so failure signals can be lost.
🛠️ Proposed fix
} catch (e) {
- if (e instanceof Error) {
- emit('failed', e);
- }
+ emit('failed', e instanceof Error ? e : new Error('Failed to update junction policy.'));
} finally {
busy.value = false;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| } catch (e) { | |
| if (e instanceof Error) { | |
| emit('failed', e); | |
| } | |
| } catch (e) { | |
| emit('failed', e instanceof Error ? e : new Error('Failed to update junction policy.')); | |
| } finally { | |
| busy.value = false; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@packages/client-web-kit/src/components/entities/permission-binding-policy/APermissionBindingPolicyButton.ts`
around lines 80 - 83, The catch in APermissionBindingPolicyButton currently
ignores throwables that are not instances of Error; change the handler so it
always emits a failure Error: inside the catch replace the conditional with code
that creates an Error when e is not an Error (e.g. const err = e instanceof
Error ? e : new Error(String(e)); and, if supported, attach the original value
as a property or cause), then call emit('failed', err); this ensures
emit('failed', ...) is always called for any thrown value in the
APermissionBindingPolicyButton catch block.
| children.push(h('button', { | ||
| class: ['btn btn-xs', { | ||
| 'btn-dark': busy.value, | ||
| 'btn-primary': !busy.value && currentPolicyId.value, | ||
| 'btn-secondary': !busy.value && !currentPolicyId.value, | ||
| }], | ||
| disabled: busy.value, | ||
| onClick(e: Event) { | ||
| e.preventDefault(); | ||
| modalOpen.value = true; | ||
| }, | ||
| }, [ | ||
| h('i', { class: 'fa fa-cog' }), | ||
| ])); |
There was a problem hiding this comment.
Add an accessible name to the icon-only settings button.
At Line 94, the trigger is icon-only and has no label for assistive tech.
♿ Proposed fix
children.push(h('button', {
+ type: 'button',
class: ['btn btn-xs', {
'btn-dark': busy.value,
'btn-primary': !busy.value && currentPolicyId.value,
'btn-secondary': !busy.value && !currentPolicyId.value,
}],
+ 'aria-label': 'Manage junction policy',
+ title: 'Manage junction policy',
disabled: busy.value,
onClick(e: Event) {
e.preventDefault();
modalOpen.value = true;
},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| children.push(h('button', { | |
| class: ['btn btn-xs', { | |
| 'btn-dark': busy.value, | |
| 'btn-primary': !busy.value && currentPolicyId.value, | |
| 'btn-secondary': !busy.value && !currentPolicyId.value, | |
| }], | |
| disabled: busy.value, | |
| onClick(e: Event) { | |
| e.preventDefault(); | |
| modalOpen.value = true; | |
| }, | |
| }, [ | |
| h('i', { class: 'fa fa-cog' }), | |
| ])); | |
| children.push(h('button', { | |
| type: 'button', | |
| class: ['btn btn-xs', { | |
| 'btn-dark': busy.value, | |
| 'btn-primary': !busy.value && currentPolicyId.value, | |
| 'btn-secondary': !busy.value && !currentPolicyId.value, | |
| }], | |
| 'aria-label': 'Manage junction policy', | |
| title: 'Manage junction policy', | |
| disabled: busy.value, | |
| onClick(e: Event) { | |
| e.preventDefault(); | |
| modalOpen.value = true; | |
| }, | |
| }, [ | |
| h('i', { class: 'fa fa-cog' }), | |
| ])); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@packages/client-web-kit/src/components/entities/permission-binding-policy/APermissionBindingPolicyButton.ts`
around lines 94 - 107, The settings button rendered in
APermissionBindingPolicyButton is icon-only and lacks an accessible name; update
the h('button', ...) call to include an accessible label (e.g., add
aria-label="Open policy settings" or a descriptive title) and mark the icon
element as decorative (set the <i> element's props to { 'aria-hidden': 'true' })
so screen readers get the button label only; ensure you update the button props
object (where class, disabled, onClick are defined) to include the
aria-label/title and adjust the h('i', ...) props accordingly.
closes #2987
Summary by CodeRabbit