mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
3f4fa4c6cc
Pull `user` and `isRestrictedTokenMember` from `ApplicationContext`/`EditorContext` instead of `window` GitOrigin-RevId: 9084d4f1b075123fe4b10b1156c7b844595827e2
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import React from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import createSharedContext from 'react2angular-shared-context'
|
|
|
|
import { ApplicationProvider } from './application-context'
|
|
import { EditorProvider } from './editor-context'
|
|
import { CompileProvider } from './compile-context'
|
|
import { LayoutProvider } from './layout-context'
|
|
import { ChatProvider } from '../../features/chat/context/chat-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)
|