FunctionsEdgeColumnRender.tsx32 lines · main
1import { Column } from 'react-data-grid'
2import { TimestampInfo } from 'ui-patterns/TimestampInfo'
3
4import type { LogData } from '../Logs.types'
5import { extractEdgeFunctionName } from '../Logs.utils'
6import { ResponseCodeFormatter, RowLayout, TextFormatter } from '../LogsFormatters'
7import { defaultRenderCell } from './DefaultPreviewColumnRenderer'
8
9const columns: Column<LogData>[] = [
10 {
11 name: 'functions-edge-first-column',
12 key: 'functions-edge-first-column',
13 renderHeaderCell: () => null,
14 renderCell: (props) => {
15 if (!props.row.status_code && !props.row.method) {
16 return defaultRenderCell(props)
17 }
18 const functionName = extractEdgeFunctionName(props.row.pathname)
19 return (
20 <RowLayout>
21 <TimestampInfo utcTimestamp={props.row.timestamp!} />
22 <ResponseCodeFormatter value={String(props.row.status_code)} />
23 <TextFormatter value={String(props.row.method)} />
24 {functionName && <TextFormatter value={functionName} />}
25 <TextFormatter value={String(props.row.id)} />
26 </RowLayout>
27 )
28 },
29 },
30]
31
32export default columns