import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; import autobind from 'autobind-decorator'; import {Cookie} from 'tough-cookie'; @autobind class ResponseCookiesViewer extends PureComponent { renderRow (h, i) { const cookie = h ? Cookie.parse(h.value) : null; const blank = --; return ( {cookie ? cookie.key : blank} {cookie ? cookie.value : blank} ); } render () { const { headers, showCookiesModal, cookiesSent, cookiesStored } = this.props; const notifyNotStored = !cookiesStored && headers.length; let noticeMessage = null; if (!cookiesSent && notifyNotStored) { noticeMessage = 'sending and storing'; } else if (!cookiesSent) { noticeMessage = 'sending'; } else if (notifyNotStored) { noticeMessage = 'storing'; } return (
{noticeMessage && (

Automatic {noticeMessage} of cookies was disabled at the time this request was made

)} {!headers.length ? this.renderRow(null, -1) : headers.map(this.renderRow)}
Name Value

); } } ResponseCookiesViewer.propTypes = { showCookiesModal: PropTypes.func.isRequired, cookiesSent: PropTypes.bool.isRequired, cookiesStored: PropTypes.bool.isRequired, headers: PropTypes.array.isRequired, handleShowRequestSettings: PropTypes.func.isRequired }; export default ResponseCookiesViewer;