Files
supabase/apps/studio/components/ui/QueryBlock/BlockViewConfiguration.tsx
T
Joshen Lim 09a1f431bc Mass update for all lucide icon imports to use the component with Icon suffix (#51659)
## Context

This is largely just a mechanical change here:
Opting to use lucide icons with the `Icon` suffix across all icon
imports within `studio`
- so that it’s clearer which components are icons + reduces the
possibility of name collision with our own components
- e.g <User /> vs <UserIcon />

Also added a eslint rule for this:
<img width="1069" height="167" alt="image"
src="https://github.com/user-attachments/assets/7f36f443-5ca2-4bf6-8d22-86e774513bfc"
/>

And updated `AGENTS.md` as such:
```
Icons come from `lucide-react`, always imported with the `Icon` suffix (`import { CheckIcon, Trash2Icon } from 'lucide-react'`) — never the bare names (`Check`) or `Check as CheckIcon` aliases (lint-enforced).
```
2026-10-14 12:56:55 +02:00

146 lines
4.6 KiB
TypeScript

import { BarChart2Icon, Settings2Icon, TableIcon } from 'lucide-react'
import {
Checkbox,
Label,
Popover,
PopoverContent,
PopoverTrigger,
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
ToggleGroup,
ToggleGroupItem,
} from 'ui'
import { ButtonTooltip } from '../ButtonTooltip'
import { ChartConfig } from '@/components/interfaces/SQLEditor/UtilityPanel/ChartConfig'
interface BlockViewConfigurationProps {
columns: string[]
view: 'chart' | 'table'
isChart: boolean
lockColumns?: boolean
chartConfig?: ChartConfig
changeView: (value: 'chart' | 'table') => void
updateChartConfig: (config: ChartConfig) => void
}
export const BlockViewConfiguration = ({
columns,
view,
isChart,
lockColumns = false,
chartConfig,
changeView,
updateChartConfig,
}: BlockViewConfigurationProps) => {
return (
<Popover modal={false}>
<PopoverTrigger asChild>
<ButtonTooltip
id="help-popover-button"
variant="text"
className="px-1"
icon={<Settings2Icon size={14} strokeWidth={1.5} />}
tooltip={{ content: { side: 'bottom', text: 'View data' } }}
/>
</PopoverTrigger>
<PopoverContent side="bottom" align="center" className="w-[240px] p-3">
<form className="grid gap-2">
<ToggleGroup
type="single"
variant="outline"
value={view}
className="w-full"
onValueChange={(view: 'chart' | 'table') => {
if (view) changeView(view)
}}
>
<ToggleGroupItem className="w-full" value="table" aria-label="Show as table">
<TableIcon className="h-4 w-4" />
<p className="text-xs ml-2">As table</p>
</ToggleGroupItem>
<ToggleGroupItem className="w-full" value="chart" aria-label="Show as chart">
<BarChart2Icon className="h-4 w-4" />
<p className="text-xs ml-2">As chart</p>
</ToggleGroupItem>
</ToggleGroup>
{isChart && chartConfig && (
<>
<Select
disabled={lockColumns}
value={chartConfig?.xKey}
onValueChange={(value) => updateChartConfig({ ...chartConfig, xKey: value })}
>
<SelectTrigger className="text-left">
X Axis {chartConfig?.xKey && `- ${chartConfig.xKey}`}
</SelectTrigger>
<SelectContent>
<SelectGroup>
{columns.map((key) => (
<SelectItem value={key} key={key}>
{key}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
<Select
disabled={lockColumns}
value={chartConfig?.yKey}
onValueChange={(value) => updateChartConfig({ ...chartConfig, yKey: value })}
>
<SelectTrigger className="text-left">
Y Axis {chartConfig?.yKey && `- ${chartConfig.yKey}`}
</SelectTrigger>
<SelectContent>
<SelectGroup>
{columns.map((key) => (
<SelectItem value={key} key={key}>
{key}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
<div className="*:flex *:gap-2 *:items-center grid gap-2 *:text-foreground-light *:p-1.5 *:pl-0">
<Label htmlFor="cumulative">
<Checkbox
id="cumulative"
checked={chartConfig?.cumulative}
onClick={() =>
updateChartConfig({
...chartConfig,
cumulative: !chartConfig?.cumulative,
})
}
/>
Cumulative
</Label>
<Label htmlFor="logScale">
<Checkbox
id="logScale"
checked={chartConfig?.logScale}
onClick={() =>
updateChartConfig({
...chartConfig,
logScale: !chartConfig?.logScale,
})
}
/>
Log scale
</Label>
</div>
</>
)}
</form>
</PopoverContent>
</Popover>
)
}