overleaf/services/web/frontend/js/shared/context/root-context.js
Jakob Ackermann f5942f1a7b Merge pull request #4098 from overleaf/msm-fix-application-provider-required-user
Fixed `isRequired` usages for `ApplicationProvider.value.user`

GitOrigin-RevId: 0f3db77fa5da1cb0aec29ef112d1044173df88e0
2021-05-28 02:08:46 +00:00

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)