insomnia/app/ui/components/viewers/ResponseHeadersViewer.js
2016-11-25 16:49:38 -08:00

42 lines
994 B
JavaScript

import React, {PropTypes} from 'react';
import CopyButton from '../base/CopyButton';
const ResponseHeadersViewer = ({headers}) => {
const headersString = headers.map(
h => `${h.name}: ${h.value}`
).join('\n');
return (
<div>
<table className="wide table--striped">
<thead>
<tr>
<th>Name</th>
<th>Value</th>
</tr>
</thead>
<tbody>
{headers.map((h, i) => (
<tr className="selectable" key={i}>
<td style={{width: '50%'}} className="force-wrap">{h.name}</td>
<td style={{width: '50%'}} className="force-wrap">{h.value}</td>
</tr>
))}
</tbody>
</table>
<p className="pad-top">
<CopyButton
className="pull-right btn btn--clicky"
content={headersString}
/>
</p>
</div>
)
};
ResponseHeadersViewer.propTypes = {
headers: PropTypes.array.isRequired
};
export default ResponseHeadersViewer;