mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-28 11:31:55 +02:00
* Created ng-controller for react shared context and set editor.loading * toolbar-header component with menu button (and story) * Added editor-navigation-toolbar-root and react2angular plumbing * Added eslint-disable exception to use <a/> instead of <button/> * added 'menu' to extracted translation * [ReactNavToolbar] Added cobranding and back to projects buttons (#3515) GitOrigin-RevId: 27c3bba85cbc96a123d58c66a0bd5d6a2cfd8aca
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
import React, { createContext, useContext } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
|
|
export const EditorContext = createContext()
|
|
|
|
export function EditorProvider({ children, loading }) {
|
|
const cobranding = window.brandVariation
|
|
? {
|
|
logoImgUrl: window.brandVariation.logo_url,
|
|
brandVariationName: window.brandVariation.name,
|
|
brandVariationHomeUrl: window.brandVariation.home_url
|
|
}
|
|
: undefined
|
|
|
|
const ownerId =
|
|
window._ide.$scope.project && window._ide.$scope.project.owner
|
|
? window._ide.$scope.project.owner._id
|
|
: null
|
|
|
|
const editorContextValue = {
|
|
cobranding,
|
|
loading,
|
|
projectId: window.project_id,
|
|
isProjectOwner: ownerId === window.user.id
|
|
}
|
|
|
|
return (
|
|
<EditorContext.Provider value={editorContextValue}>
|
|
{children}
|
|
</EditorContext.Provider>
|
|
)
|
|
}
|
|
|
|
EditorProvider.propTypes = {
|
|
children: PropTypes.any,
|
|
loading: PropTypes.bool
|
|
}
|
|
|
|
export function useEditorContext() {
|
|
const editorContext = useContext(EditorContext)
|
|
return editorContext
|
|
}
|