@@ -8,7 +8,7 @@ import { CollectedEvent, HtkResponse, HttpExchange, HttpExchangeView } from '../
88import { styled } from '../../../styles' ;
99import { logError } from '../../../errors' ;
1010
11- import { ExpandableViewCardKey , UiStore } from '../../../model/ui/ui-store' ;
11+ import { ContentPerspective , ExpandableViewCardKey , UiStore } from '../../../model/ui/ui-store' ;
1212import { RulesStore } from '../../../model/rules/rules-store' ;
1313import { AccountStore } from '../../../model/account/account-store' ;
1414import { ApiExchange } from '../../../model/api/api-interfaces' ;
@@ -37,6 +37,7 @@ import { HttpRequestBreakpointHeader, HttpResponseBreakpointHeader } from './htt
3737import { HttpBreakpointRequestCard } from './http-breakpoint-request-card' ;
3838import { HttpBreakpointResponseCard } from './http-breakpoint-response-card' ;
3939import { HttpBreakpointBodyCard } from './http-breakpoint-body-card' ;
40+ import { TransformCard } from './transform-card' ;
4041
4142// Used to push all cards below it to the bottom (when less than 100% height)
4243const CardDivider = styled . div `
@@ -61,6 +62,7 @@ const makeFriendlyApiName = (rawName: string) => {
6162@observer
6263export class HttpDetailsPane extends React . Component < {
6364 exchange : HttpExchangeView ,
65+ perspective : ContentPerspective ,
6466
6567 requestEditor : portals . HtmlPortalNode < typeof SelfSizedEditor > ,
6668 responseEditor : portals . HtmlPortalNode < typeof SelfSizedEditor > ,
@@ -121,7 +123,7 @@ export class HttpDetailsPane extends React.Component<{
121123 }
122124
123125 const cards = ( exchange . downstream . isBreakpointed )
124- ? this . renderBreakpointCards ( exchange . downstream , apiName , apiExchange )
126+ ? this . renderBreakpointCards ( exchange , apiName , apiExchange )
125127 : this . renderNormalCards ( exchange , apiName , apiExchange ) ;
126128
127129 return < >
@@ -235,30 +237,38 @@ export class HttpDetailsPane extends React.Component<{
235237 }
236238
237239 private renderBreakpointCards (
238- exchange : HttpExchange ,
240+ exchange : HttpExchangeView ,
239241 apiName : string | undefined ,
240242 apiExchange : ApiExchange | undefined
241243 ) {
242244 const { uiStore } = this . props ;
243- const { requestBreakpoint } = exchange ;
245+ const { requestBreakpoint } = exchange . downstream ;
244246
245247 const cards : Array < JSX . Element | null > = [ ] ;
246248
247249 if ( requestBreakpoint ) {
248250 cards . push ( < HttpBreakpointRequestCard
249251 { ...this . cardProps . request }
250- exchange = { exchange }
252+ exchange = { exchange . downstream }
251253 onChange = { requestBreakpoint . updateMetadata }
252254 /> ) ;
253255
254256 cards . push ( this . renderRequestBody ( exchange , apiExchange ) ) ;
255257 } else {
256- const responseBreakpoint = exchange . responseBreakpoint ! ;
258+ const responseBreakpoint = exchange . downstream . responseBreakpoint ! ;
259+ const transformCard = this . renderTransformCard ( ) ;
260+ if ( transformCard ) cards . push ( transformCard ) ;
257261
258262 cards . push ( this . renderApiCard ( apiName , apiExchange ) ) ;
259263 cards . push ( < HttpRequestCard
260264 { ...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+ }
262272 onRuleClicked = { this . jumpToRule }
263273 exchange = { exchange }
264274 /> ) ;
@@ -269,7 +279,7 @@ export class HttpDetailsPane extends React.Component<{
269279
270280 cards . push ( < HttpBreakpointResponseCard
271281 { ...this . cardProps . response }
272- exchange = { exchange }
282+ exchange = { exchange . downstream }
273283 onChange = { responseBreakpoint . updateMetadata }
274284 theme = { uiStore ! . theme }
275285 /> ) ;
@@ -290,11 +300,19 @@ export class HttpDetailsPane extends React.Component<{
290300
291301 const cards : Array < JSX . Element | null > = [ ] ;
292302
303+ const transformCard = this . renderTransformCard ( ) ;
304+ if ( transformCard ) cards . push ( transformCard ) ;
293305 cards . push ( this . renderApiCard ( apiName , apiExchange ) ) ;
294306
295307 cards . push ( < HttpRequestCard
296308 { ...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+ }
298316 onRuleClicked = { this . jumpToRule }
299317 exchange = { exchange }
300318 /> ) ;
@@ -377,14 +395,26 @@ export class HttpDetailsPane extends React.Component<{
377395 return cards ;
378396 }
379397
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+
380411 private renderRequestBody ( exchange : HttpExchangeView , apiExchange : ApiExchange | undefined ) {
381412 const { request } = exchange ;
382413 const { requestBreakpoint } = exchange . downstream ;
383414
384415 return requestBreakpoint
385416 ? < HttpBreakpointBodyCard
386417 { ...this . requestBodyParams ( ) }
387- exchangeId = { exchange . id }
388418 body = { requestBreakpoint . inProgressResult . body }
389419 rawHeaders = { requestBreakpoint . inProgressResult . rawHeaders }
390420 onChange = { requestBreakpoint . updateBody }
@@ -405,7 +435,6 @@ export class HttpDetailsPane extends React.Component<{
405435 return responseBreakpoint
406436 ? < HttpBreakpointBodyCard
407437 { ...this . responseBodyParams ( ) }
408- exchangeId = { exchange . id }
409438 body = { responseBreakpoint . inProgressResult . body }
410439 rawHeaders = { responseBreakpoint . inProgressResult . rawHeaders }
411440 onChange = { responseBreakpoint . updateBody }
@@ -449,6 +478,7 @@ export class HttpDetailsPane extends React.Component<{
449478 ...this . cardProps . requestBody ,
450479 title : 'Request Body' ,
451480 direction : 'right' as const ,
481+ editorKey : `${ this . props . exchange . id } -${ this . props . perspective } -request` ,
452482 editorNode : this . props . requestEditor
453483 } ;
454484 }
@@ -459,6 +489,7 @@ export class HttpDetailsPane extends React.Component<{
459489 ...this . cardProps . responseBody ,
460490 title : 'Response Body' ,
461491 direction : 'left' as const ,
492+ editorKey : `${ this . props . exchange . id } -${ this . props . perspective } -response` ,
462493 editorNode : this . props . responseEditor
463494 } ;
464495 }
0 commit comments