1 import { ContextSeparator, useConfirmActionModal } from '@proton/components';
2 import { isPreviewAvailable } from '@proton/shared/lib/helpers/preview';
4 import { useSharedWithMeActions } from '../../../store';
5 import { useOpenInDocs } from '../../../store/_documents';
6 import type { ContextMenuProps } from '../../FileBrowser';
7 import { useDetailsModal } from '../../modals/DetailsModal';
8 import { useFilesDetailsModal } from '../../modals/FilesDetailsModal';
9 import { DetailsButton, DownloadButton, OpenInDocsButton, PreviewButton } from '../ContextMenu';
10 import { ItemContextMenu } from '../ContextMenu/ItemContextMenu';
11 import { AcceptButton } from './ContextMenuButtons/AcceptButton';
12 import { DeclineButton } from './ContextMenuButtons/DeclineButton';
13 import { OpenBookmarkButton } from './ContextMenuButtons/OpenBookmarkButton';
14 import { RemoveBookmarkButton } from './ContextMenuButtons/RemoveBookmarkButton';
15 import { RemoveMeButton } from './ContextMenuButtons/RemoveMeButton';
16 import type { SharedWithMeItem } from './SharedWithMe';
18 export function SharedWithMeContextMenu({
25 }: ContextMenuProps & {
26 selectedBrowserItems: SharedWithMeItem[];
28 const selectedBrowserItem = selectedBrowserItems.at(0);
29 const isOnlyOneItem = selectedBrowserItems.length === 1 && !!selectedBrowserItem;
30 const isOnlyOneFileItem = isOnlyOneItem && selectedBrowserItem.isFile;
31 const hasPreviewAvailable =
33 selectedBrowserItem.isFile &&
34 selectedBrowserItem.mimeType &&
35 isPreviewAvailable(selectedBrowserItem.mimeType, selectedBrowserItem.size);
37 const [detailsModal, showDetailsModal] = useDetailsModal();
38 const [filesDetailsModal, showFilesDetailsModal] = useFilesDetailsModal();
39 const { showOpenInDocs } = useOpenInDocs(selectedBrowserItem);
40 const { removeMe } = useSharedWithMeActions();
41 const [confirmModal, showConfirmModal] = useConfirmActionModal();
45 <ItemContextMenu isOpen={isOpen} open={open} close={close} position={position} anchorRef={anchorRef}>
46 {selectedBrowserItem && !selectedBrowserItem.isInvitation && !selectedBrowserItem.isBookmark && (
48 {hasPreviewAvailable && (
50 shareId={selectedBrowserItem.rootShareId}
51 linkId={selectedBrowserItem.linkId}
55 {isOnlyOneFileItem && showOpenInDocs && (
56 <OpenInDocsButton selectedBrowserItem={selectedBrowserItem} close={close} />
58 <DownloadButton selectedBrowserItems={selectedBrowserItems} close={close} />
60 selectedBrowserItems={selectedBrowserItems}
61 showDetailsModal={showDetailsModal}
62 showFilesDetailsModal={showFilesDetailsModal}
65 {!!selectedBrowserItem && (
69 rootShareId={selectedBrowserItem.rootShareId}
71 showConfirmModal={showConfirmModal}
78 {selectedBrowserItem?.isBookmark && selectedBrowserItem.bookmarkDetails && (
81 token={selectedBrowserItem.bookmarkDetails.token}
82 urlPassword={selectedBrowserItem.bookmarkDetails.urlPassword}
86 token={selectedBrowserItem.bookmarkDetails.token}
87 linkId={selectedBrowserItem.linkId}
88 showConfirmModal={showConfirmModal}
93 {selectedBrowserItem?.invitationDetails && (
96 invitationId={selectedBrowserItem.invitationDetails.invitation.invitationId}
100 invitationId={selectedBrowserItem.invitationDetails.invitation.invitationId}
101 showConfirmModal={showConfirmModal}