Skip to content

Commit

Permalink
rename interface
Browse files Browse the repository at this point in the history
  • Loading branch information
warrenday committed Sep 23, 2024
1 parent c80baa9 commit 7457217
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 123 deletions.
50 changes: 25 additions & 25 deletions src/containers/NetworkPanel/NetworkDetails/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { useMemo } from "react"
import { Tabs } from "@/components/Tabs"
import { INetworkRequest } from "@/helpers/networkHelpers"
import { HeaderView } from "../HeaderView"
import { RequestView, RequestViewFooter } from "./RequestView"
import { ResponseView } from "./ResponseView"
import { TracingView } from "./TracingView"
import { ResponseRawView } from "./ResponseRawView"
import { useNetworkTabs } from "@/hooks/useNetworkTabs"
import { CloseButton } from "@/components/CloseButton"
import { useApolloTracing } from "@/hooks/useApolloTracing"
import { useToggle } from "@/hooks/useToggle"
import { useShareMessage } from "../../../hooks/useShareMessage"
import { useMemo } from 'react'
import { Tabs } from '@/components/Tabs'
import { ICompleteNetworkRequest } from '@/helpers/networkHelpers'
import { HeaderView } from '../HeaderView'
import { RequestView, RequestViewFooter } from './RequestView'
import { ResponseView } from './ResponseView'
import { TracingView } from './TracingView'
import { ResponseRawView } from './ResponseRawView'
import { useNetworkTabs } from '@/hooks/useNetworkTabs'
import { CloseButton } from '@/components/CloseButton'
import { useApolloTracing } from '@/hooks/useApolloTracing'
import { useToggle } from '@/hooks/useToggle'
import { useShareMessage } from '../../../hooks/useShareMessage'

export interface INetworkDetailsProps {
data: INetworkRequest
data: ICompleteNetworkRequest
onClose: () => void
}

Expand All @@ -30,7 +30,7 @@ export const NetworkDetails = (props: INetworkDetailsProps) => {
const { shareNetworkRequest } = useShareMessage()
const operation = data.request.primaryOperation.operation
const isShareable = useMemo(
() => ["query", "mutation"].includes(operation),
() => ['query', 'mutation'].includes(operation),
[operation]
)

Expand All @@ -50,8 +50,8 @@ export const NetworkDetails = (props: INetworkDetailsProps) => {
}
tabs={[
{
id: "headers",
title: "Headers",
id: 'headers',
title: 'Headers',
component: (
<HeaderView
requestHeaders={requestHeaders}
Expand All @@ -60,8 +60,8 @@ export const NetworkDetails = (props: INetworkDetailsProps) => {
),
},
{
id: "request",
title: "Request",
id: 'request',
title: 'Request',
component: (
<RequestView
onShare={isShareable ? handleShare : undefined}
Expand All @@ -77,8 +77,8 @@ export const NetworkDetails = (props: INetworkDetailsProps) => {
),
},
{
id: "response",
title: "Response",
id: 'response',
title: 'Response',
component: (
<ResponseView
onShare={isShareable ? handleShare : undefined}
Expand All @@ -88,8 +88,8 @@ export const NetworkDetails = (props: INetworkDetailsProps) => {
),
},
{
id: "response-raw",
title: "Response (Raw)",
id: 'response-raw',
title: 'Response (Raw)',
component: (
<ResponseRawView
onShare={isShareable ? handleShare : undefined}
Expand All @@ -100,8 +100,8 @@ export const NetworkDetails = (props: INetworkDetailsProps) => {
...(tracing
? [
{
id: "tracing",
title: "Tracing",
id: 'tracing',
title: 'Tracing',
component: <TracingView response={responseBody} />,
},
]
Expand Down
8 changes: 4 additions & 4 deletions src/containers/NetworkPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import RegexParser from 'regex-parser'
import { SplitPaneLayout } from '@/components/Layout'
import { onNavigate } from '@/services/networkMonitor'
import { IWebSocketNetworkRequest } from '@/hooks/useWebSocketNetworkMonitor'
import { INetworkRequest } from '@/helpers/networkHelpers'
import { ICompleteNetworkRequest } from '@/helpers/networkHelpers'
import { NetworkTable, INetworkTableDataRow } from './NetworkTable'
import { NetworkDetails } from './NetworkDetails'
import { Toolbar } from '../Toolbar'
Expand All @@ -18,7 +18,7 @@ import { IClearWebRequestsOptions } from '../../hooks/useNetworkMonitor'
interface NetworkPanelProps {
selectedRowId: string | number | null
setSelectedRowId: (selectedRowId: string | number | null) => void
networkRequests: INetworkRequest[]
networkRequests: ICompleteNetworkRequest[]
webSocketNetworkRequests: IWebSocketNetworkRequest[]
clearWebRequests: (opts?: IClearWebRequestsOptions) => void
}
Expand All @@ -35,14 +35,14 @@ const getRegex = (str: string) => {
}

const filterNetworkRequests = (
networkRequests: INetworkRequest[],
networkRequests: ICompleteNetworkRequest[],
filterValue: string,
options: {
isInverted: boolean
isRegex: boolean
operationFilters: IOperationFilters
}
): { results: INetworkRequest[]; errorMessage?: string } => {
): { results: ICompleteNetworkRequest[]; errorMessage?: string } => {
const regexResult =
options.isRegex && filterValue ? getRegex(filterValue) : null
if (regexResult?.errorMessage) {
Expand Down
24 changes: 12 additions & 12 deletions src/containers/SearchPanel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { useMemo } from "react"
import { INetworkRequest } from "@/helpers/networkHelpers"
import { useSearch } from "@/hooks/useSearch"
import { NetworkTabs } from "@/hooks/useNetworkTabs"
import { getSearchResults, ISearchResult } from "@/services/searchService"
import { SearchResults } from "./SearchResults"
import { Header } from "@/components/Header"
import { CloseButton } from "@/components/CloseButton"
import { SearchInput } from "@/components/SearchInput"
import { IWebSocketNetworkRequest } from "@/hooks/useWebSocketNetworkMonitor"
import { useMemo } from 'react'
import { ICompleteNetworkRequest } from '@/helpers/networkHelpers'
import { useSearch } from '@/hooks/useSearch'
import { NetworkTabs } from '@/hooks/useNetworkTabs'
import { getSearchResults, ISearchResult } from '@/services/searchService'
import { SearchResults } from './SearchResults'
import { Header } from '@/components/Header'
import { CloseButton } from '@/components/CloseButton'
import { SearchInput } from '@/components/SearchInput'
import { IWebSocketNetworkRequest } from '@/hooks/useWebSocketNetworkMonitor'

interface ISearchPanelProps {
networkRequests: INetworkRequest[]
networkRequests: ICompleteNetworkRequest[]
webSocketNetworkRequests: IWebSocketNetworkRequest[]
onResultClick: (
searchResult: ISearchResult,
Expand Down Expand Up @@ -39,7 +39,7 @@ export const SearchPanel = (props: ISearchPanelProps) => {
/>
}
>
<div className="flex items-center pl-2" style={{ height: "3.5rem" }}>
<div className="flex items-center pl-2" style={{ height: '3.5rem' }}>
<h2 className="font-bold">Search</h2>
</div>
</Header>
Expand Down
20 changes: 10 additions & 10 deletions src/helpers/getSearchContent.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import { stringify } from "./safeJson"
import { IHeader, INetworkRequest } from "@/helpers/networkHelpers"
import { stringify } from './safeJson'
import { IHeader, ICompleteNetworkRequest } from '@/helpers/networkHelpers'

const stringifyHeaders = (headers: IHeader[] = []) => {
return headers
.map((header) => {
return `${header.name}: ${header.value}`
})
.join(", ")
.join(', ')
}

export const getHeaderSearchContent = (
networkRequest: INetworkRequest
networkRequest: ICompleteNetworkRequest
): string => {
const requestHeaderText = stringifyHeaders(networkRequest.request.headers)
const responseHeaderText = stringifyHeaders(networkRequest.response?.headers)
return [requestHeaderText, responseHeaderText].join(", ")
return [requestHeaderText, responseHeaderText].join(', ')
}

export const getRequestSearchContent = (
networkRequest: INetworkRequest
networkRequest: ICompleteNetworkRequest
): string => {
return networkRequest.request.body
.map((body) => {
return body.query + " " + stringify(body.variables)
return body.query + ' ' + stringify(body.variables)
})
.join(", ")
.join(', ')
}

export const getResponseSearchContent = (
networkRequest: INetworkRequest
networkRequest: ICompleteNetworkRequest
): string => {
return networkRequest.response?.body || ""
return networkRequest.response?.body || ''
}
8 changes: 4 additions & 4 deletions src/helpers/networkHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface IHeader {
value?: string
}

export interface INetworkRequest {
export interface ICompleteNetworkRequest {
id: string
status: number
url: string
Expand Down Expand Up @@ -39,8 +39,8 @@ export interface INetworkRequest {
* and populated before we output from the useNetworkMonitor hook.
* */
export interface IIncompleteNetworkRequest
extends Omit<INetworkRequest, 'request'> {
request?: Partial<INetworkRequest['request']>
extends Omit<ICompleteNetworkRequest, 'request'> {
request?: Partial<ICompleteNetworkRequest['request']>
}

/**
Expand Down Expand Up @@ -74,7 +74,7 @@ const isNetworkRequest = (
*/
export const isRequestComplete = (
networkRequest: IIncompleteNetworkRequest
): networkRequest is INetworkRequest => {
): networkRequest is ICompleteNetworkRequest => {
return (
networkRequest.request !== undefined &&
networkRequest.request.headers !== undefined &&
Expand Down
Loading

0 comments on commit 7457217

Please sign in to comment.