<commit_before>import { useEffect } from 'react';

import { ContextMenu, ContextSeparator, isPreviewAvailable } from '@proton/components';
import { LinkType } from '@proton/shared/lib/interfaces/drive/link';
import { ItemContextMenuProps } from '@proton/shared/lib/interfaces/drive/fileBrowser';

import {
    DetailsButton,
    DownloadButton,
    CopyLinkButton,
    PreviewButton,
    RenameButton,
    ShareButton,
    ShareLinkButton,
} from '../ContextMenu';
import { MoveToFolderButton, MoveToTrashButton } from './ContextMenuButtons';
import useActiveShare from '../../../hooks/drive/useActiveShare';

const DriveItemContextMenu = ({
    item,
    selectedItems,
    shareId,
    anchorRef,
    isOpen,
    position,
    open,
    close,
}: ItemContextMenuProps) => {
    const { activeFolder: sourceFolder } = useActiveShare();

    const isOnlyOneItem = selectedItems.length === 1;
    const isOnlyOneFileItem = isOnlyOneItem && item.Type === LinkType.FILE;
    const hasPreviewAvailable = isOnlyOneFileItem && item.MIMEType && isPreviewAvailable(item.MIMEType, item.Size);
    const hasLink = isOnlyOneFileItem && item.ShareUrlShareID && !item.UrlsExpired && !item.Trashed

    useEffect(() => {
        if (position) {
            open();
        }
    }, [position]);

    return (
        <ContextMenu isOpen={isOpen} close={close} position={position} anchorRef={anchorRef}>
            {hasPreviewAvailable && <PreviewButton shareId={shareId} item={item} close={close} />}
            {hasPreviewAvailable && <ContextSeparator />}
            <DownloadButton shareId={shareId} items={selectedItems} close={close} />
            {isOnlyOneItem && <ShareButton shareId={shareId} item={item} close={close} />}
            {hasLink && (
                <CopyLinkButton shareId={item.ShareUrlShareID as string} close={close} />
            )}
            {isOnlyOneFileItem && <ShareLinkButton shareId={shareId} item={item} close={close} />}
            <ContextSeparator />
            {sourceFolder && <MoveToFolderButton sourceFolder={sourceFolder} items={selectedItems} close={close} />}
            {isOnlyOneItem && <RenameButton shareId={shareId} item={item} close={close} />}
            <DetailsButton shareId={shareId} items={selectedItems} close={close} />
            <ContextSeparator />
            {sourceFolder && <MoveToTrashButton sourceFolder={sourceFolder} items={selectedItems} close={close} />}
        </ContextMenu>
    );
};

export default DriveItemContextMenu;<commit_msg>Do not use scroll bar in context menu<commit_after>import { useEffect } from 'react';

import { ContextMenu, ContextSeparator, isPreviewAvailable } from '@proton/components';
import { LinkType } from '@proton/shared/lib/interfaces/drive/link';
import { ItemContextMenuProps } from '@proton/shared/lib/interfaces/drive/fileBrowser';

import {
    DetailsButton,
    DownloadButton,
    CopyLinkButton,
    PreviewButton,
    RenameButton,
    ShareButton,
    ShareLinkButton,
} from '../ContextMenu';
import { MoveToFolderButton, MoveToTrashButton } from './ContextMenuButtons';
import useActiveShare from '../../../hooks/drive/useActiveShare';

const DriveItemContextMenu = ({
    item,
    selectedItems,
    shareId,
    anchorRef,
    isOpen,
    position,
    open,
    close,
}: ItemContextMenuProps) => {
    const { activeFolder: sourceFolder } = useActiveShare();

    const isOnlyOneItem = selectedItems.length === 1;
    const isOnlyOneFileItem = isOnlyOneItem && item.Type === LinkType.FILE;
    const hasPreviewAvailable = isOnlyOneFileItem && item.MIMEType && isPreviewAvailable(item.MIMEType, item.Size);
    const hasLink = isOnlyOneFileItem && item.ShareUrlShareID && !item.UrlsExpired && !item.Trashed;

    useEffect(() => {
        if (position) {
            open();
        }
    }, [position]);

    return (
        <ContextMenu isOpen={isOpen} close={close} position={position} noMaxHeight anchorRef={anchorRef}>
            {hasPreviewAvailable && <PreviewButton shareId={shareId} item={item} close={close} />}
            {hasPreviewAvailable && <ContextSeparator />}
            <DownloadButton shareId={shareId} items={selectedItems} close={close} />
            {isOnlyOneItem && <ShareButton shareId={shareId} item={item} close={close} />}
            {hasLink && <CopyLinkButton shareId={item.ShareUrlShareID as string} close={close} />}
            {isOnlyOneFileItem && <ShareLinkButton shareId={shareId} item={item} close={close} />}
            <ContextSeparator />
            {sourceFolder && <MoveToFolderButton sourceFolder={sourceFolder} items={selectedItems} close={close} />}
            {isOnlyOneItem && <RenameButton shareId={shareId} item={item} close={close} />}
            <DetailsButton shareId={shareId} items={selectedItems} close={close} />
            <ContextSeparator />
            {sourceFolder && <MoveToTrashButton sourceFolder={sourceFolder} items={selectedItems} close={close} />}
        </ContextMenu>
    );
};

export default DriveItemContextMenu;
{'fraction_non_alphanumeric': 0.13119649611785786, 'fraction_numerical': 0.00039816842524387816, 'mean_word_length': 3.522052205220522, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6818999', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1391, 'n_words': 279}