mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
[ide-react] Notify about unsaved changes (#16163)
* Notify about unsaved changes * Move system message components and types to shared folder * Add system messages component GitOrigin-RevId: ab81a24888847bd9a8a390fd1af6b58f471f7a4b
This commit is contained in:
@@ -12,7 +12,6 @@ import GenericMessageModal, {
|
||||
import OutOfSyncModal, {
|
||||
OutOfSyncModalProps,
|
||||
} from '@/features/ide-react/components/modals/out-of-sync-modal'
|
||||
import LockEditorMessageModal from '@/features/ide-react/components/modals/lock-editor-message-modal'
|
||||
|
||||
type ModalsContextValue = {
|
||||
genericModalVisible: boolean
|
||||
@@ -23,7 +22,6 @@ type ModalsContextValue = {
|
||||
showOutOfSyncModal: (
|
||||
editorContent: OutOfSyncModalProps['editorContent']
|
||||
) => void
|
||||
showLockEditorMessageModal: (delay: number) => void
|
||||
}
|
||||
|
||||
const ModalsContext = createContext<ModalsContextValue | undefined>(undefined)
|
||||
@@ -39,12 +37,6 @@ export const ModalsContextProvider: FC = ({ children }) => {
|
||||
editorContent: '',
|
||||
})
|
||||
|
||||
const [shouldShowLockEditorModal, setShouldShowLockEditorModal] =
|
||||
useState(false)
|
||||
const [lockEditorModalData, setLockEditorModalData] = useState({
|
||||
delay: 0,
|
||||
})
|
||||
|
||||
const handleHideGenericModal = useCallback(() => {
|
||||
setShowGenericModal(false)
|
||||
}, [])
|
||||
@@ -69,24 +61,13 @@ export const ModalsContextProvider: FC = ({ children }) => {
|
||||
setShouldShowOutOfSyncModal(true)
|
||||
}, [])
|
||||
|
||||
const showLockEditorMessageModal = useCallback((delay: number) => {
|
||||
setLockEditorModalData({ delay })
|
||||
setShouldShowLockEditorModal(true)
|
||||
}, [])
|
||||
|
||||
const value = useMemo<ModalsContextValue>(
|
||||
() => ({
|
||||
showGenericMessageModal,
|
||||
genericModalVisible: showGenericModal,
|
||||
showOutOfSyncModal,
|
||||
showLockEditorMessageModal,
|
||||
}),
|
||||
[
|
||||
showGenericMessageModal,
|
||||
showGenericModal,
|
||||
showOutOfSyncModal,
|
||||
showLockEditorMessageModal,
|
||||
]
|
||||
[showGenericMessageModal, showGenericModal, showOutOfSyncModal]
|
||||
)
|
||||
|
||||
return (
|
||||
@@ -102,10 +83,6 @@ export const ModalsContextProvider: FC = ({ children }) => {
|
||||
show={shouldShowOutOfSyncModal}
|
||||
onHide={handleHideOutOfSyncModal}
|
||||
/>
|
||||
<LockEditorMessageModal
|
||||
{...lockEditorModalData}
|
||||
show={shouldShowLockEditorModal}
|
||||
/>
|
||||
</ModalsContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user