// @flow import React, { Component } from 'react'; import { inject, observer } from 'mobx-react'; import styled from 'styled-components'; import Collection from 'models/Collection'; import UiStore from 'stores/UiStore'; import Icon from 'components/Icon'; import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu'; @observer class CollectionMenu extends Component { props: { label?: React$Element, onShow?: () => void, onClose?: () => void, history: Object, ui: UiStore, collection: Collection, }; onNewDocument = () => { const { collection, history } = this.props; history.push(`${collection.url}/new`); }; onEdit = () => { const { collection } = this.props; this.props.ui.setActiveModal('collection-edit', { collection }); }; onDelete = () => { const { collection } = this.props; this.props.ui.setActiveModal('collection-delete', { collection }); }; render() { const { collection, label, onShow, onClose } = this.props; const { allowDelete } = collection; return ( } onShow={onShow} onClose={onClose} > {collection && New document } {collection && Edit} {allowDelete && Delete} ); } } const MoreIcon = styled(Icon)` width: 22px; `; export default inject('ui')(CollectionMenu);