2020-11-26 09:22:30 -05:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
|
|
|
import { FileTreeMainProvider } from '../contexts/file-tree-main'
|
|
|
|
import { FileTreeActionableProvider } from '../contexts/file-tree-actionable'
|
|
|
|
import { FileTreeMutableProvider } from '../contexts/file-tree-mutable'
|
|
|
|
import { FileTreeSelectableProvider } from '../contexts/file-tree-selectable'
|
|
|
|
import { FileTreeDraggableProvider } from '../contexts/file-tree-draggable'
|
|
|
|
|
|
|
|
// 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
|
|
|
|
function FileTreeContext({
|
|
|
|
projectId,
|
|
|
|
rootFolder,
|
|
|
|
hasWritePermissions,
|
2021-01-07 09:22:40 -05:00
|
|
|
rootDocId,
|
2021-03-24 06:06:56 -04:00
|
|
|
userHasFeature,
|
2021-03-18 05:52:36 -04:00
|
|
|
refProviders,
|
|
|
|
reindexReferences,
|
|
|
|
setRefProviderEnabled,
|
|
|
|
setStartedFreeTrial,
|
2020-11-26 09:22:30 -05:00
|
|
|
onSelect,
|
2021-04-27 03:52:58 -04:00
|
|
|
children,
|
2020-11-26 09:22:30 -05:00
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<FileTreeMainProvider
|
|
|
|
projectId={projectId}
|
|
|
|
hasWritePermissions={hasWritePermissions}
|
2021-03-24 06:06:56 -04:00
|
|
|
userHasFeature={userHasFeature}
|
2021-03-18 05:52:36 -04:00
|
|
|
refProviders={refProviders}
|
|
|
|
setRefProviderEnabled={setRefProviderEnabled}
|
|
|
|
setStartedFreeTrial={setStartedFreeTrial}
|
|
|
|
reindexReferences={reindexReferences}
|
2020-11-26 09:22:30 -05:00
|
|
|
>
|
2021-03-10 04:11:43 -05:00
|
|
|
<FileTreeMutableProvider rootFolder={rootFolder}>
|
|
|
|
<FileTreeSelectableProvider
|
|
|
|
hasWritePermissions={hasWritePermissions}
|
|
|
|
rootDocId={rootDocId}
|
|
|
|
onSelect={onSelect}
|
|
|
|
>
|
|
|
|
<FileTreeActionableProvider hasWritePermissions={hasWritePermissions}>
|
2020-11-26 09:22:30 -05:00
|
|
|
<FileTreeDraggableProvider>{children}</FileTreeDraggableProvider>
|
2021-03-10 04:11:43 -05:00
|
|
|
</FileTreeActionableProvider>
|
|
|
|
</FileTreeSelectableProvider>
|
|
|
|
</FileTreeMutableProvider>
|
2020-11-26 09:22:30 -05:00
|
|
|
</FileTreeMainProvider>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
FileTreeContext.propTypes = {
|
|
|
|
projectId: PropTypes.string.isRequired,
|
|
|
|
rootFolder: PropTypes.array.isRequired,
|
|
|
|
hasWritePermissions: PropTypes.bool.isRequired,
|
2021-03-24 06:06:56 -04:00
|
|
|
userHasFeature: PropTypes.func.isRequired,
|
2021-03-18 05:52:36 -04:00
|
|
|
reindexReferences: PropTypes.func.isRequired,
|
|
|
|
refProviders: PropTypes.object.isRequired,
|
|
|
|
setRefProviderEnabled: PropTypes.func.isRequired,
|
|
|
|
setStartedFreeTrial: PropTypes.func.isRequired,
|
2021-01-07 09:22:40 -05:00
|
|
|
rootDocId: PropTypes.string,
|
2020-11-26 09:22:30 -05:00
|
|
|
onSelect: PropTypes.func.isRequired,
|
|
|
|
children: PropTypes.oneOfType([
|
|
|
|
PropTypes.arrayOf(PropTypes.node),
|
2021-04-27 03:52:58 -04:00
|
|
|
PropTypes.node,
|
|
|
|
]).isRequired,
|
2020-11-26 09:22:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default FileTreeContext
|