Repository navigation
feat: add policy detail/preview to assignment components - #3000
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 42 minutes and 56 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 (4)
📝 WalkthroughWalkthroughThis PR adds policy detail viewing capability to assignment components. New components ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~28 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 policy preview/detail affordances to policy assignment UIs so users can see basic policy metadata (type/invert/etc.) and open a quick details view from assignment contexts.
Changes:
- Introduces reusable policy UI helpers (type badge, summary, detail trigger, inline info).
- Enhances permission → policy assignment list to show type/invert badges and open a modal preview.
- Enhances junction-policy assignment modal to show type/invert badges and support an in-modal preview state.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/client-web-kit/src/components/entities/policy/index.ts | Re-exports newly added policy UI components. |
| packages/client-web-kit/src/components/entities/policy/APolicyTypeBadge.ts | Adds a small badge component to display a human-friendly policy type label. |
| packages/client-web-kit/src/components/entities/policy/APolicySummary.ts | Adds a simple policy metadata summary used in preview modals. |
| packages/client-web-kit/src/components/entities/policy/APolicyInlineInfo.ts | Adds an inline “badges + detail trigger” helper component (currently not integrated). |
| packages/client-web-kit/src/components/entities/policy/APolicyDetailNav.ts | Adds an eye-button component intended to trigger policy “details” behavior. |
| packages/client-web-kit/src/components/entities/permission-policy/APermissionPolicyAssignments.ts | Updates permission-policy assignment list items to include badges + preview modal. |
| packages/client-web-kit/src/components/entities/permission-policy-binding/APermissionPolicyBindingButton.ts | Updates junction-policy modal to include badges + nested preview state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }, | ||
| emits: ['click'], | ||
| setup(props, { emit }) { | ||
| return () => h('button', { | ||
| class: 'btn btn-xs btn-outline-info', | ||
| title: 'View policy details', | ||
| onClick(e: Event) { | ||
| e.preventDefault(); | ||
| emit('click', props.policyId); | ||
| }, | ||
| }, [ | ||
| h('i', { class: 'fa fa-eye' }), | ||
| ]); |
There was a problem hiding this comment.
The component name APolicyDetailNav implies it performs navigation, but it currently only emits a click event and doesn’t provide any default navigation target (e.g. /policies/:id). Either rename it to reflect its behavior (button/trigger), or add an explicit to/href API (or router-link integration) so it can actually navigate when used as-is.
| }, | |
| emits: ['click'], | |
| setup(props, { emit }) { | |
| return () => h('button', { | |
| class: 'btn btn-xs btn-outline-info', | |
| title: 'View policy details', | |
| onClick(e: Event) { | |
| e.preventDefault(); | |
| emit('click', props.policyId); | |
| }, | |
| }, [ | |
| h('i', { class: 'fa fa-eye' }), | |
| ]); | |
| to: { | |
| type: String, | |
| required: false, | |
| default: undefined, | |
| }, | |
| href: { | |
| type: String, | |
| required: false, | |
| default: undefined, | |
| }, | |
| }, | |
| emits: ['click'], | |
| setup(props, { emit }) { | |
| return () => { | |
| const href = props.href || props.to; | |
| const tag = href ? 'a' : 'button'; | |
| return h(tag, { | |
| class: 'btn btn-xs btn-outline-info', | |
| title: 'View policy details', | |
| href, | |
| type: tag === 'button' ? 'button' : undefined, | |
| onClick(e: Event) { | |
| if (!href) { | |
| e.preventDefault(); | |
| } | |
| emit('click', props.policyId); | |
| }, | |
| }, [ | |
| h('i', { class: 'fa fa-eye' }), | |
| ]); | |
| }; |
| const rows = [ | ||
| renderRow('Name', props.entity.name), | ||
| renderRow('Type', h(APolicyTypeBadge, { type: props.entity.type })), | ||
| ]; | ||
|
|
||
| if (props.entity.display_name) { | ||
| rows.push(renderRow('Display Name', props.entity.display_name)); | ||
| } | ||
|
|
||
| if (props.entity.description) { | ||
| rows.push(renderRow('Description', props.entity.description)); | ||
| } | ||
|
|
||
| if (props.entity.invert) { | ||
| rows.push(renderRow('Invert', h('span', { class: 'badge bg-warning' }, 'Yes'))); | ||
| } | ||
|
|
||
| if (props.entity.built_in) { | ||
| rows.push(renderRow('Built-in', h('span', { class: 'badge bg-secondary' }, 'Yes'))); | ||
| } |
There was a problem hiding this comment.
APolicySummary currently only shows general metadata (name/type/display_name/description/invert/built_in) but doesn’t surface any policy configuration (e.g. composite children count, decision_strategy, attribute conditions, etc.). If this PR is meant to close #2989 (“view what an assigned policy actually does”), consider extending the summary with type-specific fields (and/or a link to the full policy details page).
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/client-web-kit/src/components/entities/permission-policy-binding/APermissionPolicyBindingButton.ts (1)
116-255:⚠️ Potential issue | 🟠 MajorThis modal has the same keyboard-accessibility gap as the assignment modal.
Focus is never moved into the dialog, trapped while open, or restored to the trigger afterward. As written, keyboard users can tab behind the overlay and lose context inside the two-step flow.
🤖 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-policy-binding/APermissionPolicyBindingButton.ts` around lines 116 - 255, The modal currently rendered inside APermissionPolicyBindingButton (when modalOpen.value is true, creating backdrop + modal via Teleport and using modalTitleId, detailPolicy.value, handlePolicySelect) lacks focus management: focus is not moved into the dialog, not trapped, and not restored to the trigger. Fix by adding focus management logic in the component: when opening (modalOpen.value set true) save document.activeElement, programmatically focus the first focusable element inside the modal (use the modal container you create for Teleport), add keyboard handlers on the modal for Tab/Shift+Tab to trap focus within modal and Escape to close (delegating to the existing detailPolicy.value/ modalOpen.value toggles and handlePolicySelect as appropriate), and on close restore focus to the saved trigger element; ensure the modal element has aria-modal="true" and modalTitleId is used as aria-labelledby for accessibility.
🤖 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-policy-binding/APermissionPolicyBindingButton.ts`:
- Around line 170-192: The button only shows icons and lacks accessible text;
update the button element rendered in APermissionPolicyBindingButton to include
a dynamic title and aria-label (e.g., when isSelected true use "Remove policy"
otherwise "Assign policy"), and mark the inner <i> icon as aria-hidden="true" so
screen readers read the button label; keep existing onClick and use
handlePolicySelect, busy, and slotProps.data.id as-is so behavior is unchanged.
In
`@packages/client-web-kit/src/components/entities/permission-policy/APermissionPolicyAssignments.ts`:
- Around line 81-135: The custom modal created when detailPolicy.value is set
(variables: modalTitleId, backdrop, modal, Teleport, APolicySummary) lacks focus
management—move keyboard focus into the modal when opened (e.g., to the modal
container or first focusable element), implement a focus trap to keep
Tab/Shift+Tab cycling within the modal, restore focus to the previously focused
element when detailPolicy.value is cleared, and prevent background content from
being focusable (use inert/aria-hidden on the rest of the document or use the
app's shared modal abstraction if available); also handle Escape to close the
modal and ensure backdrop and modal onClick handlers don’t block keyboard focus
behavior.
In `@packages/client-web-kit/src/components/entities/policy/APolicyDetailNav.ts`:
- Around line 17-24: The component APolicyDetailNav currently only emits a local
'click' with props.policyId and doesn't provide a real navigation target; change
the render in setup (the onClick handler / button) to produce a real link target
(either render an <a> with href={`/policies/${props.policyId}`} or use the
router API like router-link/router.push) so consumers can navigate from
assignment contexts; keep or still emit the click if needed, but ensure the
element exposes a real href/route (referencing APolicyDetailNav, setup, onClick,
props.policyId) so clicking navigates to /policies/[id] rather than only
updating local state.
- Around line 19-27: The icon-only button in the render returned by the
component (the h('button', { ... }) block in APolicyDetailNav) lacks an
accessible name; update that button props to include type: 'button' and an
explicit accessible name such as aria-label: `View policy details` (or add
visually hidden text) so assistive tech can identify the control, keeping the
existing onClick handler that emits 'click' with props.policyId.
In `@packages/client-web-kit/src/components/entities/policy/APolicyInlineInfo.ts`:
- Around line 21-33: The APolicyInlineInfo setup function doesn't forward the
click emitted by APolicyDetailNav; update the setup signature to accept the emit
context (change setup(props) to setup(props, { emit })) and, when creating the
APolicyDetailNav vnode (the one using props.entity.id), add a listener prop that
calls emit('click', props.entity.id) (e.g., onClick: () => emit('click',
props.entity.id)) so APolicyInlineInfo re-emits the click with the policyId.
In `@packages/client-web-kit/src/components/entities/policy/APolicySummary.ts`:
- Around line 29-50: APolicySummary currently only renders generic fields via
renderRow and omits policy-specific configuration; update the component to also
render composite children, decisionStrategy, attribute rules,
realm/realmMatching and any type-specific config from props.entity so users can
inspect the full policy. In APolicySummary (and where renderRow is used) add
conditional rows for props.entity.children (or compositeChildren) listing child
IDs/names, props.entity.decision_strategy (or decisionStrategy),
props.entity.rules/attributeRules with a compact readable rendering,
props.entity.realm or realmMatching settings, and switch on props.entity.type to
output type-specific fields; reuse renderRow and small helper renderers to keep
markup consistent and ensure badges/labels match existing style.
---
Outside diff comments:
In
`@packages/client-web-kit/src/components/entities/permission-policy-binding/APermissionPolicyBindingButton.ts`:
- Around line 116-255: The modal currently rendered inside
APermissionPolicyBindingButton (when modalOpen.value is true, creating backdrop
+ modal via Teleport and using modalTitleId, detailPolicy.value,
handlePolicySelect) lacks focus management: focus is not moved into the dialog,
not trapped, and not restored to the trigger. Fix by adding focus management
logic in the component: when opening (modalOpen.value set true) save
document.activeElement, programmatically focus the first focusable element
inside the modal (use the modal container you create for Teleport), add keyboard
handlers on the modal for Tab/Shift+Tab to trap focus within modal and Escape to
close (delegating to the existing detailPolicy.value/ modalOpen.value toggles
and handlePolicySelect as appropriate), and on close restore focus to the saved
trigger element; ensure the modal element has aria-modal="true" and modalTitleId
is used as aria-labelledby for accessibility.
🪄 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: ea5459fe-a250-421e-b736-bffe25695368
📒 Files selected for processing (7)
packages/client-web-kit/src/components/entities/permission-policy-binding/APermissionPolicyBindingButton.tspackages/client-web-kit/src/components/entities/permission-policy/APermissionPolicyAssignments.tspackages/client-web-kit/src/components/entities/policy/APolicyDetailNav.tspackages/client-web-kit/src/components/entities/policy/APolicyInlineInfo.tspackages/client-web-kit/src/components/entities/policy/APolicySummary.tspackages/client-web-kit/src/components/entities/policy/APolicyTypeBadge.tspackages/client-web-kit/src/components/entities/policy/index.ts
| h('button', { | ||
| class: ['btn btn-xs', { | ||
| 'btn-dark': busy.value, | ||
| 'btn-success': !busy.value && isSelected, | ||
| 'btn-secondary': !busy.value && !isSelected, | ||
| }], | ||
| disabled: busy.value, | ||
| onClick(e: Event) { | ||
| e.preventDefault(); | ||
| if (isSelected) { | ||
| handlePolicySelect(null); | ||
| } else { | ||
| handlePolicySelect(slotProps.data.id); | ||
| } | ||
| }, | ||
| }, [ | ||
| h('i', { | ||
| class: ['fa', { | ||
| 'fa-check': isSelected, | ||
| 'fa-plus': !isSelected, | ||
| }], | ||
| }), | ||
| ]), |
There was a problem hiding this comment.
Label the assign/remove toggle.
This button only exposes a plus/check icon, but no text, title, or aria-label. Screen-reader users cannot tell whether the action will assign or remove the junction policy.
Suggested patch
h('button', {
+ type: 'button',
class: ['btn btn-xs', {
'btn-dark': busy.value,
'btn-success': !busy.value && isSelected,
'btn-secondary': !busy.value && !isSelected,
}],
+ title: isSelected ? 'Remove policy' : 'Assign policy',
+ 'aria-label': isSelected ? 'Remove policy' : 'Assign policy',
disabled: busy.value,
onClick(e: Event) {
e.preventDefault();📝 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.
| h('button', { | |
| class: ['btn btn-xs', { | |
| 'btn-dark': busy.value, | |
| 'btn-success': !busy.value && isSelected, | |
| 'btn-secondary': !busy.value && !isSelected, | |
| }], | |
| disabled: busy.value, | |
| onClick(e: Event) { | |
| e.preventDefault(); | |
| if (isSelected) { | |
| handlePolicySelect(null); | |
| } else { | |
| handlePolicySelect(slotProps.data.id); | |
| } | |
| }, | |
| }, [ | |
| h('i', { | |
| class: ['fa', { | |
| 'fa-check': isSelected, | |
| 'fa-plus': !isSelected, | |
| }], | |
| }), | |
| ]), | |
| h('button', { | |
| type: 'button', | |
| class: ['btn btn-xs', { | |
| 'btn-dark': busy.value, | |
| 'btn-success': !busy.value && isSelected, | |
| 'btn-secondary': !busy.value && !isSelected, | |
| }], | |
| title: isSelected ? 'Remove policy' : 'Assign policy', | |
| 'aria-label': isSelected ? 'Remove policy' : 'Assign policy', | |
| disabled: busy.value, | |
| onClick(e: Event) { | |
| e.preventDefault(); | |
| if (isSelected) { | |
| handlePolicySelect(null); | |
| } else { | |
| handlePolicySelect(slotProps.data.id); | |
| } | |
| }, | |
| }, [ | |
| h('i', { | |
| class: ['fa', { | |
| 'fa-check': isSelected, | |
| 'fa-plus': !isSelected, | |
| }], | |
| }), | |
| ]), |
🤖 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-policy-binding/APermissionPolicyBindingButton.ts`
around lines 170 - 192, The button only shows icons and lacks accessible text;
update the button element rendered in APermissionPolicyBindingButton to include
a dynamic title and aria-label (e.g., when isSelected true use "Remove policy"
otherwise "Assign policy"), and mark the inner <i> icon as aria-hidden="true" so
screen readers read the button label; keep existing onClick and use
handlePolicySelect, busy, and slotProps.data.id as-is so behavior is unchanged.
| if (detailPolicy.value) { | ||
| const policy = detailPolicy.value; | ||
| const modalTitleId = `policy-detail-modal-${policy.id}`; | ||
|
|
||
| const backdrop = h('div', { | ||
| class: 'modal-backdrop fade show', | ||
| onClick() { | ||
| detailPolicy.value = null; | ||
| }, | ||
| }); | ||
|
|
||
| const modal = h('div', { | ||
| class: 'modal fade show d-block', | ||
| tabindex: '-1', | ||
| role: 'dialog', | ||
| 'aria-modal': 'true', | ||
| 'aria-labelledby': modalTitleId, | ||
| }, [ | ||
| h('div', { | ||
| class: 'modal-dialog', | ||
| role: 'document', | ||
| onClick(e: Event) { | ||
| e.stopPropagation(); | ||
| }, | ||
| }, [ | ||
| h('div', { class: 'modal-content' }, [ | ||
| h('div', { class: 'modal-header' }, [ | ||
| h('h5', { class: 'modal-title', id: modalTitleId }, policy.name), | ||
| h('button', { | ||
| type: 'button', | ||
| class: 'btn-close', | ||
| 'aria-label': 'Close', | ||
| onClick() { | ||
| detailPolicy.value = null; | ||
| }, | ||
| }), | ||
| ]), | ||
| h('div', { class: 'modal-body' }, [ | ||
| h(APolicySummary, { entity: policy }), | ||
| ]), | ||
| h('div', { class: 'modal-footer' }, [ | ||
| h('button', { | ||
| type: 'button', | ||
| class: 'btn btn-secondary btn-xs', | ||
| onClick() { | ||
| detailPolicy.value = null; | ||
| }, | ||
| }, 'Close'), | ||
| ]), | ||
| ]), | ||
| ]), | ||
| ]); | ||
|
|
||
| children.push(h(Teleport, { to: 'body' }, [backdrop, modal])); | ||
| } |
There was a problem hiding this comment.
This custom modal is missing basic focus management.
aria-modal="true" alone is not enough here: focus is never moved into the dialog, trapped while it is open, or restored on close. Keyboard users can tab into the page behind the modal, which breaks the assignment flow. Please use a shared modal abstraction if one exists, or add explicit focus management before shipping this.
🤖 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-policy/APermissionPolicyAssignments.ts`
around lines 81 - 135, The custom modal created when detailPolicy.value is set
(variables: modalTitleId, backdrop, modal, Teleport, APolicySummary) lacks focus
management—move keyboard focus into the modal when opened (e.g., to the modal
container or first focusable element), implement a focus trap to keep
Tab/Shift+Tab cycling within the modal, restore focus to the previously focused
element when detailPolicy.value is cleared, and prevent background content from
being focusable (use inert/aria-hidden on the rest of the document or use the
app's shared modal abstraction if available); also handle Escape to close the
modal and ensure backdrop and modal onClick handlers don’t block keyboard focus
behavior.
| emits: ['click'], | ||
| setup(props, { emit }) { | ||
| return () => h('button', { | ||
| class: 'btn btn-xs btn-outline-info', | ||
| title: 'View policy details', | ||
| onClick(e: Event) { | ||
| e.preventDefault(); | ||
| emit('click', props.policyId); |
There was a problem hiding this comment.
This control still doesn't navigate to the policy page.
It only emits a local click with policyId, so callers can open a preview, but they still cannot navigate to /policies/[id] from assignment contexts as required by the issue. Please expose a real route/href here, or render the link directly instead of limiting this component to local state changes.
🤖 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/policy/APolicyDetailNav.ts`
around lines 17 - 24, The component APolicyDetailNav currently only emits a
local 'click' with props.policyId and doesn't provide a real navigation target;
change the render in setup (the onClick handler / button) to produce a real link
target (either render an <a> with href={`/policies/${props.policyId}`} or use
the router API like router-link/router.push) so consumers can navigate from
assignment contexts; keep or still emit the click if needed, but ensure the
element exposes a real href/route (referencing APolicyDetailNav, setup, onClick,
props.policyId) so clicking navigates to /policies/[id] rather than only
updating local state.
| const rows = [ | ||
| renderRow('Name', props.entity.name), | ||
| renderRow('Type', h(APolicyTypeBadge, { type: props.entity.type })), | ||
| ]; | ||
|
|
||
| if (props.entity.display_name) { | ||
| rows.push(renderRow('Display Name', props.entity.display_name)); | ||
| } | ||
|
|
||
| if (props.entity.description) { | ||
| rows.push(renderRow('Description', props.entity.description)); | ||
| } | ||
|
|
||
| if (props.entity.invert) { | ||
| rows.push(renderRow('Invert', h('span', { class: 'badge bg-warning' }, 'Yes'))); | ||
| } | ||
|
|
||
| if (props.entity.built_in) { | ||
| rows.push(renderRow('Built-in', h('span', { class: 'badge bg-secondary' }, 'Yes'))); | ||
| } | ||
|
|
||
| return h('div', rows); |
There was a problem hiding this comment.
The detail view still hides the actual policy configuration.
This summary only shows generic fields. Composite children, decision strategy, attribute rules, realm matching, and other type-specific config are still invisible, so the original inspection problem remains unresolved for the policies users most need to review.
🤖 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/policy/APolicySummary.ts`
around lines 29 - 50, APolicySummary currently only renders generic fields via
renderRow and omits policy-specific configuration; update the component to also
render composite children, decisionStrategy, attribute rules,
realm/realmMatching and any type-specific config from props.entity so users can
inspect the full policy. In APolicySummary (and where renderRow is used) add
conditional rows for props.entity.children (or compositeChildren) listing child
IDs/names, props.entity.decision_strategy (or decisionStrategy),
props.entity.rules/attributeRules with a compact readable rendering,
props.entity.realm or realmMatching settings, and switch on props.entity.type to
output type-specific fields; reuse renderRow and small helper renderers to keep
markup consistent and ensure badges/labels match existing style.
closes #2989
Summary by CodeRabbit
Release Notes