Repository navigation
fix: SCO-173 gate order menu items to what the server allows - #397
Merged
Merged
Conversation
The order detail "More actions" menu offered Clone, Download PDF, and Cancel to every viewer, so buyers, guests, and federated viewers saw actions guaranteed to fail. A new orderMenuItems predicate mirrors each action's server rule, the clone and PDF endpoints now read their role sets from the same place, and the trigger hides when no item is left. Cancel also surfaces an error instead of failing silently when RLS refuses the update. SCO-173 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
orderMenuItemspredicate (src/lib/utils/order-menu-permissions.ts) decides which "More actions" items the order detail page offers, each mirroring its server rule:loadOwnOrgOrder+ORDER_WRITE_ROLES). Hidden for buyers, guests, and federated viewers.ORDER_PDF_ROLES. Hidden for buyers and guests.Brand admin updates federated order status); never buyers (their policy's WITH CHECK only allowsdraft/submitted).Why
The menu offered every action to every viewer, so buyers, guests, and federated viewers saw actions guaranteed to fail. The ticket's open question (should buyers clone?) is settled by the server: the clone endpoint already 404s for buyers, and buyer re-order belongs to the cart path in SCO-168.
Sibling audit
resolveReturnEntryand is role-blind, as is the/returns/newaction. That's a server gap, filed as SCO-213.Verification
bun run lintpassesbun run checkpasses (0 errors)bun run test:run: 2046 pass, including 16 new tests fororderMenuItems. The 10 localrecent-searchesfailures are pre-existing (Node v26 localStorage) and pass in CI.Test plan
/orders/[id]as a guest: no "More actions" button (unless a return entry applies).Closes SCO-173
🤖 Generated with Claude Code