// @flow import React, { Component } from 'react'; import { withRouter } from 'react-router-dom'; import { inject, observer } from 'mobx-react'; import Document from 'models/Document'; import UiStore from 'stores/UiStore'; import MoreIcon from 'components/Icon/MoreIcon'; import { documentMoveUrl } from 'utils/routeHelpers'; import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu'; @observer class DocumentMenu extends Component { props: { ui: UiStore, label?: React$Element, history: Object, document: Document, }; handleNewChild = () => { const { history, document } = this.props; history.push( `${document.collection.url}/new?parentDocument=${document.id}` ); }; handleDelete = () => { const { document } = this.props; this.props.ui.setActiveModal('document-delete', { document }); }; handleMove = () => { this.props.history.push(documentMoveUrl(this.props.document)); }; handleStar = () => { this.props.document.star(); }; handleUnstar = () => { this.props.document.unstar(); }; handleExport = () => { this.props.document.download(); }; render() { const { document, label } = this.props; return ( }> {document.starred ? ( Unstar ) : ( Star )} New child Download Print Move… Delete… ); } } export default withRouter(inject('ui')(DocumentMenu));