1 import { useMemo } from 'react';
3 import { ContextSeparator } from '@proton/components';
4 import { getCanAdmin } from '@proton/shared/lib/drive/permissions';
6 import type { DriveFileRevision } from '../../store';
7 import type { ContextMenuProps } from '../FileBrowser';
8 import { ItemContextMenu } from '../sections/ContextMenu/ItemContextMenu';
11 RevisionDetailsButton,
12 RevisionDownloadButton,
13 RevisionPreviewButton,
14 RevisionRestoreButton,
15 } from './ContextMenuButtons';
16 import { useRevisionsProvider } from './RevisionsProvider';
18 export function RevisionsItemContextMenu({
26 }: ContextMenuProps & {
27 revision: DriveFileRevision;
38 } = useRevisionsProvider();
39 const isAdmin = useMemo(() => getCanAdmin(permissions), [permissions]);
42 <ItemContextMenu isOpen={isOpen} open={open} close={close} position={position} anchorRef={anchorRef}>
43 {hasPreviewAvailable ? (
44 <RevisionPreviewButton
46 openRevisionPreview={openRevisionPreview}
50 <RevisionDownloadButton revision={revision} downloadRevision={downloadRevision} close={close} />
51 <RevisionDetailsButton revision={revision} openRevisionDetails={openRevisionDetails} close={close} />
56 <ItemContextMenu isOpen={isOpen} open={open} close={close} position={position} anchorRef={anchorRef}>
57 {hasPreviewAvailable && (
59 <RevisionPreviewButton
61 openRevisionPreview={openRevisionPreview}
67 <RevisionRestoreButton restoreRevision={restoreRevision} revision={revision} close={close} />
68 <RevisionDownloadButton revision={revision} downloadRevision={downloadRevision} close={close} />
70 <RevisionDetailsButton revision={revision} openRevisionDetails={openRevisionDetails} close={close} />
75 <RevisionDeleteButton deleteRevision={deleteRevision} revision={revision} close={close} />