mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Set permissionsLevel to readOnly when out of sync (#18391)
GitOrigin-RevId: d495d7ba4d5d0c7db00277538c932a585f6dace0
This commit is contained in:
parent
e7827fbd57
commit
af721874f1
2 changed files with 12 additions and 1 deletions
|
@ -31,6 +31,7 @@ import { EditorType } from '@/features/ide-react/editor/types/editor-type'
|
||||||
import { DocId } from '../../../../../types/project-settings'
|
import { DocId } from '../../../../../types/project-settings'
|
||||||
import { Update } from '@/features/history/services/types/update'
|
import { Update } from '@/features/history/services/types/update'
|
||||||
import { useDebugDiffTracker } from '../hooks/use-debug-diff-tracker'
|
import { useDebugDiffTracker } from '../hooks/use-debug-diff-tracker'
|
||||||
|
import { useEditorContext } from '@/shared/context/editor-context'
|
||||||
|
|
||||||
interface GotoOffsetOptions {
|
interface GotoOffsetOptions {
|
||||||
gotoOffset: number
|
gotoOffset: number
|
||||||
|
@ -93,6 +94,7 @@ export const EditorManagerProvider: FC = ({ children }) => {
|
||||||
const ide = useIdeContext()
|
const ide = useIdeContext()
|
||||||
const { projectId } = useIdeReactContext()
|
const { projectId } = useIdeReactContext()
|
||||||
const { reportError, eventEmitter, eventLog } = useIdeReactContext()
|
const { reportError, eventEmitter, eventLog } = useIdeReactContext()
|
||||||
|
const { setOutOfSync } = useEditorContext()
|
||||||
const { socket, disconnect, connectionState } = useConnectionContext()
|
const { socket, disconnect, connectionState } = useConnectionContext()
|
||||||
const { view, setView } = useLayoutContext()
|
const { view, setView } = useLayoutContext()
|
||||||
const { showGenericMessageModal, genericModalVisible, showOutOfSyncModal } =
|
const { showGenericMessageModal, genericModalVisible, showOutOfSyncModal } =
|
||||||
|
@ -566,6 +568,9 @@ export const EditorManagerProvider: FC = ({ children }) => {
|
||||||
|
|
||||||
// Tell the user about the error state.
|
// Tell the user about the error state.
|
||||||
setIsInErrorState(true)
|
setIsInErrorState(true)
|
||||||
|
// Ensure that the editor is locked
|
||||||
|
setOutOfSync(true)
|
||||||
|
// Display the "out of sync" modal
|
||||||
showOutOfSyncModal(editorContent || '')
|
showOutOfSyncModal(editorContent || '')
|
||||||
|
|
||||||
// Do not forceReopen the document.
|
// Do not forceReopen the document.
|
||||||
|
@ -592,6 +597,7 @@ export const EditorManagerProvider: FC = ({ children }) => {
|
||||||
setIsInErrorState,
|
setIsInErrorState,
|
||||||
showGenericMessageModal,
|
showGenericMessageModal,
|
||||||
showOutOfSyncModal,
|
showOutOfSyncModal,
|
||||||
|
setOutOfSync,
|
||||||
t,
|
t,
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ export const EditorContext = createContext<
|
||||||
setCurrentPopup: Dispatch<SetStateAction<string | null>>
|
setCurrentPopup: Dispatch<SetStateAction<string | null>>
|
||||||
writefullAdClicked: writefullAdButtons
|
writefullAdClicked: writefullAdButtons
|
||||||
setWritefullAdClicked: Dispatch<SetStateAction<writefullAdButtons>>
|
setWritefullAdClicked: Dispatch<SetStateAction<writefullAdButtons>>
|
||||||
|
setOutOfSync: (value: boolean) => void
|
||||||
}
|
}
|
||||||
| undefined
|
| undefined
|
||||||
>(undefined)
|
>(undefined)
|
||||||
|
@ -81,6 +82,7 @@ export const EditorProvider: FC = ({ children }) => {
|
||||||
const [projectName, setProjectName] = useScopeValue('project.name')
|
const [projectName, setProjectName] = useScopeValue('project.name')
|
||||||
const [permissionsLevel, setPermissionsLevel] =
|
const [permissionsLevel, setPermissionsLevel] =
|
||||||
useScopeValue('permissionsLevel')
|
useScopeValue('permissionsLevel')
|
||||||
|
const [outOfSync, setOutOfSync] = useState(false)
|
||||||
const [showSymbolPalette] = useScopeValue('editor.showSymbolPalette')
|
const [showSymbolPalette] = useScopeValue('editor.showSymbolPalette')
|
||||||
const [toggleSymbolPalette] = useScopeValue('editor.toggleSymbolPalette')
|
const [toggleSymbolPalette] = useScopeValue('editor.toggleSymbolPalette')
|
||||||
|
|
||||||
|
@ -171,7 +173,7 @@ export const EditorProvider: FC = ({ children }) => {
|
||||||
hasPremiumCompile: features?.compileGroup === 'priority',
|
hasPremiumCompile: features?.compileGroup === 'priority',
|
||||||
loading,
|
loading,
|
||||||
renameProject,
|
renameProject,
|
||||||
permissionsLevel,
|
permissionsLevel: outOfSync ? 'readOnly' : permissionsLevel,
|
||||||
setPermissionsLevel,
|
setPermissionsLevel,
|
||||||
isProjectOwner: owner?._id === userId,
|
isProjectOwner: owner?._id === userId,
|
||||||
isRestrictedTokenMember: getMeta('ol-isRestrictedTokenMember'),
|
isRestrictedTokenMember: getMeta('ol-isRestrictedTokenMember'),
|
||||||
|
@ -184,6 +186,7 @@ export const EditorProvider: FC = ({ children }) => {
|
||||||
setCurrentPopup,
|
setCurrentPopup,
|
||||||
writefullAdClicked,
|
writefullAdClicked,
|
||||||
setWritefullAdClicked,
|
setWritefullAdClicked,
|
||||||
|
setOutOfSync,
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
cobranding,
|
cobranding,
|
||||||
|
@ -203,6 +206,8 @@ export const EditorProvider: FC = ({ children }) => {
|
||||||
setCurrentPopup,
|
setCurrentPopup,
|
||||||
writefullAdClicked,
|
writefullAdClicked,
|
||||||
setWritefullAdClicked,
|
setWritefullAdClicked,
|
||||||
|
outOfSync,
|
||||||
|
setOutOfSync,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue