mirror of
https://github.com/supabase/supabase.git
synced 2026-10-18 07:39:07 +03:00
* chore: cleanup packages - Avoid circular imports - Export API-types as types - pg-format without depending on Node internal Buffer (not browser-compatible) - Avoid importing from barrel files in ui dir * chore: avoid barrel file imports in studio (#27771) * chore: avoid barrel file imports - Removes some unused imports - Avoids barrel file import for faster builds + less memory * add eslint rule * type fixes * delete layouts barrel * delete components/grid barrel file * delete components/grid/utils barrel file * delete components/grid/components/common barrel file * delete components/grid/components/editor barrel file * delete components/grid/components/formatter barrel file * delete components/grid/components/grid barrel file * delete components/grid/components/header/filter barrel file * remote components/grid/store barrel file * remove components/interfaces/Auth/Policies barrel file * delete components/interfaces/Settings/Logs barrel file * delete components/ui/CodeEditor barrel file * delete components/ui/Forms barrel file * delete components/ui/Shimmers barrel file * delete data/analytics barrel file * delete hooks barrel file * cleanup lib/common/fetch barrel file * final * barral files cleanup * global react-data-grid styles * remove console.log --------- Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com> * fix build --------- Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import { Home } from 'lucide-react'
|
|
|
|
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
|
|
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>
|
|
)
|
|
})
|
|
}
|