mirror of
https://github.com/Kong/insomnia
synced 2024-11-12 17:26:32 +00:00
549ce23ce8
* All projects into monorepo * Update CI * More CI updates * Extracted a bunch of things into packages * Publish - insomnia-plugin-base64@1.0.1 - insomnia-plugin-default-headers@1.0.2 - insomnia-plugin-file@1.0.1 - insomnia-plugin-hash@1.0.1 - insomnia-plugin-now@1.0.1 - insomnia-plugin-request@1.0.1 - insomnia-plugin-response@1.0.1 - insomnia-plugin-uuid@1.0.1 - insomnia-cookies@0.0.2 - insomnia-importers@1.5.2 - insomnia-prettify@0.0.3 - insomnia-url@0.0.2 - insomnia-xpath@0.0.2 * A bunch of small fixes * Improved build script * Fixed * Merge dangling files * Usability refactor * Handle duplicate plugin names
85 lines
2.2 KiB
JavaScript
85 lines
2.2 KiB
JavaScript
import React, {PureComponent} from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import autobind from 'autobind-decorator';
|
|
import {Cookie} from 'tough-cookie';
|
|
|
|
@autobind
|
|
class ResponseCookiesViewer extends PureComponent {
|
|
renderRow (h, i) {
|
|
let cookie = null;
|
|
try {
|
|
cookie = h ? Cookie.parse(h.value || '') : null;
|
|
} catch (err) {
|
|
console.warn('Failed to parse set-cookie header', h);
|
|
}
|
|
|
|
const blank = <span className="super-duper-faint italic">--</span>;
|
|
return (
|
|
<tr className="selectable" key={i}>
|
|
<td>{cookie ? cookie.key : blank}</td>
|
|
<td className="force-wrap">{cookie ? cookie.value : blank}</td>
|
|
</tr>
|
|
);
|
|
}
|
|
|
|
render () {
|
|
const {
|
|
headers,
|
|
showCookiesModal,
|
|
cookiesSent,
|
|
cookiesStored
|
|
} = this.props;
|
|
|
|
const notifyNotStored = !cookiesStored && headers.length;
|
|
|
|
let noticeMessage = null;
|
|
if (!cookiesSent && notifyNotStored) {
|
|
noticeMessage = 'sending and storing';
|
|
} else if (!cookiesSent) {
|
|
noticeMessage = 'sending';
|
|
} else if (notifyNotStored) {
|
|
noticeMessage = 'storing';
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
{noticeMessage && (
|
|
<div className="notice info margin-bottom no-margin-top">
|
|
<p>
|
|
Automatic {noticeMessage} of cookies was disabled at the time this request was made
|
|
</p>
|
|
</div>
|
|
)}
|
|
|
|
<table className="table--fancy table--striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Value</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{!headers.length ? this.renderRow(null, -1) : headers.map(this.renderRow)}
|
|
</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,
|
|
cookiesSent: PropTypes.bool.isRequired,
|
|
cookiesStored: PropTypes.bool.isRequired,
|
|
headers: PropTypes.array.isRequired,
|
|
handleShowRequestSettings: PropTypes.func.isRequired
|
|
};
|
|
|
|
export default ResponseCookiesViewer;
|