insomnia/app/components/ResponseHeadersViewer.js

42 lines
907 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">
<thead>
<tr>
<th>Name</th>
<th>Value</th>
</tr>
</thead>
<tbody>
{headers.map((h, i) => (
<tr className="selectable" key={i}>
<td>{h.name}</td>
<td>{h.value}</td>
</tr>
))}
</tbody>
</table>
<p className="pad-top">
<CopyButton
className="pull-right btn btn--super-compact btn--outlined"
content={headersString}
/>
</p>
</div>
)
};
ResponseHeadersViewer.propTypes = {
headers: PropTypes.array.isRequired
};
export default ResponseHeadersViewer;