Merge branch 'INDA-330-pii-update' into 'main'
[ProtonMail-WebClient.git] / applications / drive / src / app / components / sections / SharedLinks / ShareFileSidebarButton.tsx
blob4d080c877140c84a5bbf8b09b3bb05cef1ec133a
1 import { c } from 'ttag';
3 import { FloatingButton, Icon, SidebarPrimaryButton } from '@proton/components';
5 import useActiveShare from '../../../hooks/drive/useActiveShare';
6 import { useFileSharingModal } from '../../modals/SelectLinkToShareModal/SelectLinkToShareModal';
7 import { useLinkSharingModal } from '../../modals/ShareLinkModal/ShareLinkModal';
9 interface Props {
10     mobileVersion?: boolean;
13 const ShareFileSidebarButton = ({ mobileVersion }: Props) => {
14     const { activeShareId } = useActiveShare();
15     const [fileSharingModal, showFileSharingModal] = useFileSharingModal();
16     const [linkSharingModal, showLinkSharingModal] = useLinkSharingModal();
18     const onShareFile = () => {
19         if (activeShareId) {
20             void showFileSharingModal({ shareId: activeShareId, showLinkSharingModal });
21         }
22     };
24     return (
25         <>
26             {mobileVersion ? (
27                 <FloatingButton onClick={onShareFile} title={c('Action').t`Share item`} disabled={!activeShareId}>
28                     <Icon size={6} name="link" className="m-auto" />
29                 </FloatingButton>
30             ) : (
31                 <SidebarPrimaryButton className="hidden md:flex" disabled={!activeShareId} onClick={onShareFile}>
32                     {c('Action').t`Share item`}
33                 </SidebarPrimaryButton>
34             )}
35             {fileSharingModal}
36             {linkSharingModal}
37         </>
38     );
41 export default ShareFileSidebarButton;