mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Context Replaces the individual filters on the Account audit logs page with the filter bar to match a consistent UX across log surfaces <img width="1206" height="360" alt="image" src="https://github.com/user-attachments/assets/c5bdfd7e-3277-4695-b9fc-1791df8720c7" /> Also uses the `supportOperators` param for the `FilterBar` to support "OR" based operations when filtering for projects <img width="1219" height="97" alt="image" src="https://github.com/user-attachments/assets/d4748e6c-d1f3-4f23-b767-e0f4bb1c0a1c" /> The main changes for the `FilterBar` component made in this PR (which would be more relevant for the design team) are: - Added a divider between the options and "New group" - Originally didn't have a divider - So there's a clearer distinction that the "New group" isn't a option to set as the value for - Add a new `defaultGroupOperator` prop - Originally defaults to `AND` - However, in the context of Audit Logs when filtering for projects, you'd expect `OR` to be the default to filter across several projects (`AND` wouldn't make sense here)
17 lines
598 B
TypeScript
17 lines
598 B
TypeScript
import { z } from 'zod'
|
||
|
||
// Date ranges travel through filter bars as a single `from – to` string value.
|
||
const TIME_RANGE_SEPARATOR = ' – '
|
||
|
||
export const serializeTimeRange = (range: Date[]): string =>
|
||
range.map((date) => date.toISOString()).join(TIME_RANGE_SEPARATOR)
|
||
|
||
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(TIME_RANGE_SEPARATOR))
|
||
if (!result.success || result.data[0] > result.data[1]) return
|
||
return result.data
|
||
}
|