Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(studio): add time range to project logs filter bar (#50685)

Saxon Fletcher76c4f2b73982
diff --git a/apps/design-system/content/docs/fragments/filter-bar.mdx b/apps/design-system/content/docs/fragments/filter-bar.mdx
index 34cbf1ac0e3..50a5b2a9e2b 100644
--- a/apps/design-system/content/docs/fragments/filter-bar.mdx
+++ b/apps/design-system/content/docs/fragments/filter-bar.mdx
@@ -60,6 +60,7 @@ interface FilterProperty {
name: string
type: 'string' | 'number' | 'date' | 'boolean'
operators: string[]
+ formatValue?: (value: FilterCondition['value']) => string
options?: string[] | ((search?: string) => Promise<string[]> | string[])
}
```
diff --git a/apps/studio/components/interfaces/Settings/Logs/Logs.DatePickers.tsx b/apps/studio/components/interfaces/Settings/Logs/Logs.DatePickers.tsx
index 7d109344cdd..6899eb113d9 100644
--- a/apps/studio/components/interfaces/Settings/Logs/Logs.DatePickers.tsx
+++ b/apps/studio/components/interfaces/Settings/Logs/Logs.DatePickers.tsx
@@ -18,7 +18,7 @@ import {
} from 'ui'
import { LOGS_LARGE_DATE_RANGE_DAYS_THRESHOLD } from './Logs.constants'
-import { generateHelpersFromInput } from './Logs.datePickerHelpers'
+import { formatDateRange, generateHelpersFromInput } from './Logs.datePickerHelpers'
import type { DatetimeHelper } from './Logs.types'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { TimeSplitInput } from '@/components/ui/DatePicker/TimeSplitInput'
@@ -55,6 +55,7 @@ interface LogsDatePickerProps {
* top of the picker. Leave undefined to render no tooltip.
*/
shortcutId?: ShortcutId
+ variant?: 'popover' | 'inline'
}
export const LogsDatePicker = ({
@@ -68,10 +69,11 @@ export const LogsDatePicker = ({
open: openProp,
onOpenChange,
shortcutId,
+ variant = 'popover',
}: PropsWithChildren<LogsDatePickerProps>) => {
const [internalOpen, setInternalOpen] = useState(false)
const isControlled = openProp !== undefined
- const open = isControlled ? openProp : internalOpen
+ const open = variant === 'inline' || (isControlled ? openProp : internalOpen)
const setOpen = (next: boolean) => {
if (!isControlled) setInternalOpen(next)
onOpenChange?.(next)
@@ -84,9 +86,9 @@ export const LogsDatePicker = ({
return generated ?? []
}, [customValue, helpers])
- // Reset the state when the popover closes
+ // Reset when the popover closes, or sync an inline picker with the committed range.
useEffect(() => {
- if (!open) {
+ if (!open || variant === 'inline') {
setCustomValue('')
setStartDate(toValidDate(value.from))
const defaultEndDate = toValidDate(value.to) ?? new Date()
@@ -113,7 +115,7 @@ export const LogsDatePicker = ({
ss: toDate?.getSeconds().toString().padStart(2, '0') || nowSS,
})
}
- }, [open, value])
+ }, [open, value.from, value.to, variant])
const handleHelperChange = (newValue: string) => {
const selectedHelper = displayedHelpers.find((h) => h.text === newValue)
@@ -256,7 +258,7 @@ export const LogsDatePicker = ({
}, [pasted])
useEffect(() => {
- if (open) {
+ if (open && variant === 'popover') {
document.addEventListener('paste', handlePaste)
document.addEventListener('copy', handleCopy)
}
@@ -264,7 +266,7 @@ export const LogsDatePicker = ({
document.removeEventListener('paste', handlePaste)
document.removeEventListener('copy', handleCopy)
}
- }, [open, startDate, endDate, handleCopy])
+ }, [open, variant, startDate, endDate, handleCopy])
const isLargeRange =
Math.abs(dayjs(startDate).diff(dayjs(endDate), 'days')) >
@@ -285,13 +287,149 @@ export const LogsDatePicker = ({
const triggerButton = (
<PopoverTrigger asChild>
<Button icon={<Clock size={12} />} {...buttonTriggerProps}>
- {value.isHelper
- ? value.text
- : `${dayjs(value.from).format('DD MMM, HH:mm')} - ${dayjs(value.to || new Date()).format('DD MMM, HH:mm')}`}
+ {value.isHelper ? value.text : formatDateRange(value.from, value.to)}
</Button>
</PopoverTrigger>
)
+ const content = (
+ <div className="flex">
+ <div className="border-r p-2 flex flex-col gap-px">
+ <Input
+ type="text"
+ placeholder="e.g. 2h, 30m, 7d"
+ value={customValue}
+ onChange={(e) => setCustomValue(e.target.value)}
+ className="mb-2 text-xs h-7 rounded-xs"
+ />
+ <RadioGroup
+ onValueChange={handleHelperChange}
+ value={value.isHelper ? value.text : ''}
+ className="flex flex-col gap-px"
+ >
+ {displayedHelpers.map((helper) => (
+ <Label
+ key={helper.text}
+ className={cn(
+ '[&:has([data-state=checked])]:bg-background-overlay-hover [&:has([data-state=checked])]:text-foreground px-4 py-1.5 text-foreground-light flex items-center gap-2 hover:bg-background-overlay-hover hover:text-foreground transition-all rounded-xs text-xs w-full',
+ {
+ 'cursor-not-allowed pointer-events-none opacity-50': helper.disabled,
+ }
+ )}
+ >
+ <RadioGroupItem
+ hidden
+ key={helper.text}
+ value={helper.text}
+ disabled={helper.disabled}
+ aria-disabled={helper.disabled}
+ />
+ {helper.text}
+ {showHelperBadge(helper) ? (
+ <Lock size={12} className="text-foreground-muted" />
+ ) : null}
+ </Label>
+ ))}
+ {displayedHelpers.length === 0 && (
+ <p className="px-2 py-1.5 text-xs text-foreground-light w-full">
+ Invalid format. Try 2h, 30m, or 7d.
+ </p>
+ )}
+ </RadioGroup>
+ </div>
+
+ <div className="w-fit max-w-full">
+ <div className="flex p-2 gap-2 items-center">
+ <div className="flex grow *:grow gap-2 font-mono">
+ <TimeSplitInput
+ type="start"
+ startTime={startTime}
+ endTime={endTime}
+ time={startTime}
+ setTime={setStartTime}
+ setStartTime={setStartTime}
+ setEndTime={setEndTime}
+ startDate={startDate}
+ endDate={endDate}
+ />
+ <TimeSplitInput
+ type="end"
+ startTime={startTime}
+ endTime={endTime}
+ time={endTime}
+ setTime={setEndTime}
+ setStartTime={setStartTime}
+ setEndTime={setEndTime}
+ startDate={startDate}
+ endDate={endDate}
+ />
+ </div>
+ <div className="shrink">
+ <ButtonTooltip
+ tooltip={{
+ content: {
+ text: 'Clear time range',
+ },
+ }}
+ icon={<HistoryIcon size={14} />}
+ variant="text"
+ size="tiny"
+ className="px-1.5"
+ onClick={() => {
+ setStartTime({ HH: '00', mm: '00', ss: '00' })
+ setEndTime({ HH: '00', mm: '00', ss: '00' })
+ }}
+ ></ButtonTooltip>
+ </div>
+ </div>
+ <div className="border-t">
+ <Calendar
+ mode="range"
+ month={currentMonth}
+ onMonthChange={(month) => setCurrentMonth(new Date(month))}
+ selected={{ from: startDate ?? undefined, to: endDate ?? undefined }}
+ onSelect={(range) => {
+ handleDatePickerChange([range?.from ?? null, range?.to ?? null])
+ }}
+ />
+ </div>
+ {isLargeRange && !hideWarnings && (
+ <p className="w-0 min-w-full px-3 pt-1 pb-4 text-xs text-warning">
+ Large ranges may result in memory errors for big projects.
+ </p>
+ )}
+ <div className="flex items-center justify-end gap-2 p-2 border-t">
+ {startDate && endDate ? (
+ <Button
+ variant="text"
+ size="tiny"
+ onClick={handleCopy}
+ className={cn({ 'text-brand-link': copied || pasted })}
+ >
+ {copied ? 'Copied!' : pasted ? 'Pasted!' : 'Copy range'}
+ </Button>
+ ) : null}
+
+ <Button
+ onClick={() => {
+ const today = new Date()
+ setCurrentMonth(today)
+ setStartDate(new Date(today))
+ setEndDate(new Date(today))
+ }}
+ >
+ Today
+ </Button>
+ <Button variant="primary" onClick={handleApply}>
+ Apply
+ </Button>
+ </div>
+ </div>
+ </div>
+ )
+
+ if (variant === 'inline') return content
+
return (
<Popover open={open} onOpenChange={setOpen}>
{shortcutId ? (
@@ -307,139 +445,7 @@ export const LogsDatePicker = ({
align={align}
{...popoverContentProps}
>
- <div className="border-r p-2 flex flex-col gap-px">
- <Input
- type="text"
- placeholder="e.g. 2h, 30m, 7d"
- value={customValue}
- onChange={(e) => setCustomValue(e.target.value)}
- className="mb-2 text-xs h-7 rounded-xs"
- />
- <RadioGroup
- onValueChange={handleHelperChange}
- value={value.isHelper ? value.text : ''}
- className="flex flex-col gap-px"
- >
- {displayedHelpers.map((helper) => (
- <Label
- key={helper.text}
- className={cn(
- '[&:has([data-state=checked])]:bg-background-overlay-hover [&:has([data-state=checked])]:text-foreground px-4 py-1.5 text-foreground-light flex items-center gap-2 hover:bg-background-overlay-hover hover:text-foreground transition-all rounded-xs text-xs w-full',
- {
- 'cursor-not-allowed pointer-events-none opacity-50': helper.disabled,
- }
- )}
- >
- <RadioGroupItem
- hidden
- key={helper.text}
- value={helper.text}
- disabled={helper.disabled}
- aria-disabled={helper.disabled}
- ></RadioGroupItem>
- {helper.text}
- {showHelperBadge(helper) ? (
- <Lock size={12} className="text-foreground-muted" />
- ) : null}
- </Label>
- ))}
- {displayedHelpers.length === 0 && (
- <p className="px-2 py-1.5 text-xs text-foreground-light w-full">
- Invalid format. Try 2h, 30m, or 7d.
- </p>
- )}
- </RadioGroup>
- </div>
-
- <div className="w-fit max-w-full">
- <div className="flex p-2 gap-2 items-center">
- <div className="flex grow *:grow gap-2 font-mono">
- <TimeSplitInput
- type="start"
- startTime={startTime}
- endTime={endTime}
- time={startTime}
- setTime={setStartTime}
- setStartTime={setStartTime}
- setEndTime={setEndTime}
- startDate={startDate}
- endDate={endDate}
- />
- <TimeSplitInput
- type="end"
- startTime={startTime}
- endTime={endTime}
- time={endTime}
- setTime={setEndTime}
- setStartTime={setStartTime}
- setEndTime={setEndTime}
- startDate={startDate}
- endDate={endDate}
- />
- </div>
- <div className="shrink">
- <ButtonTooltip
- tooltip={{
- content: {
- text: 'Clear time range',
- },
- }}
- icon={<HistoryIcon size={14} />}
- variant="text"
- size="tiny"
- className="px-1.5"
- onClick={() => {
- setStartTime({ HH: '00', mm: '00', ss: '00' })
- setEndTime({ HH: '00', mm: '00', ss: '00' })
- }}
- ></ButtonTooltip>
- </div>
- </div>
- <div className="border-t">
- <Calendar
- mode="range"
- month={currentMonth}
- onMonthChange={(month) => setCurrentMonth(new Date(month))}
- selected={{ from: startDate ?? undefined, to: endDate ?? undefined }}
- onSelect={(range) => {
- handleDatePickerChange([range?.from ?? null, range?.to ?? null])
- }}
- />
- </div>
- {isLargeRange && !hideWarnings && (
- <p className="w-0 min-w-full px-3 pt-1 pb-4 text-xs text-warning">
- Large ranges may result in memory errors for big projects.
- </p>
- )}
- <div className="flex items-center justify-end gap-2 p-2 border-t">
- {startDate && endDate ? (
- <Button
- variant="text"
- size="tiny"
- onClick={handleCopy}
- className={cn({
- 'text-primary': copied || pasted,
- })}
- >
- {copied ? 'Copied!' : pasted ? 'Pasted!' : 'Copy range'}
- </Button>
- ) : null}
-
- <Button
- onClick={() => {
- const today = new Date()
- setCurrentMonth(today)
- setStartDate(new Date(today))
- setEndDate(new Date(today))
- }}
- >
- Today
- </Button>
- <Button variant="primary" onClick={handleApply}>
- Apply
- </Button>
- </div>
- </div>
+ {content}
</PopoverContent>
</Popover>
)
diff --git a/apps/studio/components/interfaces/Settings/Logs/Logs.datePickerHelpers.ts b/apps/studio/components/interfaces/Settings/Logs/Logs.datePickerHelpers.ts
index 76271b2eb50..73921e14712 100644
--- a/apps/studio/components/interfaces/Settings/Logs/Logs.datePickerHelpers.ts
+++ b/apps/studio/components/interfaces/Settings/Logs/Logs.datePickerHelpers.ts
@@ -70,3 +70,19 @@ export const generateHelpersFromInput = (input: string): DatetimeHelper[] | null
return null
}
}
+
+export const formatDateRange = (from: string, to: string): string =>
+ `${dayjs(from).format('DD MMM, HH:mm')} - ${dayjs(to || new Date()).format('DD MMM, HH:mm')}`
+
+export const findMatchingDateHelper = (
+ from: Date,
+ to: Date,
+ helpers: DatetimeHelper[]
+): DatetimeHelper | undefined =>
+ helpers.find((helper) => {
+ const tolerance = 60_000
+ return (
+ Math.abs(from.getTime() - new Date(helper.calcFrom()).getTime()) < tolerance &&
+ Math.abs(to.getTime() - new Date(helper.calcTo()).getTime()) < tolerance
+ )
+ })
diff --git a/apps/studio/components/interfaces/UnifiedLogs/components/LogsFilterBar.tsx b/apps/studio/components/interfaces/UnifiedLogs/components/LogsFilterBar.tsx
index 1c2be221958..ea94f258867 100644
--- a/apps/studio/components/interfaces/UnifiedLogs/components/LogsFilterBar.tsx
+++ b/apps/studio/components/interfaces/UnifiedLogs/components/LogsFilterBar.tsx
@@ -5,44 +5,38 @@ import { useEffect, useEffectEvent, useRef, useState } from 'react'
import {
FilterBar,
FilterCondition,
+ type CustomOptionProps,
type FilterBarHandle,
type FilterGroup,
} from 'ui-patterns/FilterBar'
-import { isLogsFilterColumnValue } from '../UnifiedLogs.filters'
import {
buildColumnFilterValues,
+ buildFilterGroup,
buildFilterProperties,
getUserFilterValue,
+ parseTimeRange,
+ serializeTimeRange,
+ TIME_RANGE_PROPERTY,
USER_PROPERTY,
} from './LogsFilterBar.utils'
import { searchAuthUsers } from '@/components/interfaces/UserJourneys/UserJourneys.queries'
+import { DataTableFilterTimerange } from '@/components/ui/DataTable/DataTableFilters/DataTableFilterTimerange'
import { useDataTable } from '@/components/ui/DataTable/providers/DataTableProvider'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { UUID_REGEX } from '@/lib/constants'
import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
import { useShortcut } from '@/state/shortcuts/useShortcut'
-const buildFilterGroup = (
- columnFilters: { id: string; value: unknown }[],
- filterableNames: Set<string>
-): FilterGroup => {
- const conditions: FilterCondition[] = []
- for (const { id, value } of columnFilters) {
- // Non-timerange column filter values are always the wrapped `{ operator, values }`
- // shape; skip anything else (e.g. the `date` timerange brush, which isn't in
- // filterableNames, or an unexpected shape).
- if (!filterableNames.has(id) || !isLogsFilterColumnValue(value)) continue
- for (const v of value.values) {
- conditions.push({
- propertyName: id,
- value: v as FilterCondition['value'],
- operator: value.operator,
- })
- }
- }
- return { logicalOperator: 'AND', conditions }
-}
+const TimeRangeOption = ({ onChange }: CustomOptionProps) => (
+ <DataTableFilterTimerange
+ label="Time range"
+ value={TIME_RANGE_PROPERTY}
+ type="timerange"
+ variant="inline"
+ onChange={(range) => onChange(serializeTimeRange(range))}
+ />
+)
export const LogsFilterBar = () => {
const { ref: projectRef } = useParams()
@@ -74,6 +68,7 @@ export const LogsFilterBar = () => {
const filterProperties = buildFilterProperties({
fields: filterFields,
userOptions: searchUserOptions,
+ timeRangeOptions: { component: TimeRangeOption },
})
const withUserCondition = (group: FilterGroup): FilterGroup => {
@@ -96,6 +91,14 @@ export const LogsFilterBar = () => {
withUserCondition(buildFilterGroup(columnFilters, columnBackedNames))
)
+ const hasTimeRangeFilter = filters.conditions.some(
+ (condition) => 'propertyName' in condition && condition.propertyName === TIME_RANGE_PROPERTY
+ )
+ const filterPropertiesWithAvailability = filterProperties.map((property) => ({
+ ...property,
+ isAvailable: property.name !== TIME_RANGE_PROPERTY || !hasTimeRangeFilter,
+ }))
+
// Read latest values without making the effect depend on their (per-render) identity.
const syncFromColumnFilters = useEffectEvent(() => {
setFilters(withUserCondition(buildFilterGroup(columnFilters, columnBackedNames)))
@@ -116,6 +119,13 @@ export const LogsFilterBar = () => {
)
if (!isValid) return
+ const timeRangeCondition = (next.conditions as FilterCondition[]).find(
+ (condition) => condition.propertyName === TIME_RANGE_PROPERTY
+ )
+ const timeRange = parseTimeRange(timeRangeCondition?.value)
+ if (timeRangeCondition && !timeRange) return
+
+ table.getColumn(TIME_RANGE_PROPERTY)?.setFilterValue(timeRange)
applyUser(getUserFilterValue(next.conditions as FilterCondition[]))
const columnFilterValues = buildColumnFilterValues(next.conditions as FilterCondition[])
@@ -123,9 +133,9 @@ export const LogsFilterBar = () => {
table.getColumn(name)?.setFilterValue(value)
}
- // Only clear filters owned by this bar — leaves externally-set filters
- // (e.g. the timeline date range) untouched.
+ // Only clear filters owned by this bar.
const nextNames = new Set(columnFilterValues.keys())
+ if (timeRange) nextNames.add(TIME_RANGE_PROPERTY)
const filtersToRemove = table
.getState()
.columnFilters.filter((x) => columnBackedNames.has(x.id) && !nextNames.has(x.id))
@@ -144,7 +154,7 @@ export const LogsFilterBar = () => {
variant="pill"
freeformDefaultProperty="event_message"
className="bg-transparent border-0 [&>div>div>div>input]:!text-xs"
- filterProperties={filterProperties}
+ filterProperties={filterPropertiesWithAvailability}
freeformText={freeformText}
filters={filters}
onFilterChange={setFilters}
diff --git a/apps/studio/components/interfaces/UnifiedLogs/components/LogsFilterBar.utils.test.ts b/apps/studio/components/interfaces/UnifiedLogs/components/LogsFilterBar.utils.test.ts
index 177bb2953e3..84e6d96b040 100644
--- a/apps/studio/components/interfaces/UnifiedLogs/components/LogsFilterBar.utils.test.ts
+++ b/apps/studio/components/interfaces/UnifiedLogs/components/LogsFilterBar.utils.test.ts
@@ -1,11 +1,16 @@
-import { describe, expect, it } from 'vitest'
+import { afterEach, describe, expect, it, vi } from 'vitest'
import { z } from 'zod'
import {
buildColumnFilterValues,
+ buildFilterGroup,
buildFilterProperties,
filterPropertySchema,
+ formatTimeRangeValue,
getUserFilterValue,
+ parseTimeRange,
+ serializeTimeRange,
+ TIME_RANGE_PROPERTY,
USER_PROPERTY,
type FilterableField,
} from './LogsFilterBar.utils'
@@ -28,10 +33,9 @@ describe('buildFilterProperties', () => {
expect(() => filterPropertySchema.array().parse(result)).not.toThrow()
})
- it('drops timerange fields and appends the synthetic user property last', () => {
+ it('includes the time range and appends the synthetic user property last', () => {
const names = buildFilterProperties({ fields }).map((property) => property.name)
- expect(names).not.toContain('date')
- expect(names).toEqual(['log_type', 'event_message', 'pathname', USER_PROPERTY])
+ expect(names).toEqual(['date', 'log_type', 'event_message', 'pathname', USER_PROPERTY])
})
it('gives the event_message column pattern (ILIKE) operators', () => {
@@ -180,3 +184,103 @@ describe('buildColumnFilterValues', () => {
expect(result.has(USER_PROPERTY)).toBe(false)
})
})
+
+describe('time range filters', () => {
+ const range = [new Date('2026-09-22T02:00:00.123Z'), new Date('2026-09-22T03:00:00.456Z')]
+
+ it('uses the custom picker with only the equals operator', () => {
+ const options = {
+ component: () => {
+ throw new Error('Not rendered in this test')
+ },
+ }
+ const properties = buildFilterProperties({
+ fields: [{ label: 'Time Range', value: TIME_RANGE_PROPERTY, type: 'timerange' }],
+ timeRangeOptions: options,
+ })
+ expect(properties[0]).toMatchObject({
+ label: 'Time range',
+ type: 'date',
+ options,
+ operators: [{ label: 'Equals', value: '=', group: 'comparison' }],
+ })
+ expect(() => filterPropertySchema.array().parse(properties)).not.toThrow()
+ })
+
+ it('round-trips precise dates from the sidebar or timeline through the bar', () => {
+ const group = buildFilterGroup(
+ [{ id: TIME_RANGE_PROPERTY, value: range }],
+ new Set([TIME_RANGE_PROPERTY])
+ )
+ expect(group.conditions).toEqual([
+ { propertyName: TIME_RANGE_PROPERTY, value: serializeTimeRange(range), operator: '=' },
+ ])
+ expect(parseTimeRange(serializeTimeRange(range))).toEqual(range)
+ })
+
+ it.each([
+ undefined,
+ null,
+ '',
+ 'invalid',
+ '2026-09-22T02:00:00Z',
+ 'invalid – 2026-09-22T03:00:00Z',
+ '2026-09-22T03:00:00Z – 2026-09-22T02:00:00Z',
+ '2026-09-22T02:00:00Z – 2026-09-22T03:00:00Z – 2026-09-22T04:00:00Z',
+ ])('rejects an invalid or incomplete range: %s', (value) => {
+ expect(parseTimeRange(value)).toBeUndefined()
+ })
+
+ it('does not wrap dates as ordinary log attribute filters', () => {
+ const values = buildColumnFilterValues([
+ { propertyName: TIME_RANGE_PROPERTY, value: serializeTimeRange(range), operator: '=' },
+ { propertyName: 'log_type', value: 'postgres', operator: '=' },
+ ])
+ expect([...values]).toEqual([['log_type', { operator: '=', values: ['postgres'] }]])
+ })
+
+ it('syncs removal while preserving other filters and skipping invalid dates', () => {
+ const group = buildFilterGroup(
+ [
+ { id: 'date', value: [new Date('invalid'), range[1]] },
+ { id: 'log_type', value: { operator: '<>', values: ['postgres', 'auth'] } },
+ { id: 'external', value: { operator: '=', values: ['value'] } },
+ ],
+ new Set(['date', 'log_type'])
+ )
+ expect(group.conditions).toEqual([
+ { propertyName: 'log_type', value: 'postgres', operator: '<>' },
+ { propertyName: 'log_type', value: 'auth', operator: '<>' },
+ ])
+ expect(buildFilterGroup([], new Set(['date'])).conditions).toEqual([])
+ })
+})
+
+describe('time range labels', () => {
+ afterEach(() => vi.useRealTimers())
+
+ it('matches the sidebar preset label within its one-minute tolerance', () => {
+ vi.useFakeTimers()
+ vi.setSystemTime(new Date('2026-09-22T03:00:30Z'))
+ expect(
+ formatTimeRangeValue(
+ serializeTimeRange([new Date('2026-09-22T02:00:00Z'), new Date('2026-09-22T03:00:00Z')])
+ )
+ ).toBe('Last 60 minutes')
+ })
+
+ it('formats custom ranges in local time just like the sidebar', () => {
+ vi.useFakeTimers()
+ vi.setSystemTime(new Date(2026, 8, 23))
+ expect(
+ formatTimeRangeValue(
+ serializeTimeRange([new Date(2026, 8, 22, 10, 5), new Date(2026, 8, 22, 11, 45)])
+ )
+ ).toBe('22 Sep, 10:05 - 22 Sep, 11:45')
+ })
+
+ it('preserves incomplete values while editing', () => {
+ expect(formatTimeRangeValue('unfinished')).toBe('unfinished')
+ expect(formatTimeRangeValue(null)).toBe('')
+ })
+})
diff --git a/apps/studio/components/interfaces/UnifiedLogs/components/LogsFilterBar.utils.ts b/apps/studio/components/interfaces/UnifiedLogs/components/LogsFilterBar.utils.ts
index 4616e4a8643..2e670062295 100644
--- a/apps/studio/components/interfaces/UnifiedLogs/components/LogsFilterBar.utils.ts
+++ b/apps/studio/components/interfaces/UnifiedLogs/components/LogsFilterBar.utils.ts
@@ -1,14 +1,26 @@
import {
type AsyncOptionsFunction,
+ type CustomOptionObject,
type FilterCondition,
+ type FilterGroup,
type FilterProperty,
} from 'ui-patterns/FilterBar'
import { z } from 'zod'
-import type { LogsColumnFilterValue, LogsFilterOperator } from '../UnifiedLogs.filters'
+import {
+ isLogsFilterColumnValue,
+ type LogsColumnFilterValue,
+ type LogsFilterOperator,
+} from '../UnifiedLogs.filters'
+import { REPORTS_DATEPICKER_HELPERS } from '@/components/interfaces/Reports/Reports.constants'
+import {
+ findMatchingDateHelper,
+ formatDateRange,
+} from '@/components/interfaces/Settings/Logs/Logs.datePickerHelpers'
import type { Option } from '@/components/ui/DataTable/DataTable.types'
export const USER_PROPERTY = 'user'
+export const TIME_RANGE_PROPERTY = 'date'
export type FilterableField = {
label: string
@@ -27,7 +39,9 @@ export const filterPropertySchema = z.object({
label: z.string(),
name: z.string(),
type: z.enum(['string', 'number', 'date', 'boolean']),
- options: z.union([z.array(z.any()), z.function()]).optional(),
+ options: z
+ .union([z.array(z.any()), z.function(), z.object({ component: z.function() })])
+ .optional(),
operators: z.array(filterOperatorSchema).optional(),
})
@@ -44,30 +58,40 @@ const PATTERN_OPERATORS: FilterProperty['operators'] = [
export const buildFilterProperties = ({
fields,
userOptions,
+ timeRangeOptions,
}: {
fields: FilterableField[]
userOptions?: AsyncOptionsFunction
+ timeRangeOptions?: CustomOptionObject
}): FilterProperty[] => {
return [
- ...fields
- .filter((field) => field.type !== 'timerange')
- .map((field): FilterProperty => {
- // event_message only supports substring matching (it's free text); pathname
- // supports both exact segment matching and substring matching.
- const operators =
- field.value === 'event_message'
- ? PATTERN_OPERATORS
- : field.value === 'pathname'
- ? [...COMPARISON_OPERATORS, ...PATTERN_OPERATORS]
- : COMPARISON_OPERATORS
+ ...fields.map((field): FilterProperty => {
+ if (field.type === 'timerange') {
return {
- label: field.label,
+ label: 'Time range',
name: field.value,
- type: 'string',
- options: field.options ?? [],
- operators,
+ type: 'date',
+ options: timeRangeOptions,
+ formatValue: formatTimeRangeValue,
+ operators: [{ label: 'Equals', value: '=', group: 'comparison' }],
}
- }),
+ }
+ // event_message only supports substring matching (it's free text); pathname
+ // supports both exact segment matching and substring matching.
+ const operators =
+ field.value === 'event_message'
+ ? PATTERN_OPERATORS
+ : field.value === 'pathname'
+ ? [...COMPARISON_OPERATORS, ...PATTERN_OPERATORS]
+ : COMPARISON_OPERATORS
+ return {
+ label: field.label,
+ name: field.value,
+ type: 'string',
+ options: field.options ?? [],
+ operators,
+ }
+ }),
{
label: 'User',
name: USER_PROPERTY,
@@ -90,7 +114,7 @@ export const buildColumnFilterValues = (
): Map<string, LogsColumnFilterValue> => {
const wrappedByColumn = new Map<string, LogsColumnFilterValue>()
for (const condition of conditions) {
- if (condition.propertyName === USER_PROPERTY) continue
+ if ([USER_PROPERTY, TIME_RANGE_PROPERTY].includes(condition.propertyName)) continue
const operator = condition.operator as LogsFilterOperator
const existing = wrappedByColumn.get(condition.propertyName)
if (!existing) {
@@ -104,3 +128,43 @@ export const buildColumnFilterValues = (
}
return wrappedByColumn
}
+
+export const serializeTimeRange = (range: Date[]): string =>
+ range.map((date) => date.toISOString()).join(' – ')
+
+export const parseTimeRange = (value: unknown): [Date, Date] | undefined => {
+ if (typeof value !== 'string') return
+ const result = z.tuple([z.coerce.date(), z.coerce.date()]).safeParse(value.split(' – '))
+ if (!result.success || result.data[0] > result.data[1]) return
+ return result.data
+}
+
+export const buildFilterGroup = (
+ columnFilters: { id: string; value: unknown }[],
+ filterableNames: Set<string>
+): FilterGroup => {
+ const conditions: FilterCondition[] = []
+ for (const { id, value } of columnFilters) {
+ if (!filterableNames.has(id)) continue
+ if (id === TIME_RANGE_PROPERTY) {
+ const range = z.tuple([z.date(), z.date()]).safeParse(value)
+ if (range.success) {
+ conditions.push({ propertyName: id, value: serializeTimeRange(range.data), operator: '=' })
+ }
+ continue
+ }
+ if (!isLogsFilterColumnValue(value)) continue
+ for (const v of value.values) {
+ conditions.push({ propertyName: id, value: String(v), operator: value.operator })
+ }
+ }
+ return { logicalOperator: 'AND', conditions }
+}
+
+export const formatTimeRangeValue = (value: FilterCondition['value']): string => {
+ const range = parseTimeRange(value)
+ if (!range) return String(value ?? '')
+ const [from, to] = range
+ const helper = findMatchingDateHelper(from, to, REPORTS_DATEPICKER_HELPERS)
+ return helper?.text ?? formatDateRange(from.toISOString(), to.toISOString())
+}
diff --git a/apps/studio/components/ui/DataTable/DataTableFilters/DataTableFilterTimerange.tsx b/apps/studio/components/ui/DataTable/DataTableFilters/DataTableFilterTimerange.tsx
index 7a1cb73ed86..431d23f80ab 100644
--- a/apps/studio/components/ui/DataTable/DataTableFilters/DataTableFilterTimerange.tsx
+++ b/apps/studio/components/ui/DataTable/DataTableFilters/DataTableFilterTimerange.tsx
@@ -5,6 +5,7 @@ import type { DataTableTimerangeFilterField } from '../DataTable.types'
import { isArrayOfDates } from '../DataTable.utils'
import { useDataTable } from '../providers/DataTableProvider'
import { REPORTS_DATEPICKER_HELPERS } from '@/components/interfaces/Reports/Reports.constants'
+import { findMatchingDateHelper } from '@/components/interfaces/Settings/Logs/Logs.datePickerHelpers'
import {
DatePickerValue,
LogsDatePicker,
@@ -15,7 +16,12 @@ import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
export function DataTableFilterTimerange<TData>({
value: _value,
-}: DataTableTimerangeFilterField<TData>) {
+ variant = 'popover',
+ onChange,
+}: DataTableTimerangeFilterField<TData> & {
+ variant?: 'popover' | 'inline'
+ onChange?: (range: [Date, Date]) => void
+}) {
const value = _value as string
const { table, columnFilters } = useDataTable()
const column = table.getColumn(value)
@@ -51,6 +57,7 @@ export function DataTableFilterTimerange<TData>({
const startDate = new Date(vals.from)
const endDate = new Date(vals.to)
column?.setFilterValue([startDate, endDate])
+ onChange?.([startDate, endDate])
}
// Get current selected DatePickerValue based on the date range
@@ -68,16 +75,7 @@ export function DataTableFilterTimerange<TData>({
}
// Try to match with a helper
- const matchingHelper = REPORTS_DATEPICKER_HELPERS.find((helper) => {
- const helperFrom = new Date(helper.calcFrom())
- const helperTo = new Date(helper.calcTo())
- const timeDiff = 60000 // 1 minute tolerance
-
- return (
- Math.abs(date.from!.getTime() - helperFrom.getTime()) < timeDiff &&
- Math.abs(date.to!.getTime() - helperTo.getTime()) < timeDiff
- )
- })
+ const matchingHelper = findMatchingDateHelper(date.from, date.to, REPORTS_DATEPICKER_HELPERS)
if (matchingHelper) {
return {
@@ -100,6 +98,7 @@ export function DataTableFilterTimerange<TData>({
return (
<>
<LogsDatePicker
+ variant={variant}
buttonTriggerProps={{
block: true,
className: 'h-8',
diff --git a/apps/studio/tests/features/logs/Logs.Datepickers.test.tsx b/apps/studio/tests/features/logs/Logs.Datepickers.test.tsx
index 639961eb08e..71ae5d750f0 100644
--- a/apps/studio/tests/features/logs/Logs.Datepickers.test.tsx
+++ b/apps/studio/tests/features/logs/Logs.Datepickers.test.tsx
@@ -1,9 +1,11 @@
-import { screen, within } from '@testing-library/react'
+import { fireEvent, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import dayjs from 'dayjs'
import timezone from 'dayjs/plugin/timezone'
import utc from 'dayjs/plugin/utc'
-import { describe, expect, test, vi } from 'vitest'
+import { HttpResponse } from 'msw'
+import { useState } from 'react'
+import { beforeEach, describe, expect, test, vi } from 'vitest'
import { render } from '../../helpers'
import { PREVIEWER_DATEPICKER_HELPERS } from '@/components/interfaces/Settings/Logs/Logs.constants'
@@ -13,12 +15,119 @@ import {
generateHelpersFromInput,
parseCustomInput,
} from '@/components/interfaces/Settings/Logs/Logs.datePickerHelpers'
-import { LogsDatePicker } from '@/components/interfaces/Settings/Logs/Logs.DatePickers'
+import {
+ LogsDatePicker,
+ type DatePickerValue,
+} from '@/components/interfaces/Settings/Logs/Logs.DatePickers'
import { DatetimeHelper } from '@/components/interfaces/Settings/Logs/Logs.types'
+import { customRender } from '@/tests/lib/custom-render'
+import { addAPIMock, type APIErrorBody } from '@/tests/lib/msw'
dayjs.extend(timezone)
dayjs.extend(utc)
+beforeEach(() => {
+ addAPIMock({
+ method: 'get',
+ path: '/platform/projects/:ref',
+ response: () =>
+ HttpResponse.json<APIErrorBody>({ message: 'Project not found' }, { status: 404 }),
+ })
+})
+
+describe('inline and popover date-picker state', () => {
+ const initialRange = {
+ from: '2026-08-01T01:02:03.000Z',
+ to: '2026-08-02T04:05:06.000Z',
+ }
+ const selectedRange = {
+ from: '2026-09-10T07:08:09.000Z',
+ to: '2026-09-11T10:11:12.000Z',
+ }
+
+ test.each(['inline', 'popover'] as const)(
+ '%s applies the newly selected helper dates and times',
+ async (variant) => {
+ const user = userEvent.setup()
+ const onSubmit = vi.fn()
+ function Picker() {
+ const [value, setValue] = useState<DatePickerValue>(initialRange)
+ return (
+ <LogsDatePicker
+ variant={variant}
+ value={value}
+ helpers={[
+ {
+ text: 'Selected range',
+ calcFrom: () => selectedRange.from,
+ calcTo: () => selectedRange.to,
+ },
+ ]}
+ onSubmit={(next) => {
+ setValue(next)
+ onSubmit(next)
+ }}
+ />
+ )
+ }
+ customRender(<Picker />)
+ if (variant === 'popover') await user.click(screen.getByRole('button'))
+ await user.click(screen.getByText('Selected range'))
+ expect(onSubmit).toHaveBeenLastCalledWith({
+ ...selectedRange,
+ isHelper: true,
+ text: 'Selected range',
+ })
+ if (variant === 'popover') {
+ await user.click(screen.getByRole('button', { name: 'Selected range' }))
+ }
+ await user.click(screen.getByRole('button', { name: 'Apply' }))
+ expect(onSubmit).toHaveBeenLastCalledWith({ ...selectedRange, isHelper: false })
+ }
+ )
+
+ test.each(['inline', 'popover'] as const)(
+ '%s only handles document clipboard events when it is a popover',
+ async (variant) => {
+ const user = userEvent.setup()
+ const onSubmit = vi.fn()
+ customRender(
+ <LogsDatePicker
+ variant={variant}
+ open
+ value={initialRange}
+ helpers={[]}
+ onSubmit={onSubmit}
+ />
+ )
+ await navigator.clipboard.writeText('Unrelated text')
+ fireEvent.copy(document)
+ if (variant === 'popover') {
+ await waitFor(async () => {
+ expect(await navigator.clipboard.readText()).toBe(JSON.stringify(initialRange))
+ })
+ } else {
+ expect(await navigator.clipboard.readText()).toBe('Unrelated text')
+ }
+
+ await navigator.clipboard.writeText(JSON.stringify(selectedRange))
+ fireEvent.paste(document)
+ if (variant === 'popover') {
+ await waitFor(() => {
+ expect(screen.getAllByLabelText('Hours')[0]).toHaveValue(
+ new Date(selectedRange.from).getHours().toString()
+ )
+ })
+ }
+ await user.click(screen.getByRole('button', { name: 'Apply' }))
+ expect(onSubmit).toHaveBeenLastCalledWith({
+ ...(variant === 'popover' ? selectedRange : initialRange),
+ isHelper: false,
+ })
+ }
+ )
+})
+
describe('parseCustomInput', () => {
test('returns invalid for empty input', () => {
expect(parseCustomInput('')).toEqual({ type: 'invalid' })
diff --git a/packages/ui-patterns/src/FilterBar/FilterBar.test.tsx b/packages/ui-patterns/src/FilterBar/FilterBar.test.tsx
index 54aecbaf391..cc19cc4fa04 100644
--- a/packages/ui-patterns/src/FilterBar/FilterBar.test.tsx
+++ b/packages/ui-patterns/src/FilterBar/FilterBar.test.tsx
@@ -37,6 +37,111 @@ describe('FilterBar', () => {
const mockOnFilterChange = vi.fn()
const mockOnFreeformTextChange = vi.fn()
+ it('formats a value for display without changing its stored or editable value', async () => {
+ const user = userEvent.setup()
+ const onApply = vi.fn()
+ const onFilterChange = vi.fn()
+ render(
+ <FilterBar
+ filterProperties={[
+ {
+ label: 'Time range',
+ name: 'date',
+ type: 'date',
+ operators: ['='],
+ formatValue: () => 'Last 60 minutes',
+ },
+ ]}
+ filters={{
+ logicalOperator: 'AND',
+ conditions: [{ propertyName: 'date', operator: '=', value: 'precise-range' }],
+ }}
+ onFilterChange={onFilterChange}
+ onApply={onApply}
+ freeformText=""
+ onFreeformTextChange={vi.fn()}
+ />
+ )
+ const valueInput = screen.getByLabelText('Value for Time range')
+ expect(valueInput).toHaveValue('Last 60 minutes')
+ await user.click(valueInput)
+ expect(valueInput).toHaveValue('precise-range')
+ await user.click(document.body)
+ await waitFor(() => expect(valueInput).toHaveValue('Last 60 minutes'))
+ expect(onFilterChange).not.toHaveBeenCalled()
+ expect(onApply).toHaveBeenLastCalledWith({
+ logicalOperator: 'AND',
+ conditions: [{ propertyName: 'date', operator: '=', value: 'precise-range' }],
+ })
+ })
+
+ it('keeps a custom picker value formatted while active and stores the selected raw value', async () => {
+ const user = userEvent.setup()
+ const onFilterChange = vi.fn()
+ const properties: FilterProperty[] = [
+ {
+ label: 'Time range',
+ name: 'date',
+ type: 'date',
+ operators: ['='],
+ formatValue: (value) => (value === 'range-30m' ? 'Last 30 minutes' : 'Last 60 minutes'),
+ options: {
+ component: ({ onChange, search }) => (
+ <button onClick={() => onChange('range-30m')} data-current-range={search}>
+ Last 30 minutes
+ </button>
+ ),
+ },
+ },
+ ]
+ function PickerFilterBar() {
+ const [filters, setFilters] = useState<FilterGroup>({
+ logicalOperator: 'AND',
+ conditions: [{ propertyName: 'date', operator: '=', value: 'range-60m' }],
+ })
+ return (
+ <FilterBar
+ filterProperties={properties.map((property) => ({
+ ...property,
+ isAvailable: filters.conditions.length === 0,
+ }))}
+ filters={filters}
+ onFilterChange={(next) => {
+ setFilters(next)
+ onFilterChange(next)
+ }}
+ freeformText=""
+ onFreeformTextChange={vi.fn()}
+ />
+ )
+ }
+ render(<PickerFilterBar />)
+ const valueInput = screen.getByLabelText('Value for Time range')
+ expect(valueInput).toHaveValue('Last 60 minutes')
+ await user.click(valueInput)
+ const preset = await screen.findByRole('button', { name: 'Last 30 minutes' })
+ expect(valueInput).toHaveValue('Last 60 minutes')
+ expect(valueInput).toHaveAttribute('readonly')
+ expect(preset).toHaveAttribute('data-current-range', 'range-60m')
+ await user.keyboard('x')
+ expect(valueInput).toHaveValue('Last 60 minutes')
+ expect(onFilterChange).not.toHaveBeenCalled()
+ await user.click(preset)
+ await waitFor(() => expect(valueInput).toHaveValue('Last 30 minutes'))
+ expect(onFilterChange).toHaveBeenLastCalledWith({
+ logicalOperator: 'AND',
+ conditions: [{ propertyName: 'date', operator: '=', value: 'range-30m' }],
+ })
+ const freeform = screen.getByTestId('filter-bar-freeform-input')
+ await user.click(freeform)
+ expect(screen.queryByRole('option', { name: 'Time range' })).not.toBeInTheDocument()
+ await user.click(screen.getByRole('button', { name: 'Remove Time range filter' }))
+ await user.click(freeform)
+ await user.click(await screen.findByRole('option', { name: 'Time range' }))
+ await user.click(await screen.findByRole('button', { name: 'Last 30 minutes' }))
+ expect(screen.getAllByLabelText('Value for Time range')).toHaveLength(1)
+ })
+
it('renders with empty state', () => {
render(
<FilterBar
diff --git a/packages/ui-patterns/src/FilterBar/FilterCondition.tsx b/packages/ui-patterns/src/FilterBar/FilterCondition.tsx
index f84e68fa284..9bf3aed1ad2 100644
--- a/packages/ui-patterns/src/FilterBar/FilterCondition.tsx
+++ b/packages/ui-patterns/src/FilterBar/FilterCondition.tsx
@@ -9,6 +9,7 @@ import { useFilterBar } from './FilterBarContext'
import { useDeferredBlur, useHighlightNavigation } from './hooks'
import { buildOperatorItems, buildPropertyChangeItems, buildValueItems } from './menuItems'
import { FilterCondition as FilterConditionType } from './types'
+import { isCustomOptionObject } from './utils'
export type FilterConditionProps = {
condition: FilterConditionType
@@ -59,6 +60,11 @@ export function FilterCondition({
const conditionOperator = condition.operator ?? ''
const conditionValue = (condition.value ?? '').toString()
+ const hasFormattedCustomValue = !!property?.formatValue && isCustomOptionObject(property.options)
+ const displayedValue =
+ (!isActive || hasFormattedCustomValue) && property?.formatValue
+ ? property.formatValue(condition.value)
+ : localValue
// Reset "has typed" state when focus changes
useEffect(() => {
@@ -374,7 +380,8 @@ export function FilterCondition({
<Input
ref={valueRef}
type="text"
- value={localValue}
+ value={displayedValue}
+ readOnly={hasFormattedCustomValue}
onChange={onValueChange}
onFocus={() => handleInputFocus(path)}
onBlur={handleValueBlur}
@@ -388,7 +395,9 @@ export function FilterCondition({
data-lpignore="true"
data-form-type="other"
/>
- <span className="invisible whitespace-pre text-xs block px-1">{localValue || ' '}</span>
+ <span className="invisible whitespace-pre text-xs block px-1">
+ {displayedValue || ' '}
+ </span>
</div>
</PopoverAnchor>
<PopoverContent
diff --git a/packages/ui-patterns/src/FilterBar/menuItems.test.ts b/packages/ui-patterns/src/FilterBar/menuItems.test.ts
index ba5358c7052..19324dd699e 100644
--- a/packages/ui-patterns/src/FilterBar/menuItems.test.ts
+++ b/packages/ui-patterns/src/FilterBar/menuItems.test.ts
@@ -1,6 +1,11 @@
import { describe, expect, it } from 'vitest'
-import { buildOperatorItems, buildPropertyItems, buildValueItems } from './menuItems'
+import {
+ buildOperatorItems,
+ buildPropertyChangeItems,
+ buildPropertyItems,
+ buildValueItems,
+} from './menuItems'
import { FilterGroup, FilterProperty } from './types'
const stringProperty: FilterProperty = {
@@ -48,6 +53,32 @@ const pathProperty: FilterProperty = {
const filterProperties: FilterProperty[] = [stringProperty, booleanProperty, pathProperty]
+describe('consumer-controlled property availability', () => {
+ it.each([true, false, undefined])(
+ 'respects isAvailable=%s in add and change menus',
+ (isAvailable) => {
+ const timeRange: FilterProperty = {
+ label: 'Time range',
+ name: 'date',
+ type: 'date',
+ isAvailable,
+ }
+ const params = { filterProperties: [...filterProperties, timeRange], inputValue: '' }
+ const addItems = buildPropertyItems(params)
+ const changeItems = buildPropertyChangeItems({ ...params, currentPropertyName: 'name' })
+ expect(addItems.some((item) => item.value === 'date')).toBe(isAvailable !== false)
+ expect(changeItems.some((item) => item.value === 'date')).toBe(isAvailable !== false)
+ expect(addItems.some((item) => item.value === 'name')).toBe(true)
+ const searchItems = buildPropertyItems({
+ ...params,
+ inputValue: 'range',
+ freeformDefaultProperty: timeRange,
+ })
+ expect(searchItems.some((item) => item.isFreeformSearch)).toBe(isAvailable !== false)
+ }
+ )
+})
+
describe('buildOperatorItems', () => {
it('returns matching operators for operator draft text', () => {
const filters: FilterGroup = {
diff --git a/packages/ui-patterns/src/FilterBar/menuItems.ts b/packages/ui-patterns/src/FilterBar/menuItems.ts
index 3031b95e00a..bf51e899d6b 100644
--- a/packages/ui-patterns/src/FilterBar/menuItems.ts
+++ b/packages/ui-patterns/src/FilterBar/menuItems.ts
@@ -76,10 +76,15 @@ export function buildPropertyItems(params: {
}): MenuItem[] {
const { filterProperties, inputValue, supportsOperators, actions, freeformDefaultProperty } =
params
+ const availableProperties = filterProperties.filter((property) => property.isAvailable !== false)
const items: MenuItem[] = []
const trimmedInput = inputValue.trim()
- if (freeformDefaultProperty && trimmedInput.length > 0) {
+ if (
+ freeformDefaultProperty &&
+ freeformDefaultProperty.isAvailable !== false &&
+ trimmedInput.length > 0
+ ) {
items.push({
value: '__freeform_search__',
label: `Search ${freeformDefaultProperty.label.toLowerCase()}: "${trimmedInput}"`,
@@ -90,7 +95,7 @@ export function buildPropertyItems(params: {
}
items.push(
- ...filterProperties
+ ...availableProperties
.filter((prop) => prop.label.toLowerCase().includes(inputValue.toLowerCase()))
.map((prop) => ({ value: prop.name, label: prop.label }))
)
@@ -123,6 +128,7 @@ export function buildPropertyChangeItems(params: {
const { filterProperties, currentPropertyName, inputValue } = params
return filterProperties
+ .filter((property) => property.isAvailable !== false)
.filter((prop) => prop.name !== currentPropertyName)
.filter((prop) => prop.label.toLowerCase().includes(inputValue.toLowerCase()))
.map((prop) => ({ value: prop.name, label: prop.label }))
diff --git a/packages/ui-patterns/src/FilterBar/types.ts b/packages/ui-patterns/src/FilterBar/types.ts
index af18893e0eb..3a842f9359c 100644
--- a/packages/ui-patterns/src/FilterBar/types.ts
+++ b/packages/ui-patterns/src/FilterBar/types.ts
@@ -58,6 +58,10 @@ export type FilterProperty = {
type: 'string' | 'number' | 'date' | 'boolean'
options?: FilterOption[] | AsyncOptionsFunction | SyncOptionsFunction | CustomOptionObject
operators?: FilterOperator[]
+ /** Whether this property can be added or selected when changing a filter. Defaults to true. */
+ isAvailable?: boolean
+ /** Display a readable label while preserving the underlying value for editing. */
+ formatValue?: (value: FilterCondition['value']) => string
}
export type FilterCondition = {