mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-24 08:22:14 +00:00
Avoid reading some variables directly from window
(#12280)
GitOrigin-RevId: 93af19498470fd7903db9d55d7468f0298097cc4
This commit is contained in:
parent
9c78422efa
commit
4c9c0641b2
2 changed files with 9 additions and 4 deletions
|
@ -11,6 +11,8 @@ import useBrowserWindow from '../hooks/use-browser-window'
|
|||
import { useIdeContext } from './ide-context'
|
||||
import { useProjectContext } from './project-context'
|
||||
import { useDetachContext } from './detach-context'
|
||||
import getMeta from '../../utils/meta'
|
||||
import { useUserContext } from './user-context'
|
||||
|
||||
export const EditorContext = createContext()
|
||||
|
||||
|
@ -47,7 +49,7 @@ EditorContext.Provider.propTypes = {
|
|||
|
||||
export function EditorProvider({ children, settings }) {
|
||||
const ide = useIdeContext()
|
||||
|
||||
const { id: userId } = useUserContext()
|
||||
const { role } = useDetachContext()
|
||||
|
||||
const { owner, features } = useProjectContext({
|
||||
|
@ -170,8 +172,8 @@ export function EditorProvider({ children, settings }) {
|
|||
loading,
|
||||
renameProject,
|
||||
permissionsLevel,
|
||||
isProjectOwner: owner?._id === window.user.id,
|
||||
isRestrictedTokenMember: window.isRestrictedTokenMember,
|
||||
isProjectOwner: owner?._id === userId,
|
||||
isRestrictedTokenMember: getMeta('ol-isRestrictedTokenMember'),
|
||||
showSymbolPalette,
|
||||
toggleSymbolPalette,
|
||||
insertSymbol,
|
||||
|
@ -185,10 +187,11 @@ export function EditorProvider({ children, settings }) {
|
|||
[
|
||||
cobranding,
|
||||
features?.compileGroup,
|
||||
owner,
|
||||
userId,
|
||||
loading,
|
||||
renameProject,
|
||||
permissionsLevel,
|
||||
owner?._id,
|
||||
showSymbolPalette,
|
||||
toggleSymbolPalette,
|
||||
insertSymbol,
|
||||
|
|
|
@ -268,6 +268,8 @@ describe('<ShareProjectModal/>', function () {
|
|||
})
|
||||
|
||||
it('only shows read-only token link to restricted token members', async function () {
|
||||
window.metaAttributesCache.set('ol-isRestrictedTokenMember', true)
|
||||
|
||||
renderWithEditorContext(<ShareProjectModal {...modalProps} />, {
|
||||
isRestrictedTokenMember: true,
|
||||
scope: { project: { ...project, publicAccesLevel: 'tokenBased' } },
|
||||
|
|
Loading…
Reference in a new issue