mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
## Problem On the organization usage page, the per-project breakdowns list project names, but there's no way to jump to that project's usage. You have to find it in the project dropdown instead. Resolves FE-5153. ## Solution Project names in the usage breakdowns are now buttons that set the `projectRef` filter and clear `branchRef`, so the page shows that project's usage. The other query params, such as the date range, are left alone. - New `UsageProjectName` component. It renders plain text when that project is already selected, and a button otherwise. It underlines on hover only. - Applied in the metric breakdown tooltip (`BillingMetric`), the compute hover card (`ComputeMetric`) and the database size table (`DatabaseSizeUsage`). - `TotalUsage` passes the selected `projectRef` down to the metric components. - The `projectRef`/`branchRef` nuqs parsers are now shared as `usageFilterParsers` in `Usage.utils.ts`, so `Usage` and `UsageProjectName` use the same definition. Tests cover the click updating the URL (and clearing `branchRef`), the selected project rendering as text, and the `BillingMetric` breakdown in both states. <img width="410" height="296" alt="Screenshot 2026-11-19 at 13 36 17" src="https://github.com/user-attachments/assets/1f032cc3-d0e2-4185-80f7-4ab3303fc6b6" /> ## Review instructions 1. Open an organization's usage page (`/org/<slug>/usage`) for an org with several projects. 2. Hover a metric that has a per-project breakdown, such as Egress, and click a project name. 3. The project dropdown should switch to that project and the usage should update. Any date range you had selected should survive the click. 4. Hover the same metric again. The selected project is now plain text and the others are still clickable. 5. Do the same from the compute hover card and the database size table. ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
38 lines
880 B
TypeScript
38 lines
880 B
TypeScript
import { useQueryStates } from 'nuqs'
|
|
import { cn } from 'ui'
|
|
|
|
import { usageFilterParsers } from './Usage.utils'
|
|
|
|
interface UsageProjectNameProps {
|
|
name: string
|
|
projectRef: string
|
|
selectedProjectRef?: string | null
|
|
className?: string
|
|
}
|
|
|
|
export const UsageProjectName = ({
|
|
name,
|
|
projectRef,
|
|
selectedProjectRef,
|
|
className,
|
|
}: UsageProjectNameProps) => {
|
|
const [, setUsageFilter] = useQueryStates(usageFilterParsers)
|
|
|
|
if (selectedProjectRef === projectRef) return <span className={className}>{name}</span>
|
|
|
|
return (
|
|
<button
|
|
type="button"
|
|
tabIndex={0}
|
|
title="Show usage for this project only"
|
|
className={cn(
|
|
'text-left transition underline-offset-2 hover:underline hover:text-foreground',
|
|
className
|
|
)}
|
|
onClick={() => setUsageFilter({ projectRef, branchRef: null })}
|
|
>
|
|
{name}
|
|
</button>
|
|
)
|
|
}
|