diff --git a/public/locales/de.json b/public/locales/de.json index afbbc81b..14664774 100644 --- a/public/locales/de.json +++ b/public/locales/de.json @@ -162,6 +162,7 @@ "confirm_limit": "Bestätigen", "finish_capture": "Erfassung abschließen", "back": "Zurück", + "reset": "Starten Sie die Aufnahme neu", "finish": "Fertig", "cancel": "Abbrechen", "delete": "Löschen" @@ -226,10 +227,14 @@ }, "browser_recording": { "modal": { - "confirm_discard": "Sind Sie sicher, dass Sie die Aufnahme verwerfen möchten?" - }, + "confirm_discard": "Sind Sie sicher, dass Sie die Aufnahme verwerfen möchten?", + "confirm_reset": "Sind Sie sicher, dass Sie zurücksetzen möchten?", + "reset_warning": "Dadurch werden alle vorherigen Aufnahmen in der aktuellen Sitzung gelöscht. Die Aufnahmesitzung wird für dieselbe Website neu gestartet." + }, "notifications": { - "terminated": "Aktuelle Aufnahme wurde beendet" + "terminated": "Aktuelle Aufnahme wurde beendet", + "environment_reset": "Browser-Umgebung wurde zurückgesetzt", + "reset_successful": "Alle Aufnahmen erfolgreich zurückgesetzt und zum Ausgangszustand zurückgekehrt" } }, "interpretation_log": { diff --git a/public/locales/en.json b/public/locales/en.json index b3f44225..88622f20 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -161,8 +161,10 @@ "confirm_capture": "Confirm Capture", "confirm_pagination": "Confirm", "confirm_limit": "Confirm", + "confirm_reset": "Confirm", "finish_capture": "Finish Capture", "back": "Back", + "reset": "Restart Recording", "finish": "Finish", "cancel": "Cancel", "delete": "Delete" @@ -227,10 +229,14 @@ }, "browser_recording": { "modal": { - "confirm_discard": "Are you sure you want to discard the recording?" + "confirm_discard": "Are you sure you want to discard the recording?", + "confirm_reset": "Are you sure you want to restart the recording?", + "reset_warning": "This will clear all previous captures in the current session. The recording session will restart for the same website." }, "notifications": { - "terminated": "Current Recording was terminated" + "terminated": "Current Recording was terminated", + "environment_reset": "Browser environment has been reset", + "reset_successful": "Successfully reset all captures and returned to initial state" } }, "interpretation_log": { diff --git a/public/locales/es.json b/public/locales/es.json index 08d1ef98..7f669096 100644 --- a/public/locales/es.json +++ b/public/locales/es.json @@ -163,6 +163,7 @@ "confirm_limit": "Confirmar", "finish_capture": "Finalizar Captura", "back": "Atrás", + "reset": "Reiniciar", "finish": "Finalizar", "cancel": "Cancelar", "delete": "Eliminar" @@ -227,10 +228,14 @@ }, "browser_recording": { "modal": { - "confirm_discard": "¿Está seguro de que desea descartar la grabación?" + "confirm_discard": "¿Está seguro de que desea descartar la grabación?", + "confirm_reset": "¿Está seguro de que desea reiniciar?", + "reset_warning": "Esto borrará todas las capturas anteriores de la sesión actual. La sesión de grabación se reiniciará para el mismo sitio web." }, "notifications": { - "terminated": "La grabación actual fue terminada" + "terminated": "La grabación actual fue terminada", + "environment_reset": "El entorno del navegador ha sido reiniciado", + "reset_successful": "Se reiniciaron correctamente todas las capturas y se volvió al estado inicial" } }, "interpretation_log": { diff --git a/public/locales/ja.json b/public/locales/ja.json index 521a7f70..5680471d 100644 --- a/public/locales/ja.json +++ b/public/locales/ja.json @@ -163,6 +163,7 @@ "confirm_limit": "確認", "finish_capture": "取得を完了", "back": "戻る", + "reset": "リセット", "finish": "完了", "cancel": "キャンセル", "delete": "削除" @@ -227,10 +228,14 @@ }, "browser_recording": { "modal": { - "confirm_discard": "録画を破棄してもよろしいですか?" + "confirm_discard": "録画を破棄してもよろしいですか?", + "confirm_reset": "リセットしてもよろしいですか?", + "reset_warning": "これにより、現在のセッションの以前のキャプチャがすべてクリアされます。同じ Web サイトの記録セッションが再開されます。" }, "notifications": { - "terminated": "現在の録画は終了しました" + "terminated": "現在の録画は終了しました", + "environment_reset": "ブラウザー環境がリセットされました", + "reset_successful": "すべてのキャプチャーを正常にリセットし、初期状態に戻りました" } }, "interpretation_log": { diff --git a/public/locales/zh.json b/public/locales/zh.json index 076f449a..536ea70c 100644 --- a/public/locales/zh.json +++ b/public/locales/zh.json @@ -163,6 +163,7 @@ "confirm_limit": "确认", "finish_capture": "完成捕获", "back": "返回", + "reset": "重置", "finish": "完成", "cancel": "取消", "delete": "删除" @@ -227,10 +228,14 @@ }, "browser_recording": { "modal": { - "confirm_discard": "您确定要放弃录制吗?" + "confirm_discard": "您确定要放弃此录制吗?", + "confirm_reset": "您确定要重置吗?", + "reset_warning": "这将清除当前会话中的所有先前捕获。录制会话将针对同一网站重新启动。" }, "notifications": { - "terminated": "当前录制已终止" + "terminated": "当前录制已终止", + "environment_reset": "浏览器环境已重置", + "reset_successful": "已成功重置所有捕获并返回初始状态" } }, "interpretation_log": { diff --git a/src/components/browser/BrowserRecordingSave.tsx b/src/components/browser/BrowserRecordingSave.tsx index af9e9ea1..9011fd9a 100644 --- a/src/components/browser/BrowserRecordingSave.tsx +++ b/src/components/browser/BrowserRecordingSave.tsx @@ -1,18 +1,44 @@ import React, { useState } from 'react' -import { Grid, Button, Box, Typography } from '@mui/material'; +import { Grid, Button, Box, Typography, IconButton, Menu, MenuItem, ListItemText } from '@mui/material'; import { SaveRecording } from "../recorder/SaveRecording"; import { useGlobalInfoStore } from '../../context/globalInfo'; +import { useActionContext } from '../../context/browserActions'; +import { useBrowserSteps } from '../../context/browserSteps'; import { stopRecording } from "../../api/recording"; import { useNavigate } from 'react-router-dom'; import { GenericModal } from "../ui/GenericModal"; import { useTranslation } from 'react-i18next'; +import { emptyWorkflow } from '../../shared/constants'; +import { useSocketStore } from '../../context/socket'; +import { MoreHoriz } from '@mui/icons-material'; const BrowserRecordingSave = () => { const { t } = useTranslation(); - const [openModal, setOpenModal] = useState(false); - const { recordingName, browserId, setBrowserId, notify } = useGlobalInfoStore(); + const [openDiscardModal, setOpenDiscardModal] = useState(false); + const [openResetModal, setOpenResetModal] = useState(false); + const [anchorEl, setAnchorEl] = React.useState(null); + const { recordingName, browserId, initialUrl, setRecordingUrl, setBrowserId, notify, setCurrentWorkflowActionsState, resetInterpretationLog } = useGlobalInfoStore(); const navigate = useNavigate(); + const { socket } = useSocketStore(); + + const { + stopGetText, + stopGetList, + stopGetScreenshot, + stopPaginationMode, + stopLimitMode, + setCaptureStage, + updatePaginationType, + updateLimitType, + updateCustomLimit, + setShowLimitOptions, + setShowPaginationOptions, + setWorkflow, + } = useActionContext(); + + const { browserSteps, deleteBrowserStep } = useBrowserSteps(); + const goToMainMenu = async () => { if (browserId) { await stopRecording(browserId); @@ -22,6 +48,58 @@ const BrowserRecordingSave = () => { navigate('/'); }; + const performReset = () => { + stopGetText(); + stopGetList(); + stopGetScreenshot(); + stopPaginationMode(); + stopLimitMode(); + + setShowLimitOptions(false); + setShowPaginationOptions(false); + setCaptureStage('initial'); + + updatePaginationType(''); + updateLimitType(''); + updateCustomLimit(''); + + setCurrentWorkflowActionsState({ + hasScrapeListAction: false, + hasScreenshotAction: false, + hasScrapeSchemaAction: false + }); + + setWorkflow(emptyWorkflow); + + resetInterpretationLog(); + + // Clear all browser steps + browserSteps.forEach(step => { + deleteBrowserStep(step.id); + }); + + if (socket) { + socket?.emit('new-recording'); + socket.emit('input:url', initialUrl); + // Update the URL in the navbar to match + setRecordingUrl(initialUrl); + } + + // Close the reset confirmation modal + setOpenResetModal(false); + + // Notify user + notify('info', t('browser_recording.notifications.environment_reset')); + }; + + const handleClick = (event: React.MouseEvent) => { + setAnchorEl(event.currentTarget); + }; + + const handleClose = () => { + setAnchorEl(null); + }; + return ( @@ -40,7 +118,7 @@ const BrowserRecordingSave = () => { height: "48px" }}> - setOpenModal(false)} modalStyle={modalStyle}> + + {/* Reset Button */} + + + + + { setOpenResetModal(true); handleClose(); }}> + {t('right_panel.buttons.reset')} + + + + + + {/* Discard Confirmation Modal */} + setOpenDiscardModal(false)} modalStyle={modalStyle}> {t('browser_recording.modal.confirm_discard')} + + + + + + {/* Reset Confirmation Modal */} + setOpenResetModal(false)} modalStyle={modalStyle}> + + {t('browser_recording.modal.confirm_reset')} + + {t('browser_recording.modal.reset_warning')} + + +