import PropTypes from 'prop-types'; import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { NavLink } from 'react-router-dom'; import { searchCollections } from 'Actions/collections'; import { getCollectionUrl } from 'Lib/urlHelper'; import { Icon } from 'netlify-cms-ui-default'; export default class Collection extends React.Component { static propTypes = { collections: ImmutablePropTypes.orderedMap.isRequired, }; state = { query: this.props.searchTerm || '' }; renderLink = collection => { const collectionName = collection.get('name'); return ( {collection.get('label')} ); }; render() { const { collections } = this.props; const { query } = this.state; return (

Collections

this.setState({ query: e.target.value })} onKeyDown={e => e.key === 'Enter' && searchCollections(query)} placeholder="Search all" value={query} />
{collections.toList().map(this.renderLink)}
); } }