@@ -2,11 +2,12 @@ import * as React from "react";
22import { inject , observer } from "mobx-react" ;
33import * as portals from 'react-reverse-portal' ;
44
5- import { styled } from '../../styles' ;
5+ import { css , styled } from '../../styles' ;
66import { HttpExchange } from "../../types" ;
77
88import { UiStore } from '../../model/ui/ui-store' ;
99import { AccountStore } from '../../model/account/account-store' ;
10+ import { SuccessfulExchange } from "../../model/http/exchange" ;
1011
1112import { ContainerSizedEditor } from '../editor/base-editor' ;
1213import { LoadingCard } from '../common/loading-card' ;
@@ -16,10 +17,19 @@ import { ResponseStatusSection } from './sent-response-status';
1617import { SentResponseHeaderSection } from './sent-response-headers' ;
1718import { SentResponseBodyCard } from './sent-response-body' ;
1819
19- const ResponsePaneContainer = styled . section `
20+ const ResponsePaneContainer = styled . section < {
21+ hasExpandedChild : boolean
22+ } > `
2023 display: flex;
2124 flex-direction: column;
2225 height: 100%;
26+
27+ ${ p => p . hasExpandedChild && css `
28+ > * {
29+ /* CollapsibleCard applies its own display property to override this for the expanded card */
30+ display : none;
31+ }
32+ ` }
2333` ;
2434
2535@inject ( 'uiStore' )
@@ -38,45 +48,58 @@ export class ResponsePane extends React.Component<{
3848 }
3949
4050 render ( ) {
41- const { exchange, uiStore, editorNode } = this . props ;
51+ const { exchange, uiStore } = this . props ;
4252 if ( ! exchange ) return null ;
4353
44- if ( exchange . isSuccessfulExchange ( ) ) {
45- const response = exchange . response ;
46- return < ResponsePaneContainer >
47- < ResponseStatusSection
48- exchange = { exchange }
49- theme = { uiStore ! . theme }
50- />
51- < SentResponseHeaderSection
52- requestUrl = { exchange . request . parsedUrl }
53- headers = { response . rawHeaders }
54- { ...this . cardProps . responseHeaders }
55- />
56- < SentResponseBodyCard
57- { ...this . cardProps . responseBody }
58- isPaidUser = { this . props . accountStore ! . isPaidUser }
59- url = { exchange . request . url }
60- message = { response }
61- editorNode = { editorNode }
62- />
63- </ ResponsePaneContainer > ;
64- } else if ( exchange . isCompletedExchange ( ) ) {
65- return < ResponsePaneContainer >
66- < HttpAbortedResponseCard
67- cardProps = { this . cardProps . responseHeaders }
68- exchange = { exchange }
69- />
70- </ ResponsePaneContainer >
71- } else {
72- return < ResponsePaneContainer >
73- < LoadingCard { ...this . cardProps . responseHeaders } >
74- < header >
75- < h1 > Response...</ h1 >
76- </ header >
77- </ LoadingCard >
78- </ ResponsePaneContainer > ;
79- }
54+ return < ResponsePaneContainer hasExpandedChild = { ! ! uiStore ?. expandedSentResponseCard } >
55+ {
56+ exchange . isSuccessfulExchange ( )
57+ ? this . renderSuccessfulResponse ( exchange )
58+ : exchange . isCompletedExchange ( )
59+ ? this . renderAbortedResponse ( exchange )
60+ : this . renderInProgressResponse ( )
61+ }
62+ </ ResponsePaneContainer > ;
63+ }
64+
65+ renderSuccessfulResponse ( exchange : SuccessfulExchange ) {
66+ const { uiStore, editorNode } = this . props ;
67+ const response = exchange . response ;
68+
69+ return < >
70+ < ResponseStatusSection
71+ exchange = { exchange }
72+ theme = { uiStore ! . theme }
73+ />
74+ < SentResponseHeaderSection
75+ { ...this . cardProps . responseHeaders }
76+ requestUrl = { exchange . request . parsedUrl }
77+ headers = { response . rawHeaders }
78+ />
79+ < SentResponseBodyCard
80+ { ...this . cardProps . responseBody }
81+ isPaidUser = { this . props . accountStore ! . isPaidUser }
82+ url = { exchange . request . url }
83+ message = { response }
84+ editorNode = { editorNode }
85+ />
86+ </ > ;
87+
88+ }
89+
90+ renderAbortedResponse ( exchange : HttpExchange ) {
91+ return < HttpAbortedResponseCard
92+ cardProps = { this . cardProps . responseHeaders }
93+ exchange = { exchange }
94+ /> ;
95+ }
96+
97+ renderInProgressResponse ( ) {
98+ return < LoadingCard { ...this . cardProps . responseHeaders } >
99+ < header >
100+ < h1 > Response...</ h1 >
101+ </ header >
102+ </ LoadingCard > ;
80103 }
81104
82105}
0 commit comments