diff options
Diffstat (limited to 'src/components/RequestList')
| -rw-r--r-- | src/components/RequestList/RequestList.tsx | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/src/components/RequestList/RequestList.tsx b/src/components/RequestList/RequestList.tsx index 6980738..a925c3b 100644 --- a/src/components/RequestList/RequestList.tsx +++ b/src/components/RequestList/RequestList.tsx | |||
| @@ -38,23 +38,31 @@ export default function RequestList({ | |||
| 38 | 38 | ||
| 39 | const [methods, setMethods] = useState<EnabledMethods>({ | 39 | const [methods, setMethods] = useState<EnabledMethods>({ |
| 40 | GET: true, | 40 | GET: true, |
| 41 | HEAD: true, | ||
| 41 | POST: true, | 42 | POST: true, |
| 42 | PUT: true, | 43 | PUT: true, |
| 43 | PATCH: true, | ||
| 44 | DELETE: true, | 44 | DELETE: true, |
| 45 | CONNECT: true, | ||
| 46 | OPTIONS: true, | ||
| 47 | TRACE: true, | ||
| 48 | PATCH: true, | ||
| 45 | }); | 49 | }); |
| 46 | 50 | ||
| 47 | const toggleMethods = useCallback((method: Method | null) => { | 51 | const toggleMethods = useCallback((method: Method | null) => { |
| 48 | const enabled = method == null; | 52 | const enabled = method == null; |
| 49 | const methods = { | 53 | const methods: EnabledMethods = { |
| 50 | GET: enabled, | 54 | GET: enabled, |
| 55 | HEAD: enabled, | ||
| 51 | POST: enabled, | 56 | POST: enabled, |
| 52 | PUT: enabled, | 57 | PUT: enabled, |
| 53 | PATCH: enabled, | ||
| 54 | DELETE: enabled, | 58 | DELETE: enabled, |
| 59 | CONNECT: enabled, | ||
| 60 | OPTIONS: enabled, | ||
| 61 | TRACE: enabled, | ||
| 62 | PATCH: enabled, | ||
| 55 | }; | 63 | }; |
| 56 | 64 | ||
| 57 | if (!enabled) { | 65 | if (method !== null) { |
| 58 | methods[method] = true; | 66 | methods[method] = true; |
| 59 | } | 67 | } |
| 60 | 68 | ||
| @@ -72,7 +80,7 @@ export default function RequestList({ | |||
| 72 | const methodLabel = useMemo(() => { | 80 | const methodLabel = useMemo(() => { |
| 73 | if (enabledMethods.length == 1) { | 81 | if (enabledMethods.length == 1) { |
| 74 | return enabledMethods[0]; | 82 | return enabledMethods[0]; |
| 75 | } else if (enabledMethods.length === 5) { | 83 | } else if (enabledMethods.length === Object.keys(methods).length) { |
| 76 | return "ANY"; | 84 | return "ANY"; |
| 77 | } else { | 85 | } else { |
| 78 | return "CUSTOM"; | 86 | return "CUSTOM"; |
| @@ -88,12 +96,9 @@ export default function RequestList({ | |||
| 88 | ); | 96 | ); |
| 89 | } catch {} | 97 | } catch {} |
| 90 | 98 | ||
| 91 | return ( | 99 | return requests |
| 92 | requests.map((request, index) => [index, request]).reverse() as [ | 100 | .map<[number, RequestResponse]>((request, index) => [index, request]) |
| 93 | number, | 101 | .reverse() |
| 94 | RequestResponse | ||
| 95 | ][] | ||
| 96 | ) | ||
| 97 | .filter( | 102 | .filter( |
| 98 | ([index, request]) => | 103 | ([index, request]) => |
| 99 | enabledMethods.length > 0 === null || | 104 | enabledMethods.length > 0 === null || |
| @@ -119,21 +124,11 @@ export default function RequestList({ | |||
| 119 | ANY | 124 | ANY |
| 120 | </Dropdown.Item> | 125 | </Dropdown.Item> |
| 121 | <Dropdown.Divider /> | 126 | <Dropdown.Divider /> |
| 122 | <Dropdown.Item onClick={() => toggleMethods("GET")}> | 127 | {Object.entries(methods).map(([method, enabled]) => ( |
| 123 | GET | 128 | <Dropdown.Item onClick={() => toggleMethods(method as Method)}> |
| 124 | </Dropdown.Item> | 129 | {method} |
| 125 | <Dropdown.Item onClick={() => toggleMethods("POST")}> | 130 | </Dropdown.Item> |
| 126 | POST | 131 | ))} |
| 127 | </Dropdown.Item> | ||
| 128 | <Dropdown.Item onClick={() => toggleMethods("PUT")}> | ||
| 129 | PUT | ||
| 130 | </Dropdown.Item> | ||
| 131 | <Dropdown.Item onClick={() => toggleMethods("PATCH")}> | ||
| 132 | PATCH | ||
| 133 | </Dropdown.Item> | ||
| 134 | <Dropdown.Item onClick={() => toggleMethods("DELETE")}> | ||
| 135 | DELETE | ||
| 136 | </Dropdown.Item> | ||
| 137 | </DropdownButton> | 132 | </DropdownButton> |
| 138 | <Form.Control | 133 | <Form.Control |
| 139 | type="text" | 134 | type="text" |
