Skip to content

fix(rbac/plans): let creator manage own scheduled purchase from Plans page (closes #1442) - #1443

Merged
cristim merged 1 commit into
mainfrom
fix/1442-manage-own-plans-scheduled-purchase
Jul 17, 2026
Merged

cristim merged 1 commit into
mainfrom
fix/1442-manage-own-plans-scheduled-purchase

Conversation

@cristim

@cristim cristim commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

  • Standard users with cancel-own:purchases could not see the Disable button on their own scheduled purchases in the Plans page, even though:
  • The Plans-page canDisablePlan gate in plans.ts required delete:purchases exclusively. Standard users hold cancel-own:purchases, not delete:purchases, so the button was hidden even for the creator.
  • canManageScheduledPurchase already enforced the ownership check; only the verb gate in canDisablePlan was wrong.

Changes

Frontend (frontend/src/plans.ts)

Tests (frontend/src/__tests__/plans-ownership-950.test.ts)

  • Extended setUser helper to accept cancelOwn, cancelAny, and deletePurchases opts (backward-compatible: deletePurchases defaults to true).
  • New describe block "Plans-page Disable-button cancel-own gating (issue bug(rbac/plans): creator cannot manage own scheduled purchase created from Plans page #1442)" with 4 cases:
    • Creator with cancel-own (no delete:purchases) sees the Disable button
    • Non-creator with cancel-own does NOT see the Disable button (ownership gate holds)
    • Legacy NULL-creator row shows no Disable for a cancel-own user
    • cancel-any creator 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 canDisablePlan gate. This is a genuine gap, not a stale re-test.

Test plan

  • Frontend tests: 79 suites, 2641 passed, 0 failures, exit 0
  • Frontend typecheck: tsc --noEmit exit 0
  • Go build: go build ./... exit 0
  • Go vet: go vet ./... exit 0
  • Pre-commit hooks: all passed
  • Manual: log in as Standard user, navigate to Plans page, verify Disable button appears on own scheduled purchases and is absent on other users' rows

Closes #1442

… 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)
@cristim cristim added triaged Item has been triaged priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-sprint Within the current sprint impact/many Affects most users effort/m Days type/bug Defect labels Jul 17, 2026
@cristim

cristim commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0bef76b3-9377-426a-ae7d-1d392d0462da

📥 Commits

Reviewing files that changed from the base of the PR and between f692085 and dd931b7.

📒 Files selected for processing (2)
  • frontend/src/__tests__/plans-ownership-950.test.ts
  • frontend/src/plans.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1442-manage-own-plans-scheduled-purchase

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim merged commit 16f9b80 into main Jul 17, 2026
20 checks passed
@cristim
cristim deleted the fix/1442-manage-own-plans-scheduled-purchase branch July 27, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/m Days impact/many Affects most users priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(rbac/plans): creator cannot manage own scheduled purchase created from Plans page

1 participant