// @flow import { observer } from "mobx-react"; import { RestoreIcon, LinkIcon } from "outline-icons"; import * as React from "react"; import { useTranslation } from "react-i18next"; import { useHistory } from "react-router-dom"; import { useMenuState } from "reakit/Menu"; import Document from "models/Document"; import ContextMenu from "components/ContextMenu"; import MenuItem from "components/ContextMenu/MenuItem"; import OverflowMenuButton from "components/ContextMenu/OverflowMenuButton"; import Separator from "components/ContextMenu/Separator"; import CopyToClipboard from "components/CopyToClipboard"; import MenuIconWrapper from "components/MenuIconWrapper"; import useCurrentTeam from "hooks/useCurrentTeam"; import useToasts from "hooks/useToasts"; import { documentHistoryUrl } from "utils/routeHelpers"; type Props = {| document: Document, revisionId: string, className?: string, |}; function RevisionMenu({ document, revisionId, className }: Props) { const { showToast } = useToasts(); const team = useCurrentTeam(); const menu = useMenuState({ modal: true }); const { t } = useTranslation(); const history = useHistory(); const handleRestore = React.useCallback( async (ev: SyntheticEvent<>) => { ev.preventDefault(); await document.restore({ revisionId }); showToast(t("Document restored"), { type: "success" }); history.push(document.url); }, [history, showToast, t, document, revisionId] ); const handleCopy = React.useCallback(() => { showToast(t("Link copied"), { type: "info" }); }, [showToast, t]); const url = `${window.location.origin}${documentHistoryUrl( document, revisionId )}`; return ( <> {t("Restore version")} {t("Copy link")} ); } export default observer(RevisionMenu);