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 { 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({
|
2021-03-18 05:52:36 -04:00
|
|
|
refProviders,
|
|
|
|
reindexReferences,
|
|
|
|
setRefProviderEnabled,
|
|
|
|
setStartedFreeTrial,
|
2023-08-14 07:38:09 -04:00
|
|
|
setShouldShowVisualSelection,
|
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
|
2021-03-18 05:52:36 -04:00
|
|
|
refProviders={refProviders}
|
|
|
|
setRefProviderEnabled={setRefProviderEnabled}
|
|
|
|
setStartedFreeTrial={setStartedFreeTrial}
|
2023-08-14 07:38:09 -04:00
|
|
|
setShouldShowVisualSelection={setShouldShowVisualSelection}
|
2021-03-18 05:52:36 -04:00
|
|
|
reindexReferences={reindexReferences}
|
2020-11-26 09:22:30 -05:00
|
|
|
>
|
2023-08-14 07:38:09 -04:00
|
|
|
<FileTreeSelectableProvider
|
|
|
|
onSelect={onSelect}
|
|
|
|
setShouldShowVisualSelection={setShouldShowVisualSelection}
|
|
|
|
>
|
2022-01-10 10:47:01 -05:00
|
|
|
<FileTreeActionableProvider>
|
|
|
|
<FileTreeDraggableProvider>{children}</FileTreeDraggableProvider>
|
|
|
|
</FileTreeActionableProvider>
|
|
|
|
</FileTreeSelectableProvider>
|
2020-11-26 09:22:30 -05:00
|
|
|
</FileTreeMainProvider>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
FileTreeContext.propTypes = {
|
2021-03-18 05:52:36 -04:00
|
|
|
reindexReferences: PropTypes.func.isRequired,
|
|
|
|
refProviders: PropTypes.object.isRequired,
|
|
|
|
setRefProviderEnabled: PropTypes.func.isRequired,
|
|
|
|
setStartedFreeTrial: PropTypes.func.isRequired,
|
2023-08-14 07:38:09 -04:00
|
|
|
setShouldShowVisualSelection: PropTypes.func.isRequired,
|
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
|