diff --git a/app/front-end/src/features/editor/components/editorView/editorConfirmLeave.tsx b/app/front-end/src/features/editor/components/editorView/editorConfirmLeave.tsx new file mode 100644 index 0000000..a128ef5 --- /dev/null +++ b/app/front-end/src/features/editor/components/editorView/editorConfirmLeave.tsx @@ -0,0 +1,83 @@ +import { FileTreeItemContextMenuStyledDialog } from '@/features/editor/components/fileTreeView/fileTreeItem'; +import { useStatusContext } from '@/hooks'; +import { Close as CloseIcon } from '@mui/icons-material'; +import { + Box, + Button, + DialogActions, + DialogContent, + DialogTitle, + Grid, + IconButton, + Typography, + useTheme, +} from '@mui/material'; +import { useCallback } from 'react'; + +interface EditorConfirmLeaveDialogProps { + onConfirm: () => void; + isOpen: boolean; + onClose: () => void; +} + +export const EditorConfirmLeave: React.FC = ({ onConfirm, isOpen, onClose }) => { + const { unsavedStateUpdate } = useStatusContext(); + const Theme = useTheme(); + + const handleConfirm = useCallback(() => { + unsavedStateUpdate(false); + onConfirm(); + onClose(); + }, [onConfirm, onClose, unsavedStateUpdate]); + + return ( + + + + + Unsaved changes + + + + + + + + + + + + + You have unsaved changes. If you continue, your changes will be lost.
+ Do you wish to continue? +
+
+ + + + +
+ ); +}; diff --git a/app/front-end/src/features/editor/components/editorView/editorToolbar.tsx b/app/front-end/src/features/editor/components/editorView/editorToolbar.tsx index ad2eb32..da684c0 100644 --- a/app/front-end/src/features/editor/components/editorView/editorToolbar.tsx +++ b/app/front-end/src/features/editor/components/editorView/editorToolbar.tsx @@ -2,7 +2,7 @@ import { useStatusContext } from '@/hooks'; import { socket } from '@/lib'; import { Events } from '@/types'; import { Done as DoneIcon, Error as ErrorIcon } from '@mui/icons-material'; -import { Box, Button, CircularProgress, useTheme } from '@mui/material'; +import { alpha, Box, Button, CircularProgress, Typography, useTheme } from '@mui/material'; import { GridToolbarColumnsButton, GridToolbarContainer, @@ -52,7 +52,7 @@ export const EditorToolbar: React.FC = ({ handleSave }) => { const [saveStatus, setSaveStatus] = useState(true); const Theme = useTheme(); - const { blocked } = useStatusContext(); + const { blocked, unsavedStateUpdate, unsaved } = useStatusContext(); useEffect(() => { const handleWorkspaceFileSaveFeedback = (data: { status: 'success' | 'error' }) => { @@ -73,10 +73,17 @@ export const EditorToolbar: React.FC = ({ handleSave }) => { {/* */} + {unsaved && ( + + Changes not saved + + )} +