@@ -59,6 +59,71 @@ const RequestNode = ({ id, data }) => {
5959 setRequestNodeUrl ( id , value ) ;
6060 } ;
6161
62+ const renderNewVars = ( vType ) => {
63+ const variables = vType === 'pre-request' ? data . preReqVars : data . postRespVars ;
64+ return (
65+ < >
66+ { variables && Object . keys ( variables ) . length > 0 ? (
67+ < table className = 'leading-normal' >
68+ < thead >
69+ < tr className = 'text-xs font-bold tracking-wider text-left bg-ghost-50 text-ghost-600' >
70+ < th className = 'p-1 border border-ghost-200' > Name</ th >
71+ < th className = 'p-1 border border-ghost-200 ' > Value</ th >
72+ < th className = 'p-1 border border-ghost-200 ' > </ th >
73+ </ tr >
74+ </ thead >
75+ < tbody >
76+ { Object . keys ( variables ) . map ( ( id , index ) => (
77+ < tr key = { index } className = 'text-sm border-b border-gray-200 text-ghost-700 hover:bg-ghost-50' >
78+ < td className = 'p-1 whitespace-no-wrap' >
79+ < input
80+ type = 'text'
81+ className = 'nodrag nowheel block h-9 rounded-bl-md rounded-tl-md p-2.5'
82+ name = 'variable-name'
83+ value = { id }
84+ readOnly
85+ />
86+ </ td >
87+ < td className = 'p-1 whitespace-no-wrap' >
88+ { variables [ id ] . type === 'Boolean' ? (
89+ < select
90+ onChange = { ( e ) => handleVariableChange ( e , vType , id ) }
91+ name = 'boolean-val'
92+ className = 'nodrag h-9 rounded-br-md rounded-tr-md p-2.5 px-1'
93+ value = { variables [ id ] . value }
94+ >
95+ < option value = 'true' > True</ option >
96+ < option value = 'false' > False</ option >
97+ </ select >
98+ ) : variables [ id ] . type === 'Now' ? (
99+ < div > </ div >
100+ ) : (
101+ < input
102+ type = { getInputType ( variables [ id ] . type ) }
103+ className = 'nodrag nowheel block h-9 rounded-bl-md rounded-tl-md p-2.5'
104+ name = 'variable-value'
105+ data-type = { getInputType ( variables [ id ] . type ) }
106+ onChange = { ( e ) => handleVariableChange ( e , vType , id ) }
107+ value = { variables [ id ] . value }
108+ />
109+ ) }
110+ </ td >
111+ < td className = 'p-1 whitespace-no-wrap' >
112+ < div onClick = { ( e ) => handleDeleteVariable ( e , vType , id ) } className = 'pl-2 text-neutral-500' >
113+ < TrashIcon className = 'w-4 h-4' />
114+ </ div >
115+ </ td >
116+ </ tr >
117+ ) ) }
118+ </ tbody >
119+ </ table >
120+ ) : (
121+ ''
122+ ) }
123+ </ >
124+ ) ;
125+ } ;
126+
62127 const renderVariables = ( vType ) => {
63128 const variables = vType === 'pre-request' ? data . preReqVars : data . postRespVars ;
64129 return (
@@ -124,84 +189,82 @@ const RequestNode = ({ id, data }) => {
124189 return [ ] ;
125190 } ;
126191
192+ const listBox = ( ) => {
193+ return (
194+ < Listbox
195+ value = { data . requestType }
196+ onChange = { ( selectedValue ) => {
197+ setRequestNodeType ( id , selectedValue ) ;
198+ } }
199+ className = 'text-xl'
200+ >
201+ < div >
202+ < Listbox . Button className = 'relative flex text-left cursor-default border-cyan-950' >
203+ < span className = 'block truncate' > { data . requestType } </ span >
204+ < span className = 'p-1' >
205+ < ChevronUpDownIcon className = 'w-5 h-5' aria-hidden = 'true' />
206+ </ span >
207+ </ Listbox . Button >
208+ < Transition as = { Fragment } leave = 'transition ease-in duration-100' leaveFrom = 'opacity-100' leaveTo = 'opacity-0' >
209+ < Listbox . Options className = 'absolute z-50 py-1 mt-1 overflow-auto text-base bg-white max-h-60 w-36 focus:outline-none' >
210+ { requestNodes
211+ . map ( ( el ) => el . requestType )
212+ . map ( ( reqType ) => (
213+ < Listbox . Option
214+ key = { reqType }
215+ className = { ( { active } ) =>
216+ `relative cursor-default select-none py-2 pl-7 pr-4 hover:font-semibold ${
217+ active ? 'bg-background-light text-slate-900' : ''
218+ } `
219+ }
220+ value = { reqType }
221+ >
222+ { ( { selected } ) => (
223+ < >
224+ < span className = { `block` } > { reqType } </ span >
225+ { selected ? (
226+ < span className = 'absolute inset-y-0 left-0 flex items-center pl-1 font-semibold' >
227+ < CheckIcon className = 'w-5 h-5' aria-hidden = 'true' />
228+ </ span >
229+ ) : null }
230+ </ >
231+ ) }
232+ </ Listbox . Option >
233+ ) ) }
234+ </ Listbox . Options >
235+ </ Transition >
236+ </ div >
237+ </ Listbox >
238+ ) ;
239+ } ;
240+
127241 return (
128242 < FlowNode
129- title = { data . requestType + ' Request' }
243+ title = { listBox ( ) }
130244 handleLeft = { true }
131245 handleLeftData = { { type : 'target' } }
132246 handleRight = { true }
133247 handleRightData = { { type : 'source' } }
134248 >
135249 < div className = 'w-96' >
136- < div className = 'flex items-center justify-center gap-2 py-4' >
137- < Listbox
138- value = { data . requestType }
139- onChange = { ( selectedValue ) => {
140- setRequestNodeType ( id , selectedValue ) ;
141- } }
142- className = 'w-1/4'
143- >
144- < div >
145- < Listbox . Button className = 'relative w-full p-2 text-left border rounded cursor-default border-cyan-950' >
146- < span className = 'block truncate' > { data . requestType } </ span >
147- < span className = 'absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none' >
148- < ChevronUpDownIcon className = 'w-5 h-5' aria-hidden = 'true' />
149- </ span >
150- </ Listbox . Button >
151- < Transition
152- as = { Fragment }
153- leave = 'transition ease-in duration-100'
154- leaveFrom = 'opacity-100'
155- leaveTo = 'opacity-0'
156- >
157- < Listbox . Options className = 'absolute z-50 py-1 mt-1 overflow-auto text-base bg-white max-h-60 w-36 focus:outline-none' >
158- { requestNodes
159- . map ( ( el ) => el . requestType )
160- . map ( ( reqType ) => (
161- < Listbox . Option
162- key = { reqType }
163- className = { ( { active } ) =>
164- `relative cursor-default select-none py-2 pl-7 pr-4 hover:font-semibold ${
165- active ? 'bg-background-light text-slate-900' : ''
166- } `
167- }
168- value = { reqType }
169- >
170- { ( { selected } ) => (
171- < >
172- < span className = { `block` } > { reqType } </ span >
173- { selected ? (
174- < span className = 'absolute inset-y-0 left-0 flex items-center pl-1 font-semibold' >
175- < CheckIcon className = 'w-5 h-5' aria-hidden = 'true' />
176- </ span >
177- ) : null }
178- </ >
179- ) }
180- </ Listbox . Option >
181- ) ) }
182- </ Listbox . Options >
183- </ Transition >
184- </ div >
185- </ Listbox >
186- < TextEditor
187- placeHolder = { `Enter URL for a ${ data . requestType } request` }
188- onChangeHandler = { handleUrlInputChange }
189- name = { 'url' }
190- value = { data . url ? data . url : '' }
191- completionOptions = { getActiveVariables ( ) }
192- styles = { 'w-3/4' }
193- />
194- </ div >
250+ < TextEditor
251+ placeHolder = { `Enter URL for a ${ data . requestType } request` }
252+ onChangeHandler = { handleUrlInputChange }
253+ name = { 'url' }
254+ value = { data . url ? data . url : '' }
255+ completionOptions = { getActiveVariables ( ) }
256+ styles = { 'w-full mb-2' }
257+ />
195258 < NodeHorizontalDivider />
196259 < RequestBody nodeId = { id } nodeData = { data } />
197260 < NodeHorizontalDivider />
198- < div className = 'p-4 bg-background' >
199- < h3 > Variables</ h3 >
200- < div className = 'mt-4' >
261+ < div className = 'bg-background' >
262+ < h3 className = 'p-2' > Variables</ h3 >
263+ < div >
201264 < NodeHorizontalDivider />
202- < div className = 'p-2' >
265+ < div >
203266 < div className = 'flex items-center justify-between' >
204- < div > Pre Request</ div >
267+ < div className = 'p-2' > Pre Request</ div >
205268 < button
206269 onClick = { ( ) => {
207270 setModalType ( 'pre-request' ) ;
@@ -211,12 +274,12 @@ const RequestNode = ({ id, data }) => {
211274 < PlusIcon className = 'w-4 h-4' />
212275 </ button >
213276 </ div >
214- { renderVariables ( 'pre-request' ) }
277+ { renderNewVars ( 'pre-request' ) }
215278 </ div >
216279 < NodeHorizontalDivider />
217- < div className = 'p-2' >
280+ < div >
218281 < div className = 'flex items-center justify-between' >
219- < div > Post Response</ div >
282+ < div className = 'p-2' > Post Response</ div >
220283 < button
221284 onClick = { ( ) => {
222285 setModalType ( 'post-response' ) ;
0 commit comments