1- import { Form , Input , InputNumber , Select , Switch , Typography } from 'antd' ;
1+ import {
2+ Dropdown ,
3+ Form ,
4+ Input ,
5+ InputNumber ,
6+ Select ,
7+ Switch ,
8+ Typography ,
9+ } from 'antd' ;
210import React from 'react' ;
311import { MonitorOverviewComponent , MonitorProvider } from './types' ;
412import { trpc } from '../../../api/trpc' ;
@@ -8,9 +16,17 @@ import { isEmpty } from 'lodash-es';
816import { useCurrentWorkspaceId } from '../../../store/user' ;
917import { z } from 'zod' ;
1018import { useTranslation } from '@i18next-toolkit/react' ;
19+ import { Button } from '@/components/ui/button' ;
20+ import { useEvent } from '@/hooks/useEvent' ;
21+ import { LuArrowDown , LuChevronDown } from 'react-icons/lu' ;
1122
1223const MonitorHttp : React . FC = React . memo ( ( ) => {
1324 const { t } = useTranslation ( ) ;
25+ const form = Form . useFormInstance ( ) ;
26+
27+ const handleSetHeaderValue = useEvent ( ( json : Record < string , string > ) => {
28+ form . setFieldValue ( [ 'payload' , 'headers' ] , JSON . stringify ( json , null , 2 ) ) ;
29+ } ) ;
1430
1531 return (
1632 < >
@@ -38,7 +54,7 @@ const MonitorHttp: React.FC = React.memo(() => {
3854 </ Form . Item >
3955
4056 < Form . Item
41- label = " Method"
57+ label = { t ( ' Method' ) }
4258 name = { [ 'payload' , 'method' ] }
4359 initialValue = { 'get' }
4460 >
@@ -102,6 +118,47 @@ const MonitorHttp: React.FC = React.memo(() => {
102118 } ,
103119 } ,
104120 ] }
121+ extra = {
122+ < Dropdown
123+ trigger = { [ 'click' ] }
124+ placement = "bottomRight"
125+ menu = { {
126+ items : [
127+ {
128+ key : 'default' ,
129+ label : t ( 'Default Fetch Headers' ) ,
130+ onClick : ( ) =>
131+ handleSetHeaderValue ( {
132+ 'Accept-Encoding' : 'gzip, deflate, br, zstd' ,
133+ 'Accept-Language' : 'en-US,en;q=0.9' ,
134+ 'Cache-Control' : 'max-age=0' ,
135+ Priority : 'u=0, i' ,
136+ 'Sec-Ch-Ua-Mobile' : '?0' ,
137+ 'Sec-Ch-Ua-Platform' : 'macOS' ,
138+ 'Sec-Fetch-Dest' : 'document' ,
139+ 'Sec-Fetch-Mode' : 'navigate' ,
140+ 'Sec-Fetch-Site' : 'same-site' ,
141+ 'Sec-Fetch-User' : '?1' ,
142+ 'Upgrade-Insecure-Requests' : '1' ,
143+ 'User-Agent' :
144+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36' ,
145+ } ) ,
146+ } ,
147+ ] ,
148+ } }
149+ >
150+ < Button
151+ variant = "secondary"
152+ size = "sm"
153+ type = "button"
154+ className = "absolute -top-9 right-0"
155+ Icon = { LuChevronDown }
156+ iconType = "right"
157+ >
158+ { t ( 'Preset' ) }
159+ </ Button >
160+ </ Dropdown >
161+ }
105162 >
106163 < Input . TextArea
107164 rows = { 4 }
0 commit comments