@@ -8,7 +8,7 @@ import { CollectedEvent, HtkResponse, HttpExchange, HttpExchangeView } from '../
8
8
import { styled } from '../../../styles' ;
9
9
import { logError } from '../../../errors' ;
10
10
11
- import { ExpandableViewCardKey , UiStore } from '../../../model/ui/ui-store' ;
11
+ import { ContentPerspective , ExpandableViewCardKey , UiStore } from '../../../model/ui/ui-store' ;
12
12
import { RulesStore } from '../../../model/rules/rules-store' ;
13
13
import { AccountStore } from '../../../model/account/account-store' ;
14
14
import { ApiExchange } from '../../../model/api/api-interfaces' ;
@@ -37,6 +37,7 @@ import { HttpRequestBreakpointHeader, HttpResponseBreakpointHeader } from './htt
37
37
import { HttpBreakpointRequestCard } from './http-breakpoint-request-card' ;
38
38
import { HttpBreakpointResponseCard } from './http-breakpoint-response-card' ;
39
39
import { HttpBreakpointBodyCard } from './http-breakpoint-body-card' ;
40
+ import { TransformCard } from './transform-card' ;
40
41
41
42
// Used to push all cards below it to the bottom (when less than 100% height)
42
43
const CardDivider = styled . div `
@@ -61,6 +62,7 @@ const makeFriendlyApiName = (rawName: string) => {
61
62
@observer
62
63
export class HttpDetailsPane extends React . Component < {
63
64
exchange : HttpExchangeView ,
65
+ perspective : ContentPerspective ,
64
66
65
67
requestEditor : portals . HtmlPortalNode < typeof SelfSizedEditor > ,
66
68
responseEditor : portals . HtmlPortalNode < typeof SelfSizedEditor > ,
@@ -121,7 +123,7 @@ export class HttpDetailsPane extends React.Component<{
121
123
}
122
124
123
125
const cards = ( exchange . downstream . isBreakpointed )
124
- ? this . renderBreakpointCards ( exchange . downstream , apiName , apiExchange )
126
+ ? this . renderBreakpointCards ( exchange , apiName , apiExchange )
125
127
: this . renderNormalCards ( exchange , apiName , apiExchange ) ;
126
128
127
129
return < >
@@ -235,30 +237,38 @@ export class HttpDetailsPane extends React.Component<{
235
237
}
236
238
237
239
private renderBreakpointCards (
238
- exchange : HttpExchange ,
240
+ exchange : HttpExchangeView ,
239
241
apiName : string | undefined ,
240
242
apiExchange : ApiExchange | undefined
241
243
) {
242
244
const { uiStore } = this . props ;
243
- const { requestBreakpoint } = exchange ;
245
+ const { requestBreakpoint } = exchange . downstream ;
244
246
245
247
const cards : Array < JSX . Element | null > = [ ] ;
246
248
247
249
if ( requestBreakpoint ) {
248
250
cards . push ( < HttpBreakpointRequestCard
249
251
{ ...this . cardProps . request }
250
- exchange = { exchange }
252
+ exchange = { exchange . downstream }
251
253
onChange = { requestBreakpoint . updateMetadata }
252
254
/> ) ;
253
255
254
256
cards . push ( this . renderRequestBody ( exchange , apiExchange ) ) ;
255
257
} else {
256
- const responseBreakpoint = exchange . responseBreakpoint ! ;
258
+ const responseBreakpoint = exchange . downstream . responseBreakpoint ! ;
259
+ const transformCard = this . renderTransformCard ( ) ;
260
+ if ( transformCard ) cards . push ( transformCard ) ;
257
261
258
262
cards . push ( this . renderApiCard ( apiName , apiExchange ) ) ;
259
263
cards . push ( < HttpRequestCard
260
264
{ ...this . cardProps . request }
261
- matchedRuleData = { this . matchedRuleData }
265
+ matchedRuleData = {
266
+ // Matched rule data is shown inline here only when there
267
+ // was not any substantial proxy transformation.
268
+ ! transformCard
269
+ ? this . matchedRuleData
270
+ : undefined
271
+ }
262
272
onRuleClicked = { this . jumpToRule }
263
273
exchange = { exchange }
264
274
/> ) ;
@@ -269,7 +279,7 @@ export class HttpDetailsPane extends React.Component<{
269
279
270
280
cards . push ( < HttpBreakpointResponseCard
271
281
{ ...this . cardProps . response }
272
- exchange = { exchange }
282
+ exchange = { exchange . downstream }
273
283
onChange = { responseBreakpoint . updateMetadata }
274
284
theme = { uiStore ! . theme }
275
285
/> ) ;
@@ -290,11 +300,19 @@ export class HttpDetailsPane extends React.Component<{
290
300
291
301
const cards : Array < JSX . Element | null > = [ ] ;
292
302
303
+ const transformCard = this . renderTransformCard ( ) ;
304
+ if ( transformCard ) cards . push ( transformCard ) ;
293
305
cards . push ( this . renderApiCard ( apiName , apiExchange ) ) ;
294
306
295
307
cards . push ( < HttpRequestCard
296
308
{ ...this . cardProps . request }
297
- matchedRuleData = { this . matchedRuleData }
309
+ matchedRuleData = {
310
+ // Matched rule data is shown inline here only when there
311
+ // was not any substantial proxy transformation.
312
+ ! transformCard
313
+ ? this . matchedRuleData
314
+ : undefined
315
+ }
298
316
onRuleClicked = { this . jumpToRule }
299
317
exchange = { exchange }
300
318
/> ) ;
@@ -377,14 +395,26 @@ export class HttpDetailsPane extends React.Component<{
377
395
return cards ;
378
396
}
379
397
398
+ private renderTransformCard ( ) {
399
+ const { uiStore } = this . props ;
400
+
401
+ if ( ! this . props . exchange . upstream ?. wasTransformed ) return false ;
402
+
403
+ return < TransformCard
404
+ key = 'transform'
405
+ matchedRuleData = { this . matchedRuleData }
406
+ onRuleClicked = { this . jumpToRule }
407
+ uiStore = { uiStore ! }
408
+ /> ;
409
+ }
410
+
380
411
private renderRequestBody ( exchange : HttpExchangeView , apiExchange : ApiExchange | undefined ) {
381
412
const { request } = exchange ;
382
413
const { requestBreakpoint } = exchange . downstream ;
383
414
384
415
return requestBreakpoint
385
416
? < HttpBreakpointBodyCard
386
417
{ ...this . requestBodyParams ( ) }
387
- exchangeId = { exchange . id }
388
418
body = { requestBreakpoint . inProgressResult . body }
389
419
rawHeaders = { requestBreakpoint . inProgressResult . rawHeaders }
390
420
onChange = { requestBreakpoint . updateBody }
@@ -405,7 +435,6 @@ export class HttpDetailsPane extends React.Component<{
405
435
return responseBreakpoint
406
436
? < HttpBreakpointBodyCard
407
437
{ ...this . responseBodyParams ( ) }
408
- exchangeId = { exchange . id }
409
438
body = { responseBreakpoint . inProgressResult . body }
410
439
rawHeaders = { responseBreakpoint . inProgressResult . rawHeaders }
411
440
onChange = { responseBreakpoint . updateBody }
@@ -449,6 +478,7 @@ export class HttpDetailsPane extends React.Component<{
449
478
...this . cardProps . requestBody ,
450
479
title : 'Request Body' ,
451
480
direction : 'right' as const ,
481
+ editorKey : `${ this . props . exchange . id } -${ this . props . perspective } -request` ,
452
482
editorNode : this . props . requestEditor
453
483
} ;
454
484
}
@@ -459,6 +489,7 @@ export class HttpDetailsPane extends React.Component<{
459
489
...this . cardProps . responseBody ,
460
490
title : 'Response Body' ,
461
491
direction : 'left' as const ,
492
+ editorKey : `${ this . props . exchange . id } -${ this . props . perspective } -response` ,
462
493
editorNode : this . props . responseEditor
463
494
} ;
464
495
}
0 commit comments