2016-08-15 17:04:36 +00:00
|
|
|
import React, {PropTypes} from 'react';
|
|
|
|
import {Cookie} from 'tough-cookie';
|
|
|
|
|
|
|
|
const ResponseCookiesViewer = ({headers, showCookiesModal}) => {
|
|
|
|
if (!headers.length) {
|
|
|
|
// Don't do anything if no cookies
|
2016-09-21 00:18:18 +00:00
|
|
|
return (
|
|
|
|
<span className="faint">
|
|
|
|
No cookies returned
|
|
|
|
</span>
|
|
|
|
);
|
2016-08-15 17:04:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<table className="wide table--striped">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Value</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{headers.map((h, i) => {
|
|
|
|
const cookie = Cookie.parse(h.value);
|
2016-10-05 16:34:13 +00:00
|
|
|
|
2016-08-15 17:04:36 +00:00
|
|
|
return (
|
|
|
|
<tr className="selectable" key={i}>
|
2016-10-05 16:34:13 +00:00
|
|
|
<td>{cookie ? cookie.key : 'n/a'}</td>
|
|
|
|
<td className="force-wrap">{cookie ? cookie.value : 'malformed set-cookie header'}</td>
|
2016-08-15 17:04:36 +00:00
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<p className="pad-top">
|
2016-11-26 00:49:38 +00:00
|
|
|
<button className="pull-right btn btn--clicky"
|
2016-08-15 17:04:36 +00:00
|
|
|
onClick={e => showCookiesModal()}>
|
|
|
|
Manage Cookies
|
|
|
|
</button>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
};
|
|
|
|
|
|
|
|
ResponseCookiesViewer.propTypes = {
|
|
|
|
showCookiesModal: PropTypes.func.isRequired,
|
|
|
|
headers: PropTypes.array.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ResponseCookiesViewer;
|