overleaf/services/web/test/frontend/features/file-tree/helpers/render-with-context.js
ilkin-overleaf d8e2c10257 Merge pull request #14291 from overleaf/ii-filetree-empty-space-click-2
Select project root folder

GitOrigin-RevId: 146bf9dcbfbd037c51529b80104495bd95922471
2023-08-15 08:03:22 +00:00

54 lines
1.4 KiB
JavaScript

import FileTreeContext from '../../../../../frontend/js/features/file-tree/components/file-tree-context'
import { renderWithEditorContext } from '../../../helpers/render-with-context'
export default (children, options = {}) => {
let { contextProps = {}, ...renderOptions } = options
contextProps = {
projectId: '123abc',
rootFolder: [
{
_id: 'root-folder-id',
name: 'rootFolder',
docs: [],
fileRefs: [],
folders: [],
},
],
refProviders: {},
reindexReferences: () => {
console.log('reindex references')
},
setRefProviderEnabled: provider => {
console.log(`ref provider ${provider} enabled`)
},
setStartedFreeTrial: () => {
console.log('started free trial')
},
setShouldShowVisualSelection: () => {},
onSelect: () => {},
...contextProps,
}
const {
refProviders,
reindexReferences,
setRefProviderEnabled,
setStartedFreeTrial,
setShouldShowVisualSelection,
onSelect,
...editorContextProps
} = contextProps
return renderWithEditorContext(
<FileTreeContext
refProviders={refProviders}
reindexReferences={reindexReferences}
setRefProviderEnabled={setRefProviderEnabled}
setStartedFreeTrial={setStartedFreeTrial}
setShouldShowVisualSelection={setShouldShowVisualSelection}
onSelect={onSelect}
>
{children}
</FileTreeContext>,
editorContextProps,
renderOptions
)
}