2020-11-26 09:22:30 -05:00
|
|
|
import { FileTreeMainProvider } from '../contexts/file-tree-main'
|
|
|
|
import { FileTreeActionableProvider } from '../contexts/file-tree-actionable'
|
|
|
|
import { FileTreeSelectableProvider } from '../contexts/file-tree-selectable'
|
|
|
|
import { FileTreeDraggableProvider } from '../contexts/file-tree-draggable'
|
2024-01-26 04:23:48 -05:00
|
|
|
import { FC } from 'react'
|
2020-11-26 09:22:30 -05:00
|
|
|
|
|
|
|
// renders all the contexts needed for the file tree:
|
|
|
|
// FileTreeMain: generic store
|
|
|
|
// FileTreeActionable: global UI state for actions (rename, delete, etc.)
|
|
|
|
// FileTreeMutable: provides entities mutation operations
|
|
|
|
// FileTreeSelectable: handles selection and multi-selection
|
2024-01-26 04:23:48 -05:00
|
|
|
const FileTreeContext: FC<{
|
|
|
|
refProviders: Record<string, boolean>
|
|
|
|
setRefProviderEnabled: (provider: string, value: boolean) => void
|
|
|
|
setStartedFreeTrial: (value: boolean) => void
|
|
|
|
onSelect: () => void
|
2024-02-05 06:44:05 -05:00
|
|
|
fileTreeContainer?: HTMLDivElement
|
2024-01-26 04:23:48 -05:00
|
|
|
}> = ({
|
2021-03-18 05:52:36 -04:00
|
|
|
refProviders,
|
|
|
|
setRefProviderEnabled,
|
|
|
|
setStartedFreeTrial,
|
2020-11-26 09:22:30 -05:00
|
|
|
onSelect,
|
2024-02-05 06:44:05 -05:00
|
|
|
fileTreeContainer,
|
2021-04-27 03:52:58 -04:00
|
|
|
children,
|
2024-01-26 04:23:48 -05:00
|
|
|
}) => {
|
2020-11-26 09:22:30 -05:00
|
|
|
return (
|
|
|
|
<FileTreeMainProvider
|
2021-03-18 05:52:36 -04:00
|
|
|
refProviders={refProviders}
|
|
|
|
setRefProviderEnabled={setRefProviderEnabled}
|
|
|
|
setStartedFreeTrial={setStartedFreeTrial}
|
2020-11-26 09:22:30 -05:00
|
|
|
>
|
2023-08-18 05:26:22 -04:00
|
|
|
<FileTreeSelectableProvider onSelect={onSelect}>
|
2024-07-15 05:36:39 -04:00
|
|
|
<FileTreeActionableProvider>
|
2024-02-05 06:44:05 -05:00
|
|
|
<FileTreeDraggableProvider fileTreeContainer={fileTreeContainer}>
|
|
|
|
{children}
|
|
|
|
</FileTreeDraggableProvider>
|
2022-01-10 10:47:01 -05:00
|
|
|
</FileTreeActionableProvider>
|
|
|
|
</FileTreeSelectableProvider>
|
2020-11-26 09:22:30 -05:00
|
|
|
</FileTreeMainProvider>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FileTreeContext
|