mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-04 20:54:53 -05:00
f5942f1a7b
Fixed `isRequired` usages for `ApplicationProvider.value.user` GitOrigin-RevId: 0f3db77fa5da1cb0aec29ef112d1044173df88e0
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import React from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import { ApplicationProvider } from './application-context'
|
|
import { EditorProvider } from './editor-context'
|
|
import createSharedContext from 'react2angular-shared-context'
|
|
import { ChatProvider } from '../../features/chat/context/chat-context'
|
|
import { LayoutProvider } from './layout-context'
|
|
import { CompileProvider } from './compile-context'
|
|
|
|
export function ContextRoot({ children, ide, settings }) {
|
|
const isAnonymousUser = window.user.id == null
|
|
|
|
return (
|
|
<ApplicationProvider>
|
|
<EditorProvider ide={ide} settings={settings}>
|
|
<CompileProvider $scope={ide.$scope}>
|
|
<LayoutProvider $scope={ide.$scope}>
|
|
{isAnonymousUser ? (
|
|
children
|
|
) : (
|
|
<ChatProvider>{children}</ChatProvider>
|
|
)}
|
|
</LayoutProvider>
|
|
</CompileProvider>
|
|
</EditorProvider>
|
|
</ApplicationProvider>
|
|
)
|
|
}
|
|
|
|
ContextRoot.propTypes = {
|
|
children: PropTypes.any,
|
|
ide: PropTypes.any.isRequired,
|
|
settings: PropTypes.any.isRequired,
|
|
}
|
|
|
|
export const rootContext = createSharedContext(ContextRoot)
|