diff --git a/public/locales/de.json b/public/locales/de.json index 28855c78..90beaa14 100644 --- a/public/locales/de.json +++ b/public/locales/de.json @@ -245,11 +245,15 @@ "mimetype": "Medientyp: ", "image_below": "Bild wird unten angezeigt:", "separator": "--------------------------------------------------" + }, + "notifications": { + "reset_success": "Vorschau erfolgreich zurückgesetzt" } }, "interpretation_buttons": { "buttons": { "preview": "Vorschau der Ausgabedaten anzeigen", + "reset": "Zurücksetzen", "yes": "Ja", "no": "Nein" }, diff --git a/public/locales/en.json b/public/locales/en.json index 8084b5f2..7752ad78 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -246,11 +246,15 @@ "mimetype": "mimetype: ", "image_below": "Image is rendered below:", "separator": "--------------------------------------------------" + }, + "notifications": { + "reset_success": "Output Preview reset successfully" } }, "interpretation_buttons": { "buttons": { "preview": "Get Preview of Output Data", + "reset": "Reset", "yes": "Yes", "no": "No" }, diff --git a/public/locales/es.json b/public/locales/es.json index 4ef417ea..00fa379e 100644 --- a/public/locales/es.json +++ b/public/locales/es.json @@ -251,6 +251,7 @@ "interpretation_buttons": { "buttons": { "preview": "Obtener Vista Previa de Datos de Salida", + "reset": "Restablecer", "yes": "Sí", "no": "No" }, @@ -264,6 +265,9 @@ "use_previous": "¿Desea usar su selección anterior como condición para realizar esta acción?", "previous_action": "Su acción anterior fue: ", "element_text": "en un elemento con texto " + }, + "notifications": { + "reset_success": "Vista previa restablecida correctamente" } }, "recording_page": { diff --git a/public/locales/ja.json b/public/locales/ja.json index b40cc6e6..b444c81a 100644 --- a/public/locales/ja.json +++ b/public/locales/ja.json @@ -246,11 +246,15 @@ "mimetype": "MIMEタイプ: ", "image_below": "画像は以下に表示されます:", "separator": "--------------------------------------------------" + }, + "notifications": { + "reset_success": "出力プレビューが正常にリセットされました" } }, "interpretation_buttons": { "buttons": { "preview": "出力データのプレビューを取得", + "reset": "リセット", "yes": "はい", "no": "いいえ" }, diff --git a/public/locales/zh.json b/public/locales/zh.json index 600fd821..27455ebe 100644 --- a/public/locales/zh.json +++ b/public/locales/zh.json @@ -246,11 +246,15 @@ "mimetype": "MIME类型:", "image_below": "图片显示如下:", "separator": "--------------------------------------------------" + }, + "notifications": { + "reset_success": "输出预览已成功重置" } }, "interpretation_buttons": { "buttons": { "preview": "获取输出数据预览", + "reset": "重置", "yes": "是", "no": "否" }, diff --git a/src/components/molecules/InterpretationLog.tsx b/src/components/molecules/InterpretationLog.tsx index 0a771535..227e621c 100644 --- a/src/components/molecules/InterpretationLog.tsx +++ b/src/components/molecules/InterpretationLog.tsx @@ -35,7 +35,7 @@ export const InterpretationLog: React.FC = ({ isOpen, se const { width } = useBrowserDimensionsStore(); const { socket } = useSocketStore(); - const { currentWorkflowActionsState } = useGlobalInfoStore(); + const { currentWorkflowActionsState, shouldResetInterpretationLog, notify } = useGlobalInfoStore(); const toggleDrawer = (newOpen: boolean) => (event: React.KeyboardEvent | React.MouseEvent) => { if ( @@ -94,6 +94,14 @@ export const InterpretationLog: React.FC = ({ isOpen, se setCustomValue(event.target.value); }; + useEffect(() => { + if (shouldResetInterpretationLog) { + setLog(''); + setTableData([]); + setBinaryData(null); + } + }, [shouldResetInterpretationLog]); + useEffect(() => { socket?.on('log', handleLog); socket?.on('serializableCallback', handleSerializableCallback); diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 224e0954..ba178b7b 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -57,7 +57,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture const [hoverStates, setHoverStates] = useState<{ [id: string]: boolean }>({}); const [browserStepIdList, setBrowserStepIdList] = useState([]); - const { lastAction, notify, currentWorkflowActionsState, setCurrentWorkflowActionsState } = useGlobalInfoStore(); + const { lastAction, notify, currentWorkflowActionsState, setCurrentWorkflowActionsState, resetInterpretationLog } = useGlobalInfoStore(); const { getText, startGetText, stopGetText, getScreenshot, startGetScreenshot, stopGetScreenshot, getList, startGetList, stopGetList, startPaginationMode, stopPaginationMode, paginationType, updatePaginationType, limitType, customLimit, updateLimitType, updateCustomLimit, stopLimitMode, startLimitMode, captureStage, setCaptureStage } = useActionContext(); const { browserSteps, updateBrowserTextStepLabel, deleteBrowserStep, addScreenshotStep, updateListTextFieldLabel, removeListTextField } = useBrowserSteps(); const { id, socket } = useSocketStore(); @@ -225,8 +225,9 @@ export const RightSidePanel: React.FC = ({ onFinishCapture if (hasTextSteps) { socket?.emit('action', { action: 'scrapeSchema', settings }); } + resetInterpretationLog(); onFinishCapture(); - }, [stopGetText, getTextSettingsObject, socket, browserSteps, confirmedTextSteps]); + }, [stopGetText, getTextSettingsObject, socket, browserSteps, confirmedTextSteps, resetInterpretationLog]); const getListSettingsObject = useCallback(() => { let settings: { diff --git a/src/context/globalInfo.tsx b/src/context/globalInfo.tsx index 58589c3a..ac281630 100644 --- a/src/context/globalInfo.tsx +++ b/src/context/globalInfo.tsx @@ -32,6 +32,8 @@ interface GlobalInfo { hasScreenshotAction: boolean; hasScrapeSchemaAction: boolean; }) => void; + shouldResetInterpretationLog: boolean; + resetInterpretationLog: () => void; }; class GlobalInfoStore implements Partial { @@ -53,6 +55,7 @@ class GlobalInfoStore implements Partial { hasScreenshotAction: false, hasScrapeSchemaAction: false, }; + shouldResetInterpretationLog = false; }; const globalInfoStore = new GlobalInfoStore(); @@ -71,6 +74,7 @@ export const GlobalInfoProvider = ({ children }: { children: JSX.Element }) => { const [recordingName, setRecordingName] = useState(globalInfoStore.recordingName); const [recordingUrl, setRecordingUrl] = useState(globalInfoStore.recordingUrl); const [currentWorkflowActionsState, setCurrentWorkflowActionsState] = useState(globalInfoStore.currentWorkflowActionsState); + const [shouldResetInterpretationLog, setShouldResetInterpretationLog] = useState(globalInfoStore.shouldResetInterpretationLog); const notify = (severity: 'error' | 'warning' | 'info' | 'success', message: string) => { setNotification({ severity, message, isOpen: true }); @@ -87,6 +91,14 @@ export const GlobalInfoProvider = ({ children }: { children: JSX.Element }) => { } } + const resetInterpretationLog = () => { + setShouldResetInterpretationLog(true); + // Reset the flag after a short delay to allow components to respond + setTimeout(() => { + setShouldResetInterpretationLog(false); + }, 100); + } + return ( { setRecordingUrl, currentWorkflowActionsState, setCurrentWorkflowActionsState, + shouldResetInterpretationLog, + resetInterpretationLog, }} > {children}