mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-17 21:05:04 -04:00
2dd10c7fee
* Remove split-tests of `compile-timeout-20s` and `compile-timeout-20s-existing-users` * Remove `NEW_COMPILE_TIMEOUT_ENFORCED_CUTOFF` variables * Revert timeout override `60` -> `20` * Update settings.overrides.saas.js: `compileTimeout: 20` * Remove `compile-backend-class-n2d` * Remove `force_new_compile_timeout` * Remove `showNewCompileTimeoutUI` * Remove `compileTimeChanging` * Simplify code by removing segmentation object * Remove `CompileTimeoutChangingSoon` * Remove `user.features.compileTimeout = '20 (with 10s prompt)'` * Remove `CompileTimeWarning` * Remove `TimeoutUpgradePrompt` (old) * Remove `compile-backend-class` * Remove unused translations * Update tests * Fix: Show `CompileTimeout` even if `!window.ExposedSettings.enableSubscriptions` * Create script to migrate users to 20s compileTimeout * migration script: exclude `compileTimeout: 20` from the match * migration script: use `batchedUpdate` * Remove `showFasterCompilesFeedbackUI` and `FasterCompilesFeedback` Helped-by: Jakob Ackermann <jakob.ackermann@overleaf.com> * Remove `_getCompileBackendClassDetails`, simplify definition of `limits` object * Remove `Settings.apis.clsi.defaultBackendClass` * Remove unnecessary second scan of the whole user collection in dry mode * Override `timeout` to 20 for users having `compileGroup === 'standard' && compileTimeout <= 60` * Remove second `logCount`: re-run the script in dry-mode if you want to see that count * Use secondary readPreference when counting users * Fix script setup and exit 0 * Fix: Remove `user.` from query path! * Add acceptance test on script migration_compile_timeout_60s_to_20s.js GitOrigin-RevId: 3cb65130e6d7fbd9c54005f4c213066d0473e9d8
482 lines
11 KiB
TypeScript
482 lines
11 KiB
TypeScript
import { createContext, FC, useContext, useMemo } from 'react'
|
|
import { CompileContext, useLocalCompileContext } from './local-compile-context'
|
|
import useDetachStateWatcher from '../hooks/use-detach-state-watcher'
|
|
import useDetachAction from '../hooks/use-detach-action'
|
|
import useCompileTriggers from '../../features/pdf-preview/hooks/use-compile-triggers'
|
|
|
|
export const DetachCompileContext = createContext<CompileContext | undefined>(
|
|
undefined
|
|
)
|
|
|
|
export const DetachCompileProvider: FC = ({ children }) => {
|
|
const localCompileContext = useLocalCompileContext()
|
|
if (!localCompileContext) {
|
|
throw new Error(
|
|
'DetachCompileProvider is only available inside LocalCompileProvider'
|
|
)
|
|
}
|
|
|
|
const {
|
|
animateCompileDropdownArrow: _animateCompileDropdownArrow,
|
|
autoCompile: _autoCompile,
|
|
clearingCache: _clearingCache,
|
|
clsiServerId: _clsiServerId,
|
|
codeCheckFailed: _codeCheckFailed,
|
|
compiling: _compiling,
|
|
deliveryLatencies: _deliveryLatencies,
|
|
draft: _draft,
|
|
editedSinceCompileStarted: _editedSinceCompileStarted,
|
|
error: _error,
|
|
fileList: _fileList,
|
|
hasChanges: _hasChanges,
|
|
highlights: _highlights,
|
|
isProjectOwner: _isProjectOwner,
|
|
lastCompileOptions: _lastCompileOptions,
|
|
logEntries: _logEntries,
|
|
logEntryAnnotations: _logEntryAnnotations,
|
|
pdfFile: _pdfFile,
|
|
pdfViewer: _pdfViewer,
|
|
position: _position,
|
|
rawLog: _rawLog,
|
|
setAnimateCompileDropdownArrow: _setAnimateCompileDropdownArrow,
|
|
setAutoCompile: _setAutoCompile,
|
|
setDraft: _setDraft,
|
|
setError: _setError,
|
|
setHasLintingError: _setHasLintingError,
|
|
setHighlights: _setHighlights,
|
|
setPosition: _setPosition,
|
|
setShowCompileTimeWarning: _setShowCompileTimeWarning,
|
|
setShowLogs: _setShowLogs,
|
|
toggleLogs: _toggleLogs,
|
|
setStopOnFirstError: _setStopOnFirstError,
|
|
setStopOnValidationError: _setStopOnValidationError,
|
|
showLogs: _showLogs,
|
|
showCompileTimeWarning: _showCompileTimeWarning,
|
|
stopOnFirstError: _stopOnFirstError,
|
|
stopOnValidationError: _stopOnValidationError,
|
|
stoppedOnFirstError: _stoppedOnFirstError,
|
|
uncompiled: _uncompiled,
|
|
validationIssues: _validationIssues,
|
|
firstRenderDone: _firstRenderDone,
|
|
cleanupCompileResult: _cleanupCompileResult,
|
|
recompileFromScratch: _recompileFromScratch,
|
|
setCompiling: _setCompiling,
|
|
startCompile: _startCompile,
|
|
stopCompile: _stopCompile,
|
|
setChangedAt: _setChangedAt,
|
|
clearCache: _clearCache,
|
|
syncToEntry: _syncToEntry,
|
|
} = localCompileContext
|
|
|
|
const [animateCompileDropdownArrow] = useDetachStateWatcher(
|
|
'animateCompileDropdownArrow',
|
|
_animateCompileDropdownArrow,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [autoCompile] = useDetachStateWatcher(
|
|
'autoCompile',
|
|
_autoCompile,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [clearingCache] = useDetachStateWatcher(
|
|
'clearingCache',
|
|
_clearingCache,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [clsiServerId] = useDetachStateWatcher(
|
|
'clsiServerId',
|
|
_clsiServerId,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [codeCheckFailed] = useDetachStateWatcher(
|
|
'codeCheckFailed',
|
|
_codeCheckFailed,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [compiling] = useDetachStateWatcher(
|
|
'compiling',
|
|
_compiling,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [deliveryLatencies] = useDetachStateWatcher(
|
|
'deliveryLatencies',
|
|
_deliveryLatencies,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [draft] = useDetachStateWatcher('draft', _draft, 'detacher', 'detached')
|
|
const [error] = useDetachStateWatcher('error', _error, 'detacher', 'detached')
|
|
const [fileList] = useDetachStateWatcher(
|
|
'fileList',
|
|
_fileList,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [hasChanges] = useDetachStateWatcher(
|
|
'hasChanges',
|
|
_hasChanges,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [highlights] = useDetachStateWatcher(
|
|
'highlights',
|
|
_highlights,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [isProjectOwner] = useDetachStateWatcher(
|
|
'isProjectOwner',
|
|
_isProjectOwner,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [lastCompileOptions] = useDetachStateWatcher(
|
|
'lastCompileOptions',
|
|
_lastCompileOptions,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [logEntries] = useDetachStateWatcher(
|
|
'logEntries',
|
|
_logEntries,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [logEntryAnnotations] = useDetachStateWatcher(
|
|
'logEntryAnnotations',
|
|
_logEntryAnnotations,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [pdfFile] = useDetachStateWatcher(
|
|
'pdfFile',
|
|
_pdfFile,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [pdfViewer] = useDetachStateWatcher(
|
|
'pdfViewer',
|
|
_pdfViewer,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [position] = useDetachStateWatcher(
|
|
'position',
|
|
_position,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [rawLog] = useDetachStateWatcher(
|
|
'rawLog',
|
|
_rawLog,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [showCompileTimeWarning] = useDetachStateWatcher(
|
|
'showCompileTimeWarning',
|
|
_showCompileTimeWarning,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [showLogs] = useDetachStateWatcher(
|
|
'showLogs',
|
|
_showLogs,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [stopOnFirstError] = useDetachStateWatcher(
|
|
'stopOnFirstError',
|
|
_stopOnFirstError,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [stopOnValidationError] = useDetachStateWatcher(
|
|
'stopOnValidationError',
|
|
_stopOnValidationError,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [stoppedOnFirstError] = useDetachStateWatcher(
|
|
'stoppedOnFirstError',
|
|
_stoppedOnFirstError,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [uncompiled] = useDetachStateWatcher(
|
|
'uncompiled',
|
|
_uncompiled,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [editedSinceCompileStarted] = useDetachStateWatcher(
|
|
'editedSinceCompileStarted',
|
|
_editedSinceCompileStarted,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const [validationIssues] = useDetachStateWatcher(
|
|
'validationIssues',
|
|
_validationIssues,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
|
|
const setAnimateCompileDropdownArrow = useDetachAction(
|
|
'setAnimateCompileDropdownArrow',
|
|
_setAnimateCompileDropdownArrow,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const setAutoCompile = useDetachAction(
|
|
'setAutoCompile',
|
|
_setAutoCompile,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const setDraft = useDetachAction(
|
|
'setDraft',
|
|
_setDraft,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const setError = useDetachAction(
|
|
'setError',
|
|
_setError,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const setPosition = useDetachAction(
|
|
'setPosition',
|
|
_setPosition,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const firstRenderDone = useDetachAction(
|
|
'firstRenderDone',
|
|
_firstRenderDone,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const setHasLintingError = useDetachAction(
|
|
'setHasLintingError',
|
|
_setHasLintingError,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const setHighlights = useDetachAction(
|
|
'setHighlights',
|
|
_setHighlights,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const setShowCompileTimeWarning = useDetachAction(
|
|
'setShowCompileTimeWarning',
|
|
_setShowCompileTimeWarning,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const setShowLogs = useDetachAction(
|
|
'setShowLogs',
|
|
_setShowLogs,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const toggleLogs = useDetachAction(
|
|
'toggleLogs',
|
|
_toggleLogs,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const setStopOnFirstError = useDetachAction(
|
|
'setStopOnFirstError',
|
|
_setStopOnFirstError,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const setStopOnValidationError = useDetachAction(
|
|
'setStopOnValidationError',
|
|
_setStopOnValidationError,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const cleanupCompileResult = useDetachAction(
|
|
'cleanupCompileResult',
|
|
_cleanupCompileResult,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const recompileFromScratch = useDetachAction(
|
|
'recompileFromScratch',
|
|
_recompileFromScratch,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const setCompiling = useDetachAction(
|
|
'setCompiling',
|
|
_setCompiling,
|
|
'detacher',
|
|
'detached'
|
|
)
|
|
const startCompile = useDetachAction(
|
|
'startCompile',
|
|
_startCompile,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const stopCompile = useDetachAction(
|
|
'stopCompile',
|
|
_stopCompile,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const setChangedAt = useDetachAction(
|
|
'setChangedAt',
|
|
_setChangedAt,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
const clearCache = useDetachAction(
|
|
'clearCache',
|
|
_clearCache,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
|
|
const syncToEntry = useDetachAction(
|
|
'sync-to-entry',
|
|
_syncToEntry,
|
|
'detached',
|
|
'detacher'
|
|
)
|
|
|
|
useCompileTriggers(startCompile, setChangedAt)
|
|
|
|
const value = useMemo(
|
|
() => ({
|
|
animateCompileDropdownArrow,
|
|
autoCompile,
|
|
clearCache,
|
|
clearingCache,
|
|
clsiServerId,
|
|
codeCheckFailed,
|
|
compiling,
|
|
deliveryLatencies,
|
|
draft,
|
|
editedSinceCompileStarted,
|
|
error,
|
|
fileList,
|
|
hasChanges,
|
|
highlights,
|
|
isProjectOwner,
|
|
lastCompileOptions,
|
|
logEntryAnnotations,
|
|
logEntries,
|
|
pdfDownloadUrl: pdfFile?.pdfDownloadUrl,
|
|
pdfFile,
|
|
pdfUrl: pdfFile?.pdfUrl,
|
|
pdfViewer,
|
|
position,
|
|
rawLog,
|
|
recompileFromScratch,
|
|
setAnimateCompileDropdownArrow,
|
|
setAutoCompile,
|
|
setCompiling,
|
|
setDraft,
|
|
setError,
|
|
setHasLintingError,
|
|
setHighlights,
|
|
setPosition,
|
|
setShowCompileTimeWarning,
|
|
setShowLogs,
|
|
toggleLogs,
|
|
setStopOnFirstError,
|
|
setStopOnValidationError,
|
|
showLogs,
|
|
showCompileTimeWarning,
|
|
startCompile,
|
|
stopCompile,
|
|
stopOnFirstError,
|
|
stopOnValidationError,
|
|
stoppedOnFirstError,
|
|
uncompiled,
|
|
validationIssues,
|
|
firstRenderDone,
|
|
setChangedAt,
|
|
cleanupCompileResult,
|
|
syncToEntry,
|
|
}),
|
|
[
|
|
animateCompileDropdownArrow,
|
|
autoCompile,
|
|
clearCache,
|
|
clearingCache,
|
|
clsiServerId,
|
|
codeCheckFailed,
|
|
compiling,
|
|
deliveryLatencies,
|
|
draft,
|
|
error,
|
|
editedSinceCompileStarted,
|
|
fileList,
|
|
hasChanges,
|
|
highlights,
|
|
isProjectOwner,
|
|
lastCompileOptions,
|
|
logEntryAnnotations,
|
|
logEntries,
|
|
pdfFile,
|
|
pdfViewer,
|
|
position,
|
|
rawLog,
|
|
recompileFromScratch,
|
|
setAnimateCompileDropdownArrow,
|
|
setAutoCompile,
|
|
setCompiling,
|
|
setDraft,
|
|
setError,
|
|
setHasLintingError,
|
|
setHighlights,
|
|
setPosition,
|
|
setShowCompileTimeWarning,
|
|
setShowLogs,
|
|
toggleLogs,
|
|
setStopOnFirstError,
|
|
setStopOnValidationError,
|
|
showCompileTimeWarning,
|
|
showLogs,
|
|
startCompile,
|
|
stopCompile,
|
|
stopOnFirstError,
|
|
stopOnValidationError,
|
|
stoppedOnFirstError,
|
|
uncompiled,
|
|
validationIssues,
|
|
firstRenderDone,
|
|
setChangedAt,
|
|
cleanupCompileResult,
|
|
syncToEntry,
|
|
]
|
|
)
|
|
|
|
return (
|
|
<DetachCompileContext.Provider value={value}>
|
|
{children}
|
|
</DetachCompileContext.Provider>
|
|
)
|
|
}
|
|
|
|
export function useDetachCompileContext() {
|
|
const context = useContext(DetachCompileContext)
|
|
if (!context) {
|
|
throw new Error(
|
|
'useDetachCompileContext is ony available inside DetachCompileProvider'
|
|
)
|
|
}
|
|
return context
|
|
}
|