// @flow import * as React from 'react'; import { withRouter } from 'react-router-dom'; import { inject, observer } from 'mobx-react'; import { MoreIcon } from 'outline-icons'; import Document from 'models/Document'; import UiStore from 'stores/UiStore'; import { documentMoveUrl } from 'utils/routeHelpers'; import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu'; type Props = { ui: UiStore, label?: React.Node, history: Object, document: Document, className: string, showPrint?: boolean, }; @observer class DocumentMenu extends React.Component { handleNewChild = (ev: SyntheticEvent<*>) => { const { history, document } = this.props; history.push( `${document.collection.url}/new?parentDocument=${document.id}` ); }; handleDelete = (ev: SyntheticEvent<*>) => { const { document } = this.props; this.props.ui.setActiveModal('document-delete', { document }); }; handleMove = (ev: SyntheticEvent<*>) => { this.props.history.push(documentMoveUrl(this.props.document)); }; handleDuplicate = async (ev: SyntheticEvent<*>) => { this.props.document.duplicate(); }; handlePin = (ev: SyntheticEvent<*>) => { this.props.document.pin(); }; handleUnpin = (ev: SyntheticEvent<*>) => { this.props.document.unpin(); }; handleStar = (ev: SyntheticEvent<*>) => { this.props.document.star(); }; handleUnstar = (ev: SyntheticEvent<*>) => { this.props.document.unstar(); }; handleExport = (ev: SyntheticEvent<*>) => { this.props.document.download(); }; handleShareLink = async (ev: SyntheticEvent<*>) => { const { document } = this.props; if (!document.shareUrl) await document.share(); this.props.ui.setActiveModal('document-share', { document }); }; render() { const { document, label, className, showPrint } = this.props; const isDraft = !document.publishedAt; return ( } className={className}> {!isDraft && ( {document.pinned ? ( Unpin ) : ( Pin )} {document.starred ? ( Unstar ) : ( Star )} Share link…
New child document Duplicate Move…
)} Delete…
Download {showPrint && ( Print )}
); } } export default withRouter(inject('ui')(DocumentMenu));