mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Problem Filtering via properties in the Overview tab of Unified Logs had a couple of clicks to it. ## Solution Attribute rows now expose equals and not-equals directly, through one shared code path. - **Hover devices** (`(hover: hover) and (pointer: fine)` above `md`): hovering or keyboard-focusing a row reveals borderless icon buttons at its right edge — equals, not equals, copy — following the same reveal pattern as the "Only" button on the sidebar filters. The value fades out behind them so nothing is occluded or reflowed. - **Touch devices and small viewports**: unchanged dropdown, now listing "Filter: equals", "Filter: not equals" and "Copy <attribute>" instead of the single "Add filter". - Only rows that can actually be filtered get filter actions; everything else gets copy alone. | Before | After | |--------|--------| | <img width="451" height="191" alt="Screenshot 2026-11-09 at 16 12 08" src="https://github.com/user-attachments/assets/ffc68a34-4373-44ea-8922-8f5b3dd436a0" /> | <img width="465" height="148" alt="Screenshot 2026-11-09 at 16 12 25" src="https://github.com/user-attachments/assets/0bf41014-25d7-4390-ba5f-ab7a796ec1de" /> | ## Review instructions 1. Open the preview, go to a project's Logs, and click a log row to open the detail dock on the Overview tab. 2. Hover a filterable row (Path, Method, Status, or any attribute). Equals, not-equals and copy buttons fade in at the right edge; the value fades out. Tab into them to check the focus rings and tooltips. 3. Click the equals button on Path. The filter appears in the filter bar and the log list updates. Do the same with not-equals on another row and confirm the chip uses `<>`. 4. Hover a row that can't be filtered (for example Host or Client). Only the copy button appears, and no filter action is offered. 5. Apply the same filter twice — no duplicate chip. Then apply the opposite operator on that column — the chip's operator is replaced rather than mixed. 6. Narrow the window below 768px (or use a touch device). The hover buttons disappear and clicking a row opens the dropdown with "Filter: equals", "Filter: not equals" and "Copy <attribute>".
66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
import { getCoreRowModel, useReactTable } from '@tanstack/react-table'
|
|
import { screen } from '@testing-library/react'
|
|
import userEvent from '@testing-library/user-event'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
import { columnSchema } from '../UnifiedLogs.schema'
|
|
import { LogOverview } from './LogOverview'
|
|
import { customRender as render } from '@/tests/lib/custom-render'
|
|
|
|
const row = columnSchema.parse({
|
|
id: 'postgres-log',
|
|
log_type: 'postgres',
|
|
timestamp: '2026-01-01T10:00:00Z',
|
|
date: new Date('2026-01-01T10:00:00Z'),
|
|
event_message: 'Statement finished',
|
|
method: null,
|
|
pathname: null,
|
|
status: null,
|
|
level: 'success',
|
|
})
|
|
|
|
function Overview({
|
|
attribute,
|
|
value,
|
|
onAddAttributeFilter,
|
|
}: {
|
|
attribute: string
|
|
value: string | number | boolean
|
|
onAddAttributeFilter: (key: string, value: string) => void
|
|
}) {
|
|
const table = useReactTable({ data: [row], columns: [], getCoreRowModel: getCoreRowModel() })
|
|
return (
|
|
<LogOverview
|
|
data={row}
|
|
table={table}
|
|
filterFields={[]}
|
|
attributes={{ [attribute]: value }}
|
|
onAddAttributeFilter={onAddAttributeFilter}
|
|
/>
|
|
)
|
|
}
|
|
|
|
describe('specialized log attribute actions', () => {
|
|
it.each([
|
|
['request_id', 'req-1'],
|
|
['trace_id', 'trace-1'],
|
|
['span_id', 'span-1'],
|
|
['execution_id', 'exec-1'],
|
|
['request.count', 0],
|
|
['request.enabled', false],
|
|
] as const)('filters by the stored %s key and scalar value', async (attribute, value) => {
|
|
const user = userEvent.setup()
|
|
const onAddAttributeFilter = vi.fn()
|
|
render(
|
|
<Overview attribute={attribute} value={value} onAddAttributeFilter={onAddAttributeFilter} />
|
|
)
|
|
await user.click(screen.getByRole('button', { name: 'Attributes' }))
|
|
const section = attribute.startsWith('request.') ? 'Request' : 'Details'
|
|
await user.click(screen.getByRole('button', { name: section }))
|
|
const label = attribute.replace(/^request\./, '')
|
|
await user.click(screen.getByRole('button', { name: `${label} ${value}` }))
|
|
await user.click(screen.getByRole('menuitem', { name: 'Filter: equals' }))
|
|
expect(onAddAttributeFilter).toHaveBeenCalledExactlyOnceWith(attribute, String(value), '=')
|
|
})
|
|
})
|