Skip to content

Commit

Permalink
feat: add type column to WebLogView (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoventura authored Dec 12, 2024
1 parent 564aab9 commit b7a793a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/WebLogView/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { MethodBadge } from '../MethodBadge'
import { ResponseStatusBadge } from '../ResponseStatusBadge'
import { TableCellWithTooltip } from '../TableCellWithTooltip'
import { HighlightedText } from '../HighlightedText'
import { getRequestType } from './WebLogView.utils'

interface RowProps {
data: ProxyDataWithMatches
Expand Down Expand Up @@ -53,6 +54,7 @@ export function Row({ data, isSelected, onSelectRequest }: RowProps) {
/>
</ResponseStatusBadge>
</Table.Cell>
<TableCellWithTooltip>{getRequestType(data)}</TableCellWithTooltip>
<TableCellWithTooltip>
<HighlightedText text={data.request.host} matches={data.matches} />
</TableCellWithTooltip>
Expand Down
1 change: 1 addition & 0 deletions src/components/WebLogView/WebLogView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function RequestList({
<Table.Row>
<Table.ColumnHeaderCell width="70px">Method</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell width="60px">Status</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell width="80px">Type</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell width="20%">Host</Table.ColumnHeaderCell>
<Table.ColumnHeaderCell width="80%">Path</Table.ColumnHeaderCell>
</Table.Row>
Expand Down
11 changes: 11 additions & 0 deletions src/components/WebLogView/WebLogView.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { GroupedProxyData, ProxyData } from '@/types'
import { getContentType } from '@/utils/headers'
import { isNonStaticAssetResponse } from '@/utils/staticAssets'

export function removeQueryStringFromUrl(url: string) {
return url.split('?')[0]
Expand All @@ -20,3 +22,12 @@ export function isGroupedProxyData(
): data is GroupedProxyData {
return !Array.isArray(data)
}

export function getRequestType(data: ProxyData) {
if (isNonStaticAssetResponse(data)) {
return 'fetch'
}

const mimeType = getContentType(data.response?.headers ?? [])
return mimeType ? mimeType.split('/')[1] : 'unknown'
}

0 comments on commit b7a793a

Please sign in to comment.