forked from supabase/supabase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore/reports read replicas filter (supabase#23711)
* Scaffold for API reports * Add support for filtering database reports by replicas * midway adding read replica support for custom reports * Refactor reports page to use react query and deprecate project content mobxstore * Reports add chart labels if metric is read replica specific * Give an easier way to remove charts from reports * make reports layout non-blocking * Update apps/studio/components/interfaces/Reports/Reports.tsx Co-authored-by: Alaister Young <[email protected]> --------- Co-authored-by: Alaister Young <[email protected]> Co-authored-by: Alaister Young <[email protected]>
- Loading branch information
1 parent
02c0d75
commit 1afaae6
Showing
26 changed files
with
650 additions
and
737 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
57 changes: 57 additions & 0 deletions
57
apps/studio/components/interfaces/Reports/MetricOptions.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Home } from 'lucide-react' | ||
|
||
import { useIsFeatureEnabled } from 'hooks' | ||
import { METRICS, METRIC_CATEGORIES } from 'lib/constants/metrics' | ||
import { | ||
DropdownMenuCheckboxItem, | ||
DropdownMenuPortal, | ||
DropdownMenuSub, | ||
DropdownMenuSubContent, | ||
DropdownMenuSubTrigger, | ||
} from 'ui' | ||
|
||
interface MetricOptionsProps { | ||
config: any | ||
handleChartSelection: any | ||
} | ||
|
||
export const MetricOptions = ({ config, handleChartSelection }: MetricOptionsProps) => { | ||
const { projectAuthAll: authEnabled, projectStorageAll: storageEnabled } = useIsFeatureEnabled([ | ||
'project_auth:all', | ||
'project_storage:all', | ||
]) | ||
|
||
const metricCategories = Object.values(METRIC_CATEGORIES).filter(({ key }) => { | ||
if (key === 'api_auth') return authEnabled | ||
if (key === 'api_storage') return storageEnabled | ||
return true | ||
}) | ||
|
||
return metricCategories.map((cat) => { | ||
return ( | ||
<DropdownMenuSub key={cat.key}> | ||
<DropdownMenuSubTrigger className="space-x-2"> | ||
{cat.icon ? cat.icon : <Home size={14} />} | ||
<p>{cat.label}</p> | ||
</DropdownMenuSubTrigger> | ||
<DropdownMenuPortal> | ||
<DropdownMenuSubContent> | ||
{METRICS.filter((metric) => metric?.category?.key === cat.key).map((metric) => { | ||
return ( | ||
<DropdownMenuCheckboxItem | ||
key={metric.key} | ||
checked={config.layout?.some((x: any) => x.attribute === metric.key)} | ||
onCheckedChange={(e) => handleChartSelection({ metric, value: e })} | ||
> | ||
<div className="flex flex-col space-y-0"> | ||
<span>{metric.label}</span> | ||
</div> | ||
</DropdownMenuCheckboxItem> | ||
) | ||
})} | ||
</DropdownMenuSubContent> | ||
</DropdownMenuPortal> | ||
</DropdownMenuSub> | ||
) | ||
}) | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.