import React, {PropTypes, Component} from 'react' import {Tab, Tabs, TabList, TabPanel} from 'react-tabs' import StatusTag from './StatusTag' import SizeTag from './SizeTag' import TimeTag from './TimeTag' import PreviewModeDropdown from '../components/PreviewModeDropdown' import ResponseViewer from '../components/ResponseViewer' import {getPreviewModeName} from '../lib/previewModes' import {PREVIEW_MODE_SOURCE} from '../lib/previewModes' import {REQUEST_TIME_TO_SHOW_COUNTER} from '../lib/constants' class ResponsePane extends Component { render () { const { response, request, previewMode, updatePreviewMode, loadingRequests } = this.props; const loadStartTime = loadingRequests[request._id]; let timer = null; if (loadStartTime) { // Set a timer to update the UI again soon setTimeout(() => { this.forceUpdate(); }, 30); const elapsedTime = Math.round((Date.now() - loadStartTime - 200) / 100) / 10; timer = (
{elapsedTime > REQUEST_TIME_TO_SHOW_COUNTER ? (

{elapsedTime} seconds...

) : (

Loading...

)} {false && elapsedTime > REQUEST_TIME_TO_SHOW_COUNTER ? ( // TODO: implement cancel requests ) : null}
) } if (!response) { return (
{timer}

Nothing Yet...

Click the Send button to trigger a request

) } return (
{timer}
{!response ? null : (
)}
{response.error ? ( ) : ( )} {response.headers.map((h, i) => ( ))}
Name Value
{h.name} {h.value}
) } } ResponsePane.propTypes = { // Functions updatePreviewMode: PropTypes.func.isRequired, // Required previewMode: PropTypes.string.isRequired, loadingRequests: PropTypes.object.isRequired, request: PropTypes.object.isRequired, // Other response: PropTypes.object, }; export default ResponsePane;