Repository navigation
fix(rbac/plans): let creator manage own scheduled purchase from Plans page (closes #1442) - #1443
Conversation
… page (closes #1442) canDisablePlan in plans.ts required delete:purchases, which Standard users do not hold. PR #1421 updated the backend (deletePlannedPurchase) and the Home-page widget (canCancelUpcomingPurchase) to accept cancel-own:purchases, but the Plans-page Disable-button gate was not updated. The creator's canManagePurchase was already true via canManageScheduledPurchase; only the verb check was wrong. Accept cancel-own:purchases and cancel-any:purchases alongside delete:purchases in canDisablePlan, mirroring the backend requireDeleteOrCancelPurchasePermission gate and the dashboard canCancelUpcomingPurchase logic from PR #1421. Regression tests added to plans-ownership-950.test.ts: - Creator with cancel-own (no delete) sees Disable on their own row - Non-creator with cancel-own does not see Disable (ownership gate holds) - Legacy NULL-creator row shows no Disable for cancel-own user - cancel-any creator also sees Disable (backend supports it)
|
@coderabbitai review |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 50 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
✅ Action performedReview finished.
|
Summary
cancel-own:purchasescould not see the Disable button on their own scheduled purchases in the Plans page, even though:deletePlannedPurchasealready acceptscancel-own:purchases(PR fix(home): show Cancel button for own scheduled purchases #1421)canCancelUpcomingPurchasealready acceptscancel-own:purchases(PR fix(home): show Cancel button for own scheduled purchases #1421)canDisablePlangate inplans.tsrequireddelete:purchasesexclusively. Standard users holdcancel-own:purchases, notdelete:purchases, so the button was hidden even for the creator.canManageScheduledPurchasealready enforced the ownership check; only the verb gate incanDisablePlanwas wrong.Changes
Frontend (
frontend/src/plans.ts)canDisablePlan: extended to acceptcancel-any:purchasesorcancel-own:purchasesin addition todelete:purchases, mirroring the backendrequireDeleteOrCancelPurchasePermissiongate and the dashboardcanCancelUpcomingPurchaselogic introduced by PR fix(home): show Cancel button for own scheduled purchases #1421.authorizePlannedPurchaseCancel(the current backend function name after fix(home): show Cancel button for own scheduled purchases #1421, not the oldauthorizeExecutionManagement).Tests (
frontend/src/__tests__/plans-ownership-950.test.ts)setUserhelper to acceptcancelOwn,cancelAny, anddeletePurchasesopts (backward-compatible:deletePurchasesdefaults totrue).cancel-own(nodelete:purchases) sees the Disable buttoncancel-owndoes NOT see the Disable button (ownership gate holds)cancel-ownusercancel-anycreator also sees Disable (backend supports it)Verify-first result
PR #1421 updated the backend and the Home-page widget but did NOT update the Plans-page
canDisablePlangate. This is a genuine gap, not a stale re-test.Test plan
tsc --noEmitexit 0go build ./...exit 0go vet ./...exit 0Closes #1442