@@ -18,6 +18,7 @@ import getProject from "app/projects/queries/getProject"
1818import { DeleteIcon , EditIcon } from "@chakra-ui/icons"
1919import { HiOutlineClipboardCopy } from "react-icons/hi"
2020import { CopyToClipboard } from "react-copy-to-clipboard"
21+ import formatXml from "xml-formatter"
2122
2223const BreadCrumb = ( { stub } ) => {
2324 const [ project ] = useQuery ( getProject , { id : stub . projectId } )
@@ -107,137 +108,144 @@ export const Stub = () => {
107108 DELETE
108109 </ Button >
109110 </ Flex >
110- < Box fontSize = "md" mr = "1" ml = "1" mt = "1" mb = "5" p = "1" borderWidth = "1px" borderRadius = "lg" >
111- < Flex justify = "space-between" >
112- < Box flex = "1" >
113- < Flex direction = "column" fontWeight = "bold" color = "#666" >
114- < Text mb = "1" h = "1.5rem" >
115- path
116- </ Text >
117- < Text mb = "1" h = "1.5rem" >
118- createdBy
119- </ Text >
120- < Text mb = "1" h = "1.5rem" >
121- createdAt
122- </ Text >
123- < Text mb = "1" h = "1.5rem" >
124- updatedBy
125- </ Text >
126- < Text mb = "1" h = "1.5rem" >
127- updatedAt
128- </ Text >
129- < Text mb = "1" h = "1.5rem" >
130- method
131- </ Text >
132- < Text mb = "1" h = "1.5rem" >
133- contentType
134- </ Text >
135- < Text mb = "1" h = "1.5rem" >
136- statusCode
137- </ Text >
138- { stub . sleep !== 0 && (
139- < >
140- < Text mb = "1" h = "1.5rem" >
141- sleep
142- </ Text >
143- </ >
144- ) }
145- { stub . ntimesError !== 0 && (
146- < >
147- < Text mb = "1" h = "1.5rem" >
148- ntimesError
149- </ Text >
150- < Text mb = "1" h = "1.5rem" >
151- ntimesErrorStatusCode
152- </ Text >
153- </ >
154- ) }
155- { stub . memo !== "" && (
156- < Text mb = "1" h = "100" >
157- memo
111+ < Flex fontSize = "md" mr = "1" ml = "1" mt = "1" mb = "5" p = "1" borderWidth = "1px" borderRadius = "lg" >
112+ < Box w = "33%" >
113+ < Flex direction = "column" fontWeight = "bold" color = "#666" >
114+ < Text mb = "1" h = "1.5rem" >
115+ path
116+ </ Text >
117+ < Text mb = "1" h = "1.5rem" >
118+ createdBy
119+ </ Text >
120+ < Text mb = "1" h = "1.5rem" >
121+ createdAt
122+ </ Text >
123+ < Text mb = "1" h = "1.5rem" >
124+ updatedBy
125+ </ Text >
126+ < Text mb = "1" h = "1.5rem" >
127+ updatedAt
128+ </ Text >
129+ < Text mb = "1" h = "1.5rem" >
130+ method
131+ </ Text >
132+ < Text mb = "1" h = "1.5rem" >
133+ contentType
134+ </ Text >
135+ < Text mb = "1" h = "1.5rem" >
136+ statusCode
137+ </ Text >
138+ { stub . sleep !== 0 && (
139+ < >
140+ < Text mb = "1" h = "1.5rem" >
141+ sleep
158142 </ Text >
159- ) }
160- < Text > response</ Text >
161- </ Flex >
162- </ Box >
163- < Box flex = "2" >
164- < Flex direction = "column" >
165- < Text mb = "1" h = "1.5rem" >
166- { stub . path }
167- </ Text >
168- < Text mb = "1" h = "1.5rem" >
169- { stub . createdBy }
170- </ Text >
171- < Text mb = "1" h = "1.5rem" >
172- { stub . createdAt . toLocaleString ( ) }
173- </ Text >
174- < Text mb = "1" h = "1.5rem" >
175- { stub . updatedBy }
176- </ Text >
177- < Text mb = "1" h = "1.5rem" >
178- { stub . updatedAt . toLocaleString ( ) }
179- </ Text >
180- < Text mb = "1" h = "1.5rem" >
181- { stub . method }
182- </ Text >
183- < Text mb = "1" h = "1.5rem" >
184- { stub . contentType }
185- </ Text >
186- < Text mb = "1" h = "1.5rem" >
187- { stub . statusCode }
143+ </ >
144+ ) }
145+ { stub . ntimesError !== 0 && (
146+ < >
147+ < Text mb = "1" h = "1.5rem" >
148+ ntimesError
149+ </ Text >
150+ < Text mb = "1" h = "1.5rem" >
151+ ntimesErrorStatusCode
152+ </ Text >
153+ </ >
154+ ) }
155+ { stub . memo !== "" && (
156+ < Text mb = "1" h = "100" >
157+ memo
188158 </ Text >
189- { stub . sleep !== 0 && (
190- < >
191- < Text mb = "1" h = "1.5rem" >
192- { stub . sleep } s
193- </ Text >
194- </ >
195- ) }
196- { stub . ntimesError !== 0 && (
197- < >
198- < Text mb = "1" h = "1.5rem" >
199- { stub . ntimesError } times
200- </ Text >
201- < Text mb = "1" h = "1.5rem" >
202- { stub . ntimesErrorStatusCode }
203- </ Text >
204- </ >
205- ) }
206- { stub . memo !== "" && (
207- < Text
208- h = "100"
209- overflowY = "auto"
210- mb = "1"
211- style = { { whiteSpace : "pre-wrap" , wordWrap : "break-word" } }
212- borderRadius = "lg"
213- borderWidth = "1px"
214- >
215- { stub . memo }
159+ ) }
160+ < Text > response</ Text >
161+ </ Flex >
162+ </ Box >
163+ < Box w = "66%" >
164+ < Flex direction = "column" >
165+ < Text mb = "1" h = "1.5rem" >
166+ { stub . path }
167+ </ Text >
168+ < Text mb = "1" h = "1.5rem" >
169+ { stub . createdBy }
170+ </ Text >
171+ < Text mb = "1" h = "1.5rem" >
172+ { stub . createdAt . toLocaleString ( ) }
173+ </ Text >
174+ < Text mb = "1" h = "1.5rem" >
175+ { stub . updatedBy }
176+ </ Text >
177+ < Text mb = "1" h = "1.5rem" >
178+ { stub . updatedAt . toLocaleString ( ) }
179+ </ Text >
180+ < Text mb = "1" h = "1.5rem" >
181+ { stub . method }
182+ </ Text >
183+ < Text mb = "1" h = "1.5rem" >
184+ { stub . contentType }
185+ </ Text >
186+ < Text mb = "1" h = "1.5rem" >
187+ { stub . statusCode }
188+ </ Text >
189+ { stub . sleep !== 0 && (
190+ < >
191+ < Text mb = "1" h = "1.5rem" >
192+ { stub . sleep } s
216193 </ Text >
217- ) }
218- < Box
219- w = "100%"
220- p = "2"
221- bgColor = "#3c3c3c"
222- color = "#fff"
223- borderRadius = "lg"
224- maxH = "300"
194+ </ >
195+ ) }
196+ { stub . ntimesError !== 0 && (
197+ < >
198+ < Text mb = "1" h = "1.5rem" >
199+ { stub . ntimesError } times
200+ </ Text >
201+ < Text mb = "1" h = "1.5rem" >
202+ { stub . ntimesErrorStatusCode }
203+ </ Text >
204+ </ >
205+ ) }
206+ { stub . memo !== "" && (
207+ < Text
208+ h = "100"
225209 overflowY = "auto"
210+ mb = "1"
211+ style = { { whiteSpace : "pre-wrap" , wordWrap : "break-word" } }
212+ borderRadius = "lg"
213+ borderWidth = "1px"
226214 >
227- < pre style = { { whiteSpace : "pre-wrap" } } >
228- { ( ( ) => {
229- try {
215+ { stub . memo }
216+ </ Text >
217+ ) }
218+ < Box
219+ w = "100%"
220+ p = "2"
221+ bgColor = "#3c3c3c"
222+ color = "#fff"
223+ borderRadius = "lg"
224+ maxH = "300"
225+ overflowY = "auto"
226+ >
227+ < pre style = { { whiteSpace : "pre-wrap" } } >
228+ { ( ( ) => {
229+ try {
230+ if (
231+ stub . contentType === "application/json" ||
232+ stub . contentType === "text/json"
233+ ) {
230234 return JSON . stringify ( JSON . parse ( stub . response ) , null , 2 )
231- } catch {
235+ } else if ( stub . contentType === "application/xml" ) {
236+ return formatXml ( stub . response , { lineSeparator : "\n" } )
237+ } else {
232238 return stub . response
233239 }
234- } ) ( ) }
235- </ pre >
236- </ Box >
237- </ Flex >
238- </ Box >
239- </ Flex >
240- </ Box >
240+ } catch {
241+ return stub . response
242+ }
243+ } ) ( ) }
244+ </ pre >
245+ </ Box >
246+ </ Flex >
247+ </ Box >
248+ </ Flex >
241249 < Heading size = "md" as = "h3" mb = "1" >
242250 Recent Requests
243251 </ Heading >
@@ -255,9 +263,12 @@ export const Stub = () => {
255263 . split ( "\t" )
256264 . filter ( ( s ) => s !== "" )
257265 . map ( ( l , i ) => (
258- < pre style = { { whiteSpace : "pre-wrap" } } key = { "log_" + i } >
259- { i !== 0 ? `\n${ l } ` : l }
260- </ pre >
266+ < >
267+ < pre style = { { whiteSpace : "pre-wrap" } } key = { "log_" + i } >
268+ { i !== 0 ? `\n${ l } ` : l }
269+ </ pre >
270+ < hr />
271+ </ >
261272 ) )
262273 : "Never been requested..." }
263274 </ Box >
0 commit comments