insomnia/app/ui/components/viewers/response-cookies-viewer.js
Gregory Schier 8452e8b777 Some eslint refactoring (#109)
* Fixed duplication kve bug

* Some changes

* Add proptypes linting

* Fixed proptypes even more

* Filename linting
2017-03-07 21:52:17 -08:00

52 lines
1.2 KiB
JavaScript

import React, {PropTypes} from 'react';
import {Cookie} from 'tough-cookie';
const ResponseCookiesViewer = ({headers, showCookiesModal}) => {
if (!headers.length) {
// Don't do anything if no cookies
return (
<span className="faint">
No cookies returned
</span>
);
}
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);
return (
<tr className="selectable" key={i}>
<td>{cookie ? cookie.key : 'n/a'}</td>
<td className="force-wrap">{cookie ? cookie.value : 'malformed set-cookie header'}</td>
</tr>
);
})}
</tbody>
</table>
<p className="pad-top">
<button className="pull-right btn btn--clicky"
onClick={e => showCookiesModal()}>
Manage Cookies
</button>
</p>
</div>
);
};
ResponseCookiesViewer.propTypes = {
showCookiesModal: PropTypes.func.isRequired,
headers: PropTypes.array.isRequired
};
export default ResponseCookiesViewer;