import React, {PropTypes, Component} from 'react'; import {Tab, Tabs, TabList, TabPanel} from 'react-tabs'; import ResponsePaneHeader from './ResponsePaneHeader' import PreviewModeDropdown from './dropdowns/PreviewModeDropdown'; import ResponseViewer from './viewers/ResponseViewer'; import ResponseHeadersViewer from './viewers/ResponseHeadersViewer'; import ResponseCookiesViewer from './viewers/ResponseCookiesViewer'; import {getPreviewModeName} from '../lib/previewModes'; import {PREVIEW_MODE_SOURCE} from '../lib/previewModes'; import {REQUEST_TIME_TO_SHOW_COUNTER} from '../lib/constants'; import {MOD_SYM} from '../lib/constants'; import {trackEvent} from '../lib/analytics'; class ResponsePane extends Component { render () { const { response, request, previewMode, updatePreviewMode, loadingRequests, editorLineWrapping, editorFontSize, showCookiesModal } = this.props; const loadStartTime = loadingRequests[request ? request._id : '__NONE__']; let timer = null; if (loadStartTime) { // Set a timer to update the UI again soon // TODO: Move this into a child component so we don't rerender too much setTimeout(() => { this.forceUpdate(); }, 100); // NOTE: We subtract 200ms because the request has some time padding on either end 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 (!request) { return (
) } if (!response) { return (
{timer}
Send Request {MOD_SYM}Enter
Focus Url Bar {MOD_SYM}L
Manage Cookies {MOD_SYM}K
Edit Environments {MOD_SYM}E
) } const cookieHeaders = response.headers.filter(h => h.name.toLowerCase() === 'set-cookie'); return (
{timer}
{!response ? null : ( )}
{response.error ? ( ) : ( )}
) } } ResponsePane.propTypes = { // Functions updatePreviewMode: PropTypes.func.isRequired, showCookiesModal: PropTypes.func.isRequired, // Required previewMode: PropTypes.string.isRequired, loadingRequests: PropTypes.object.isRequired, editorFontSize: PropTypes.number.isRequired, editorLineWrapping: PropTypes.bool.isRequired, // Other response: PropTypes.object, request: PropTypes.object }; export default ResponsePane;