// @flow import React from 'react'; import uuid from 'uuid'; import * as toughCookie from 'tough-cookie'; import autobind from 'autobind-decorator'; import { cookieToString } from 'insomnia-cookies'; import PromptButton from './base/prompt-button'; import RenderedText from './rendered-text'; import type { Cookie } from '../../models/cookie-jar'; import { Dropdown, DropdownButton, DropdownItem } from './base/dropdown/index'; type Props = { handleCookieAdd: Function, handleCookieDelete: Function, handleDeleteAll: Function, cookies: Array, newCookieDomainName: string, handleShowModifyCookieModal: Function, handleRender: Function, }; @autobind class CookieList extends React.PureComponent { _handleCookieAdd() { const newCookie: Cookie = { id: uuid.v4(), key: 'foo', value: 'bar', domain: this.props.newCookieDomainName, expires: null, path: '/', secure: false, httpOnly: false, }; this.props.handleCookieAdd(newCookie); } _handleDeleteCookie(cookie: Cookie) { this.props.handleCookieDelete(cookie); } render() { const { cookies, handleDeleteAll, handleShowModifyCookieModal, handleRender } = this.props; return (
{cookies.map((cookie, i) => { const cookieString = cookieToString(toughCookie.Cookie.fromJSON(cookie)); return ( ); })}
Domain Cookie Actions Add Cookie Delete All
{cookie.domain || ''} {cookieString || ''} {' '} this._handleDeleteCookie(cookie)} title="Delete cookie">
{cookies.length === 0 && (

I couldn't find any cookies for you.

)}
); } } export default CookieList;