2016-04-29 04:57:03 +00:00
|
|
|
import React, {PropTypes} from 'react'
|
2016-04-26 07:29:24 +00:00
|
|
|
import {Tab, Tabs, TabList, TabPanel} from 'react-tabs'
|
|
|
|
|
2016-06-15 03:20:05 +00:00
|
|
|
import StatusTag from './StatusTag'
|
|
|
|
import SizeTag from './SizeTag'
|
|
|
|
import TimeTag from './TimeTag'
|
2016-04-30 05:01:57 +00:00
|
|
|
import PreviewModeDropdown from '../components/PreviewModeDropdown'
|
|
|
|
import ResponseViewer from '../components/ResponseViewer'
|
|
|
|
import {getPreviewModeName} from '../lib/previewModes'
|
2016-04-26 07:29:24 +00:00
|
|
|
|
2016-04-30 05:01:57 +00:00
|
|
|
const ResponsePane = ({response, previewMode, updatePreviewMode}) => {
|
2016-04-29 04:57:03 +00:00
|
|
|
if (!response) {
|
2016-04-26 07:29:24 +00:00
|
|
|
return (
|
2016-05-01 19:56:30 +00:00
|
|
|
<section className="response-pane pane">
|
|
|
|
<header className="pane__header"></header>
|
|
|
|
<div className="pane__body pane__body--placeholder">
|
|
|
|
<h1>Nothing Yet...</h1>
|
|
|
|
<p>Click the <em>Send</em> button to trigger a request</p>
|
2016-04-26 07:29:24 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
)
|
|
|
|
}
|
2016-04-29 04:57:03 +00:00
|
|
|
|
|
|
|
return (
|
2016-05-01 19:56:30 +00:00
|
|
|
<section className="response-pane pane">
|
|
|
|
<header className="pane__header">
|
|
|
|
{!response ? null : (
|
|
|
|
<div>
|
|
|
|
<StatusTag
|
|
|
|
statusCode={response.statusCode}
|
|
|
|
statusMessage={response.statusMessage}
|
|
|
|
/>
|
|
|
|
<TimeTag milliseconds={response.millis}/>
|
|
|
|
<SizeTag bytes={response.bytes}/>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</header>
|
|
|
|
<Tabs className="pane__body">
|
|
|
|
<TabList>
|
|
|
|
<Tab>
|
|
|
|
<button>{getPreviewModeName(previewMode)}</button>
|
|
|
|
<PreviewModeDropdown
|
2016-04-30 05:01:57 +00:00
|
|
|
previewMode={previewMode}
|
2016-05-01 19:56:30 +00:00
|
|
|
updatePreviewMode={updatePreviewMode}
|
2016-04-30 05:01:57 +00:00
|
|
|
/>
|
2016-05-01 19:56:30 +00:00
|
|
|
</Tab>
|
|
|
|
<Tab><button>Headers</button></Tab>
|
|
|
|
</TabList>
|
|
|
|
<TabPanel>
|
|
|
|
<ResponseViewer
|
|
|
|
contentType={response.contentType}
|
|
|
|
previewMode={previewMode}
|
|
|
|
body={response.body}
|
|
|
|
/>
|
|
|
|
</TabPanel>
|
|
|
|
<TabPanel className="scrollable pad">
|
|
|
|
<table className="wide">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Value</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{response.headers.map((h, i) => (
|
|
|
|
<tr className="selectable" key={i}>
|
|
|
|
<td>{h.name}</td>
|
|
|
|
<td>{h.value}</td>
|
|
|
|
</tr>
|
|
|
|
))}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</TabPanel>
|
|
|
|
</Tabs>
|
2016-04-29 04:57:03 +00:00
|
|
|
</section>
|
|
|
|
)
|
|
|
|
};
|
2016-04-26 07:29:24 +00:00
|
|
|
|
|
|
|
ResponsePane.propTypes = {
|
2016-04-30 05:01:57 +00:00
|
|
|
// Functions
|
|
|
|
updatePreviewMode: PropTypes.func.isRequired,
|
|
|
|
|
|
|
|
// Required
|
|
|
|
previewMode: PropTypes.string.isRequired,
|
|
|
|
|
|
|
|
// Other
|
2016-04-26 07:29:24 +00:00
|
|
|
response: PropTypes.object
|
2016-04-30 05:01:57 +00:00
|
|
|
|
2016-04-26 07:29:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default ResponsePane;
|