feat: Include more events in document history sidebar (#2334)

closes #2230
This commit is contained in:
Tom Moor
2021-08-05 18:03:55 -04:00
committed by GitHub
parent 57a2524fbd
commit 9db72217af
22 changed files with 600 additions and 369 deletions

View File

@ -5,7 +5,6 @@ import { useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";
import { useMenuState } from "reakit/Menu";
import Document from "models/Document";
import Revision from "models/Revision";
import ContextMenu from "components/ContextMenu";
import MenuItem from "components/ContextMenu/MenuItem";
import OverflowMenuButton from "components/ContextMenu/OverflowMenuButton";
@ -16,12 +15,11 @@ import { documentHistoryUrl } from "utils/routeHelpers";
type Props = {|
document: Document,
revision: Revision,
iconColor?: string,
revisionId: string,
className?: string,
|};
function RevisionMenu({ document, revision, className, iconColor }: Props) {
function RevisionMenu({ document, revisionId, className }: Props) {
const { showToast } = useToasts();
const menu = useMenuState({ modal: true });
const { t } = useTranslation();
@ -30,11 +28,11 @@ function RevisionMenu({ document, revision, className, iconColor }: Props) {
const handleRestore = React.useCallback(
async (ev: SyntheticEvent<>) => {
ev.preventDefault();
await document.restore({ revisionId: revision.id });
await document.restore({ revisionId });
showToast(t("Document restored"), { type: "success" });
history.push(document.url);
},
[history, showToast, t, document, revision]
[history, showToast, t, document, revisionId]
);
const handleCopy = React.useCallback(() => {
@ -43,14 +41,14 @@ function RevisionMenu({ document, revision, className, iconColor }: Props) {
const url = `${window.location.origin}${documentHistoryUrl(
document,
revision.id
revisionId
)}`;
return (
<>
<OverflowMenuButton
className={className}
iconColor={iconColor}
iconColor="currentColor"
aria-label={t("Show menu")}
{...menu}
/>