2023-08-18 05:26:22 -04:00
|
|
|
import { useFileTreeSelectable } from '../contexts/file-tree-selectable'
|
2024-01-26 04:23:48 -05:00
|
|
|
import { FC, useCallback } from 'react'
|
2023-08-18 05:26:22 -04:00
|
|
|
|
2024-01-26 04:23:48 -05:00
|
|
|
const FileTreeInner: FC = ({ children }) => {
|
2023-12-05 04:38:07 -05:00
|
|
|
const { setIsRootFolderSelected, selectedEntityIds, select } =
|
|
|
|
useFileTreeSelectable()
|
2023-08-18 05:26:22 -04:00
|
|
|
|
2023-10-12 04:38:31 -04:00
|
|
|
const handleFileTreeClick = useCallback(() => {
|
2023-08-18 05:26:22 -04:00
|
|
|
setIsRootFolderSelected(true)
|
2023-12-05 04:38:07 -05:00
|
|
|
if (selectedEntityIds.size > 1) {
|
|
|
|
select([])
|
|
|
|
}
|
|
|
|
}, [select, selectedEntityIds.size, setIsRootFolderSelected])
|
2023-08-18 05:26:22 -04:00
|
|
|
|
|
|
|
return (
|
|
|
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
|
|
<div
|
|
|
|
className="file-tree-inner"
|
|
|
|
onClick={handleFileTreeClick}
|
|
|
|
data-testid="file-tree-inner"
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FileTreeInner
|