// @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 Flex from 'components/Flex'; import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu'; @observer class CollectionMenu extends Component { props: { label?: React$Element, onOpen?: () => void, onClose?: () => void, onImport?: () => 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, onOpen, onClose, onImport } = this.props; const { allowDelete } = collection; return ( } onOpen={onOpen} onClose={onClose} > {collection && New document Import document Edit } {allowDelete && Delete} ); } } const MoreIcon = styled(Icon)` width: 22px; `; export default inject('ui')(CollectionMenu);