mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## What kind of change does this PR introduce? Refactor. Follow-up to #49871. ## What is the current behavior? Branded (green) text still uses the `text-brand` classname while the colour comes from `--primary`. ## What is the new behavior? **Rename-only:** `text-brand` → `text-primary` across callsites and docs. Leftover `bg-brand` / `border-brand` alias to `brand-default`. No intentional colour changes in this PR. This better matches how we treat our green in other components and props, like `variant="primary"` for green buttons. ## To test On light mode: smoke-test that branded text still looks like #49871 (readable green, not the bright fill). - [Homepage](https://zone-www-dot-com-git-dnywh-depr-316-text-brand-de2380-supabase.vercel.app/): “Scale to millions” uses `text-primary` - [Docs homepage](https://docs-git-dnywh-depr-316-text-brand-to-primary-supabase.vercel.app/docs): branded links like “More on self-hosting” are still readable - [Typography docs](https://design-system-git-dnywh-depr-316-text-brand-to-primary-supabase.vercel.app/design-system/docs/typography): documents `text-primary` - [Colour usage](https://design-system-git-dnywh-depr-316-text-brand-to-primary-supabase.vercel.app/design-system/docs/color-usage): `text-primary` is visibly darker than `bg-brand-default` _on light mode_ - [Studio auth providers](https://studio-staging-git-dnywh-depr-316-text-brand-to-60fa6c-supabase.vercel.app/dashboard/project/_/auth/providers): enabled provider badge text readable; status dot stays bright green <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Style** * Updated branded text, link hover states, icons, badges, indicators, and highlighted content across the Design System, Docs, Studio, Learn, UI Library, and marketing experiences to use the primary theme color. * Updated syntax highlighting and table-of-contents styling for consistent primary-color presentation. * Refined brand color fallback behavior for bright fills and borders. * **Documentation** * Updated color-usage and typography guidance to recommend the primary text utility. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
158 lines
4.9 KiB
TypeScript
158 lines
4.9 KiB
TypeScript
'use client'
|
|
|
|
import { useState } from 'react'
|
|
import { Button, cn, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from 'ui'
|
|
import { FilterBar, isGroup, type FilterCondition, type FilterGroup } from 'ui-patterns/FilterBar'
|
|
|
|
const logs = [
|
|
['10:42:01.129', 'POST /hello-world', '200', '132ms', 'iad1'],
|
|
['10:41:47.854', 'POST /hello-world', '200', '118ms', 'syd1'],
|
|
['10:40:22.381', 'OPTIONS /hello-world', '204', '24ms', 'fra1'],
|
|
['10:39:58.025', 'POST /hello-world', '500', '96ms', 'iad1'],
|
|
] as const
|
|
|
|
const logFilterProperties = [
|
|
{
|
|
label: 'Request',
|
|
name: 'request',
|
|
type: 'string' as const,
|
|
operators: ['=', '!=', 'CONTAINS'],
|
|
},
|
|
{
|
|
label: 'Status',
|
|
name: 'status',
|
|
type: 'string' as const,
|
|
options: ['200', '204', '500'],
|
|
operators: ['=', '!='],
|
|
},
|
|
{
|
|
label: 'Region',
|
|
name: 'region',
|
|
type: 'string' as const,
|
|
options: ['iad1', 'syd1', 'fra1'],
|
|
operators: ['=', '!='],
|
|
},
|
|
]
|
|
|
|
const initialLogFilters: FilterGroup = {
|
|
logicalOperator: 'AND',
|
|
conditions: [],
|
|
}
|
|
|
|
type LogRow = (typeof logs)[number]
|
|
|
|
function getLogValue(log: LogRow, propertyName: string) {
|
|
const [, request, status, , region] = log
|
|
|
|
switch (propertyName) {
|
|
case 'request':
|
|
return request
|
|
case 'status':
|
|
return status
|
|
case 'region':
|
|
return region
|
|
default:
|
|
return undefined
|
|
}
|
|
}
|
|
|
|
function matchesLogCondition(log: LogRow, condition: FilterCondition) {
|
|
const actualValue = getLogValue(log, condition.propertyName)
|
|
|
|
if (actualValue === undefined || condition.value === '' || condition.value === null) {
|
|
return true
|
|
}
|
|
|
|
const actual = String(actualValue).toLowerCase()
|
|
const expected = String(condition.value).toLowerCase()
|
|
|
|
switch (condition.operator) {
|
|
case '=':
|
|
return actual === expected
|
|
case '!=':
|
|
return actual !== expected
|
|
case 'CONTAINS':
|
|
return actual.includes(expected)
|
|
default:
|
|
return true
|
|
}
|
|
}
|
|
|
|
function matchesLogFilters(log: LogRow, filterGroup: FilterGroup): boolean {
|
|
if (filterGroup.conditions.length === 0) {
|
|
return true
|
|
}
|
|
|
|
const conditionMatches = filterGroup.conditions.map((condition) =>
|
|
isGroup(condition) ? matchesLogFilters(log, condition) : matchesLogCondition(log, condition)
|
|
)
|
|
|
|
return filterGroup.logicalOperator === 'AND'
|
|
? conditionMatches.every(Boolean)
|
|
: conditionMatches.some(Boolean)
|
|
}
|
|
|
|
export function PageLayoutLogsContent() {
|
|
const [filters, setFilters] = useState<FilterGroup>(initialLogFilters)
|
|
const [freeformText, setFreeformText] = useState('')
|
|
const normalizedFreeformText = freeformText.trim().toLowerCase()
|
|
const filteredLogs = logs.filter(
|
|
(log) =>
|
|
matchesLogFilters(log, filters) &&
|
|
(normalizedFreeformText === '' ||
|
|
log.some((value) => value.toLowerCase().includes(normalizedFreeformText)))
|
|
)
|
|
|
|
return (
|
|
<div className="overflow-hidden bg-surface-75">
|
|
<div className="flex h-12 items-center justify-between border-b bg-surface-100 pl-0 pr-4 xl:pl-0 xl:pr-4">
|
|
<div className="min-w-0 flex-1 pr-4">
|
|
<FilterBar
|
|
filterProperties={logFilterProperties}
|
|
freeformText={freeformText}
|
|
onFreeformTextChange={setFreeformText}
|
|
filters={filters}
|
|
onFilterChange={setFilters}
|
|
variant="pill"
|
|
className="border-0 bg-transparent px-1.5 overflow-visible [&>div>div>div>input]:!text-xs"
|
|
/>
|
|
</div>
|
|
<div className="flex shrink-0 items-center gap-2">
|
|
<Button size="tiny">Live</Button>
|
|
<Button size="tiny">Refresh</Button>
|
|
</div>
|
|
</div>
|
|
|
|
<Table containerProps={{ className: 'w-full' }}>
|
|
<TableHeader className="[&>tr]:bg-surface-100">
|
|
<TableRow>
|
|
<TableHead className="w-[120px]">Time</TableHead>
|
|
<TableHead>Request</TableHead>
|
|
<TableHead className="w-[80px]">Status</TableHead>
|
|
<TableHead className="w-[100px]">Duration</TableHead>
|
|
<TableHead className="w-[80px]">Region</TableHead>
|
|
</TableRow>
|
|
</TableHeader>
|
|
<TableBody>
|
|
{filteredLogs.map(([time, request, status, duration, region]) => (
|
|
<TableRow key={`${time}-${region}`}>
|
|
<TableCell className="font-mono text-xs text-foreground-lighter">{time}</TableCell>
|
|
<TableCell className="font-mono text-xs">{request}</TableCell>
|
|
<TableCell
|
|
className={cn(
|
|
'font-mono text-xs',
|
|
status === '500' ? 'text-destructive' : 'text-primary'
|
|
)}
|
|
>
|
|
{status}
|
|
</TableCell>
|
|
<TableCell className="font-mono text-xs">{duration}</TableCell>
|
|
<TableCell className="font-mono text-xs text-foreground-lighter">{region}</TableCell>
|
|
</TableRow>
|
|
))}
|
|
</TableBody>
|
|
</Table>
|
|
</div>
|
|
)
|
|
}
|