overleaf/services/web/frontend/js/shared/context/root-context.js
Alasdair Smith 3f4fa4c6cc Merge pull request #4099 from overleaf/as-clean-up-share-modal-window
Pull `user` and `isRestrictedTokenMember` from `ApplicationContext`/`EditorContext` instead of `window`

GitOrigin-RevId: 9084d4f1b075123fe4b10b1156c7b844595827e2
2021-06-04 02:08:24 +00:00

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)