overleaf/services/web/frontend/js/shared/context/application-context.js
Miguel Serrano 445c850004 Revert "React Git Bridge Modal (#3757)" (#3867)
This reverts commit cf883b776a9ddc7975977534dc453ece4b3ec431.

GitOrigin-RevId: 462d7282d2c706ef5395c25a335239bfac4787a6
2021-04-01 02:05:27 +00:00

43 lines
1,008 B
JavaScript

import React, { createContext, useContext } from 'react'
import PropTypes from 'prop-types'
import ExposedSettings from '../../main/exposed-settings'
export const ApplicationContext = createContext()
ApplicationContext.Provider.propTypes = {
value: PropTypes.shape({
user: PropTypes.shape({
id: PropTypes.string.isRequired
}),
exposedSettings: PropTypes.shape({
enableSubscriptions: PropTypes.bool
})
})
}
export function ApplicationProvider({ children }) {
const applicationContextValue = {
user: window.user,
exposedSettings: ExposedSettings
}
return (
<ApplicationContext.Provider value={applicationContextValue}>
{children}
</ApplicationContext.Provider>
)
}
ApplicationProvider.propTypes = {
children: PropTypes.any
}
export function useApplicationContext(propTypes) {
const data = useContext(ApplicationContext)
PropTypes.checkPropTypes(
propTypes,
data,
'data',
'ApplicationContext.Provider'
)
return data
}