2017-08-10 01:56:27 +00:00
|
|
|
import React, {PureComponent} from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-03-08 05:52:17 +00:00
|
|
|
import CopyButton from '../base/copy-button';
|
2016-07-22 20:02:17 +00:00
|
|
|
|
2017-03-28 22:45:23 +00:00
|
|
|
class ResponseHeadersViewer extends PureComponent {
|
|
|
|
render () {
|
|
|
|
const {headers} = this.props;
|
2016-07-22 20:02:17 +00:00
|
|
|
|
2017-03-28 22:45:23 +00:00
|
|
|
const headersString = headers.map(
|
|
|
|
h => `${h.name}: ${h.value}`
|
|
|
|
).join('\n');
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<table className="table--fancy table--striped">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Value</th>
|
2016-07-27 20:17:57 +00:00
|
|
|
</tr>
|
2017-03-28 22:45:23 +00:00
|
|
|
</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>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2016-07-22 20:02:17 +00:00
|
|
|
|
|
|
|
ResponseHeadersViewer.propTypes = {
|
|
|
|
headers: PropTypes.array.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ResponseHeadersViewer;
|