2020-12-14 06:44:10 -05:00
|
|
|
import React from 'react'
|
2021-01-27 05:30:55 -05:00
|
|
|
import PropTypes from 'prop-types'
|
2021-06-03 09:44:23 -04:00
|
|
|
import createSharedContext from 'react2angular-shared-context'
|
|
|
|
|
2020-12-14 06:44:10 -05:00
|
|
|
import { ApplicationProvider } from './application-context'
|
|
|
|
import { EditorProvider } from './editor-context'
|
2021-04-19 08:38:03 -04:00
|
|
|
import { CompileProvider } from './compile-context'
|
2021-06-03 09:44:23 -04:00
|
|
|
import { LayoutProvider } from './layout-context'
|
|
|
|
import { ChatProvider } from '../../features/chat/context/chat-context'
|
2020-12-14 06:44:10 -05:00
|
|
|
|
2021-03-10 07:19:54 -05:00
|
|
|
export function ContextRoot({ children, ide, settings }) {
|
2021-05-27 05:30:24 -04:00
|
|
|
const isAnonymousUser = window.user.id == null
|
|
|
|
|
2020-12-14 06:44:10 -05:00
|
|
|
return (
|
|
|
|
<ApplicationProvider>
|
2021-03-10 07:19:54 -05:00
|
|
|
<EditorProvider ide={ide} settings={settings}>
|
2021-04-19 08:38:03 -04:00
|
|
|
<CompileProvider $scope={ide.$scope}>
|
|
|
|
<LayoutProvider $scope={ide.$scope}>
|
2021-05-27 05:30:24 -04:00
|
|
|
{isAnonymousUser ? (
|
|
|
|
children
|
|
|
|
) : (
|
|
|
|
<ChatProvider>{children}</ChatProvider>
|
|
|
|
)}
|
2021-04-19 08:38:03 -04:00
|
|
|
</LayoutProvider>
|
|
|
|
</CompileProvider>
|
2021-02-09 10:37:48 -05:00
|
|
|
</EditorProvider>
|
2020-12-14 06:44:10 -05:00
|
|
|
</ApplicationProvider>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-01-27 05:30:55 -05:00
|
|
|
ContextRoot.propTypes = {
|
|
|
|
children: PropTypes.any,
|
2021-03-10 07:19:54 -05:00
|
|
|
ide: PropTypes.any.isRequired,
|
2021-04-27 03:52:58 -04:00
|
|
|
settings: PropTypes.any.isRequired,
|
2021-01-27 05:30:55 -05:00
|
|
|
}
|
|
|
|
|
2020-12-14 06:44:10 -05:00
|
|
|
export const rootContext = createSharedContext(ContextRoot)
|