feat(frontend): per-team spend breakdown in org billing tab (SECRT-2450) - #13659
feat(frontend): per-team spend breakdown in org billing tab (SECRT-2450)#13659ntindle wants to merge 6 commits into
Conversation
Add a billing-manager/owner-gated Billing tab to org settings with a
spend-by-team table riding GET /api/orgs/{org}/spend:
- TeamSpendSection renders one row per team plus the org-home row (team_id
null), showing team name, spend (credits formatted as dollars), and run
count, with design-system Skeleton loading and ErrorCard failure states.
Uses the endpoint's own team_name (not TeamBadge) since a billing manager
can see spend for teams they aren't a member of.
- Gating: canManageBilling (owner or billing_manager, not plain admin —
matches MANAGE_BILLING in the backend permission matrix) shows the tab and
content; the query stays disabled otherwise, and a ?tab=billing deep link
falls back to General for members without the right.
Co-Authored-By: Claude Opus <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
|
/batch orgs |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feat/memory-tier-ui #13659 +/- ##
====================================================
Coverage 76.16% 76.17%
====================================================
Files 2748 2751 +3
Lines 202382 202397 +15
Branches 19697 19688 -9
====================================================
+ Hits 154152 154179 +27
+ Misses 43950 43872 -78
- Partials 4280 4346 +66
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…/team-spend-display Clean forward-merge (inherits OrgTeamProvider + AddToLibraryButton resolutions). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBwmh7CkHiF8vKLBf2GWTU
…eSupabase→useAuth (keep branch's test additions) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBwmh7CkHiF8vKLBf2GWTU
…dToLibraryButton test useAuth fix Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBwmh7CkHiF8vKLBf2GWTU
Why
SECRT-2450 tail: the per-team spend endpoint (#13530) had no UI.
What
New Billing tab in org settings, gated to owner/billing_manager (
canManageBilling— not plain admin, matching the billing role-gating decision), rendering TeamSpendSection: team / spend (credits→dollars) / run count, with an org-home row. Uses the endpoint's ownteam_namerather than TeamBadge since billing managers can see spend for teams they aren't in. Deep-link?tab=billingdegrades to General for unauthorized roles.Testing
2 tests (rows incl. org-home from mocked endpoint; hidden + zero requests for non-billing roles). format/lint/types clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Jm3mCG9okfdGtAXtFaDF9A
Note
Low Risk
Read-only billing UI with role gating aligned to backend permissions; no payment or mutation paths.
Overview
Adds a Billing tab to organization settings that shows per-team credit spend for owners and billing managers only (not org admins without billing rights).
The tab loads spend via the existing per-team breakdown API and renders a table of team name, dollar spend (cents → dollars), and run count, including an Organization row for org-home usage (
nullteam_id). Team labels come from the API response so billing managers can see teams they are not members of. Unauthorized users do not see the tab;?tab=billingfalls back to General. The spend query stays disabled when billing access is denied.Includes
TeamSpendSectiontests for mocked rows and for no UI/request whencanManageBillingis false.Reviewed by Cursor Bugbot for commit 9f22ddd. Bugbot is set up for automated code reviews on this repo. Configure here.