diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/App/App.module.scss | 9 | ||||
| -rw-r--r-- | src/components/App/App.tsx | 54 | ||||
| -rw-r--r-- | src/components/Content/Content.tsx | 1 | ||||
| -rw-r--r-- | src/components/Icons/Filter.tsx | 10 | ||||
| -rw-r--r-- | src/components/RequestDetails/RequestDetails.module.scss (renamed from src/components/Details/Details.module.scss) | 8 | ||||
| -rw-r--r-- | src/components/RequestDetails/RequestDetails.tsx (renamed from src/components/Details/Details.tsx) | 16 | ||||
| -rw-r--r-- | src/components/RequestList/RequestList.module.scss | 20 | ||||
| -rw-r--r-- | src/components/RequestList/RequestList.tsx | 203 |
8 files changed, 257 insertions, 64 deletions
diff --git a/src/components/App/App.module.scss b/src/components/App/App.module.scss index 088a4f6..61e399e 100644 --- a/src/components/App/App.module.scss +++ b/src/components/App/App.module.scss | |||
| @@ -16,7 +16,6 @@ | |||
| 16 | .sidebar { | 16 | .sidebar { |
| 17 | width: calc((6 / 16) * 100%); | 17 | width: calc((6 / 16) * 100%); |
| 18 | height: 100%; | 18 | height: 100%; |
| 19 | overflow-y: auto; | ||
| 20 | } | 19 | } |
| 21 | 20 | ||
| 22 | .details { | 21 | .details { |
| @@ -24,11 +23,3 @@ | |||
| 24 | overflow: hidden; | 23 | overflow: hidden; |
| 25 | height: 100%; | 24 | height: 100%; |
| 26 | } | 25 | } |
| 27 | |||
| 28 | .noRequest, .noRequestSelected { | ||
| 29 | width: 100%; | ||
| 30 | height: 100%; | ||
| 31 | display: flex; | ||
| 32 | justify-content: center; | ||
| 33 | align-items: center; | ||
| 34 | } | ||
diff --git a/src/components/App/App.tsx b/src/components/App/App.tsx index 55ab5b4..e08c84f 100644 --- a/src/components/App/App.tsx +++ b/src/components/App/App.tsx | |||
| @@ -6,8 +6,7 @@ import useRequests, { | |||
| 6 | } from "../../hooks/useRequests"; | 6 | } from "../../hooks/useRequests"; |
| 7 | 7 | ||
| 8 | import styles from './App.module.scss'; | 8 | import styles from './App.module.scss'; |
| 9 | import Details from "../Details/Details"; | 9 | import RequestDetails from "../RequestDetails/RequestDetails"; |
| 10 | import RequestSummary from "../RequestSummary/RequestSummary"; | ||
| 11 | import {getHost} from "../../utils"; | 10 | import {getHost} from "../../utils"; |
| 12 | import {Container, ListGroup, Nav, Navbar, NavDropdown} from "react-bootstrap"; | 11 | import {Container, ListGroup, Nav, Navbar, NavDropdown} from "react-bootstrap"; |
| 13 | import classNames from "classnames"; | 12 | import classNames from "classnames"; |
| @@ -16,6 +15,7 @@ import {Sun} from "../Icons/Sun"; | |||
| 16 | import {Moon} from "../Icons/Moon"; | 15 | import {Moon} from "../Icons/Moon"; |
| 17 | import Trash from "../Icons/Trash"; | 16 | import Trash from "../Icons/Trash"; |
| 18 | import {DarkModeContext} from "../../contexts/DarkMode"; | 17 | import {DarkModeContext} from "../../contexts/DarkMode"; |
| 18 | import RequestList from "../RequestList/RequestList"; | ||
| 19 | 19 | ||
| 20 | interface Config { | 20 | interface Config { |
| 21 | url: string | 21 | url: string |
| @@ -143,53 +143,11 @@ export default function App() { | |||
| 143 | </Navbar> | 143 | </Navbar> |
| 144 | 144 | ||
| 145 | <main className={styles.main}> | 145 | <main className={styles.main}> |
| 146 | <ListGroup | 146 | <div className={classNames("border-end", styles.sidebar)}> |
| 147 | variant='flush' | 147 | <RequestList requests={calls} selectedRequestIndex={selectedRequestIndex} setSelectedRequestIndex={setSelectedRequestIndex}/> |
| 148 | as="ul" | 148 | </div> |
| 149 | className={classNames("border-end", styles.sidebar)} | ||
| 150 | > | ||
| 151 | { | ||
| 152 | calls.length > 0 | ||
| 153 | ? ( | ||
| 154 | calls.slice(0).reverse().map((requestResponse, index) => { | ||
| 155 | const selected = selectedRequestIndex === calls.length - index - 1; | ||
| 156 | return ( | ||
| 157 | <ListGroup.Item | ||
| 158 | as="li" | ||
| 159 | onClick={() => setSelectedRequestIndex(calls.length - index - 1)} | ||
| 160 | key={`request-${index}`} | ||
| 161 | className={classNames({ | ||
| 162 | 'bg-primary': selected, | ||
| 163 | 'text-light': selected, | ||
| 164 | 'border-bottom': true | ||
| 165 | })} | ||
| 166 | > | ||
| 167 | <RequestSummary | ||
| 168 | requestResponse={requestResponse} | ||
| 169 | selected={selected} | ||
| 170 | /> | ||
| 171 | </ListGroup.Item> | ||
| 172 | ) | ||
| 173 | }) | ||
| 174 | ) | ||
| 175 | : ( | ||
| 176 | <div className={styles.noRequest}> | ||
| 177 | <p>No requests</p> | ||
| 178 | </div> | ||
| 179 | ) | ||
| 180 | } | ||
| 181 | </ListGroup> | ||
| 182 | <div className={styles.details}> | 149 | <div className={styles.details}> |
| 183 | { | 150 | <RequestDetails requestResponse={selectedRequest} /> |
| 184 | selectedRequest !== null | ||
| 185 | ? ( | ||
| 186 | <Details requestResponse={selectedRequest} /> | ||
| 187 | ) : ( | ||
| 188 | <div className={styles.noRequestSelected}> | ||
| 189 | <p>Select a request to inspect it</p> | ||
| 190 | </div> | ||
| 191 | ) | ||
| 192 | } | ||
| 193 | </div> | 151 | </div> |
| 194 | </main> | 152 | </main> |
| 195 | </div> | 153 | </div> |
diff --git a/src/components/Content/Content.tsx b/src/components/Content/Content.tsx index 3d747b2..c7a5f58 100644 --- a/src/components/Content/Content.tsx +++ b/src/components/Content/Content.tsx | |||
| @@ -7,7 +7,6 @@ import {Button, Col, Container, Row} from "react-bootstrap"; | |||
| 7 | import {DarkModeContext} from "../../contexts/DarkMode"; | 7 | import {DarkModeContext} from "../../contexts/DarkMode"; |
| 8 | 8 | ||
| 9 | function getHeader(headers: Headers, key: string, unit?: string): string | null { | 9 | function getHeader(headers: Headers, key: string, unit?: string): string | null { |
| 10 | console.log(headers, key) | ||
| 11 | try { | 10 | try { |
| 12 | const [_, value] = headers.find(([headerKey]) => headerKey.toLowerCase() === key.toLowerCase()) | 11 | const [_, value] = headers.find(([headerKey]) => headerKey.toLowerCase() === key.toLowerCase()) |
| 13 | return unit !== undefined | 12 | return unit !== undefined |
diff --git a/src/components/Icons/Filter.tsx b/src/components/Icons/Filter.tsx new file mode 100644 index 0000000..a14183d --- /dev/null +++ b/src/components/Icons/Filter.tsx | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | import * as React from "react"; | ||
| 2 | |||
| 3 | export function Filter() { | ||
| 4 | return <svg xmlns="http://www.w3.org/2000/svg" width="16" | ||
| 5 | height="16" fill="currentColor" className="bi bi-filter" | ||
| 6 | viewBox="0 0 16 16"> | ||
| 7 | <path | ||
| 8 | d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/> | ||
| 9 | </svg>; | ||
| 10 | } | ||
diff --git a/src/components/Details/Details.module.scss b/src/components/RequestDetails/RequestDetails.module.scss index 146b5d8..8a872f7 100644 --- a/src/components/Details/Details.module.scss +++ b/src/components/RequestDetails/RequestDetails.module.scss | |||
| @@ -16,3 +16,11 @@ | |||
| 16 | flex-shrink: 1; | 16 | flex-shrink: 1; |
| 17 | overflow-y: auto; | 17 | overflow-y: auto; |
| 18 | } | 18 | } |
| 19 | |||
| 20 | .noRequestSelected { | ||
| 21 | width: 100%; | ||
| 22 | height: 100%; | ||
| 23 | display: flex; | ||
| 24 | justify-content: center; | ||
| 25 | align-items: center; | ||
| 26 | } | ||
diff --git a/src/components/Details/Details.tsx b/src/components/RequestDetails/RequestDetails.tsx index 96f0790..34e572c 100644 --- a/src/components/Details/Details.tsx +++ b/src/components/RequestDetails/RequestDetails.tsx | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | import * as React from "react"; | 1 | import * as React from "react"; |
| 2 | import {useCallback, useMemo, useState} from "react"; | 2 | import {useCallback, useMemo, useState} from "react"; |
| 3 | import {RequestResponse, Headers} from "~hooks/useRequests"; | 3 | import {RequestResponse, Headers} from "../../hooks/useRequests"; |
| 4 | import styles from "./Details.module.scss"; | 4 | import styles from "./RequestDetails.module.scss"; |
| 5 | import RequestSummary from "../RequestSummary/RequestSummary"; | 5 | import RequestSummary from "../RequestSummary/RequestSummary"; |
| 6 | import Content from "../Content/Content"; | 6 | import Content from "../Content/Content"; |
| 7 | import {getHost} from "../../utils"; | 7 | import {getHost} from "../../utils"; |
| @@ -62,16 +62,16 @@ function Headers({ title, headers }: HeadersProps) { | |||
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | interface DetailsProps { | 64 | interface DetailsProps { |
| 65 | requestResponse: RequestResponse | 65 | requestResponse: RequestResponse | null |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | type Tab = 'headers' | 'request' | 'response' | 68 | type Tab = 'headers' | 'request' | 'response' |
| 69 | 69 | ||
| 70 | export default function Details({ requestResponse }: DetailsProps) { | 70 | export default function RequestDetails({ requestResponse }: DetailsProps) { |
| 71 | const [tab, selectTab] = useState<Tab>('headers'); | 71 | const [tab, selectTab] = useState<Tab>('headers'); |
| 72 | const [raw, setRaw] = useState(false); | 72 | const [raw, setRaw] = useState(false); |
| 73 | 73 | ||
| 74 | const resend = useCallback(async () => fetch( | 74 | const resend = useCallback(async () => requestResponse !== null && fetch( |
| 75 | `http://${getHost()}/resend/`, | 75 | `http://${getHost()}/resend/`, |
| 76 | { | 76 | { |
| 77 | method: 'POST', | 77 | method: 'POST', |
| @@ -82,7 +82,7 @@ export default function Details({ requestResponse }: DetailsProps) { | |||
| 82 | } | 82 | } |
| 83 | ), [requestResponse]); | 83 | ), [requestResponse]); |
| 84 | 84 | ||
| 85 | return ( | 85 | return requestResponse !== null ? ( |
| 86 | <div className={styles.details}> | 86 | <div className={styles.details}> |
| 87 | <div className={styles.header}> | 87 | <div className={styles.header}> |
| 88 | <Row> | 88 | <Row> |
| @@ -158,5 +158,9 @@ export default function Details({ requestResponse }: DetailsProps) { | |||
| 158 | } | 158 | } |
| 159 | </div> | 159 | </div> |
| 160 | </div> | 160 | </div> |
| 161 | ) : ( | ||
| 162 | <div className={styles.noRequestSelected}> | ||
| 163 | <p>Select a request to inspect it</p> | ||
| 164 | </div> | ||
| 161 | ) | 165 | ) |
| 162 | } | 166 | } |
diff --git a/src/components/RequestList/RequestList.module.scss b/src/components/RequestList/RequestList.module.scss new file mode 100644 index 0000000..47f36c8 --- /dev/null +++ b/src/components/RequestList/RequestList.module.scss | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | .noRequest { | ||
| 2 | width: 100%; | ||
