mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-26 06:09:23 +00:00
Preview file
This commit is contained in:
parent
888bac9408
commit
456d3e61ad
@ -134,7 +134,10 @@ export function ToolWorkflowProvider({ children }: ToolWorkflowProviderProps) {
|
|||||||
|
|
||||||
const setPreviewFile = useCallback((file: File | null) => {
|
const setPreviewFile = useCallback((file: File | null) => {
|
||||||
dispatch({ type: 'SET_PREVIEW_FILE', payload: file });
|
dispatch({ type: 'SET_PREVIEW_FILE', payload: file });
|
||||||
}, []);
|
if (file) {
|
||||||
|
actions.setMode('viewer');
|
||||||
|
}
|
||||||
|
}, [actions]);
|
||||||
|
|
||||||
const setPageEditorFunctions = useCallback((functions: PageEditorFunctions | null) => {
|
const setPageEditorFunctions = useCallback((functions: PageEditorFunctions | null) => {
|
||||||
dispatch({ type: 'SET_PAGE_EDITOR_FUNCTIONS', payload: functions });
|
dispatch({ type: 'SET_PAGE_EDITOR_FUNCTIONS', payload: functions });
|
||||||
|
@ -2,6 +2,7 @@ import React, { useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useFileContext } from "../contexts/FileContext";
|
import { useFileContext } from "../contexts/FileContext";
|
||||||
import { useFileSelection } from "../contexts/FileContext";
|
import { useFileSelection } from "../contexts/FileContext";
|
||||||
|
import { useNavigation } from "../contexts/NavigationContext";
|
||||||
|
|
||||||
import { createToolFlow } from "../components/tools/shared/createToolFlow";
|
import { createToolFlow } from "../components/tools/shared/createToolFlow";
|
||||||
import { createFilesToolStep } from "../components/tools/shared/FilesToolStep";
|
import { createFilesToolStep } from "../components/tools/shared/FilesToolStep";
|
||||||
@ -19,6 +20,7 @@ import { AUTOMATION_STEPS } from "../constants/automation";
|
|||||||
const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { selectedFiles } = useFileSelection();
|
const { selectedFiles } = useFileSelection();
|
||||||
|
const { setMode } = useNavigation();
|
||||||
|
|
||||||
const [currentStep, setCurrentStep] = useState<'selection' | 'creation' | 'run'>(AUTOMATION_STEPS.SELECTION);
|
const [currentStep, setCurrentStep] = useState<'selection' | 'creation' | 'run'>(AUTOMATION_STEPS.SELECTION);
|
||||||
const [stepData, setStepData] = useState<AutomationStepData>({ step: AUTOMATION_STEPS.SELECTION });
|
const [stepData, setStepData] = useState<AutomationStepData>({ step: AUTOMATION_STEPS.SELECTION });
|
||||||
@ -33,13 +35,13 @@ const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
|||||||
if (currentStep === AUTOMATION_STEPS.RUN && data.step !== AUTOMATION_STEPS.RUN) {
|
if (currentStep === AUTOMATION_STEPS.RUN && data.step !== AUTOMATION_STEPS.RUN) {
|
||||||
automateOperation.resetResults();
|
automateOperation.resetResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If navigating to run step with a different automation, reset results
|
// If navigating to run step with a different automation, reset results
|
||||||
if (data.step === AUTOMATION_STEPS.RUN && data.automation &&
|
if (data.step === AUTOMATION_STEPS.RUN && data.automation &&
|
||||||
stepData.automation && data.automation.id !== stepData.automation.id) {
|
stepData.automation && data.automation.id !== stepData.automation.id) {
|
||||||
automateOperation.resetResults();
|
automateOperation.resetResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
setStepData(data);
|
setStepData(data);
|
||||||
setCurrentStep(data.step);
|
setCurrentStep(data.step);
|
||||||
};
|
};
|
||||||
@ -47,7 +49,7 @@ const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
|||||||
const handleComplete = () => {
|
const handleComplete = () => {
|
||||||
// Reset automation results when completing
|
// Reset automation results when completing
|
||||||
automateOperation.resetResults();
|
automateOperation.resetResults();
|
||||||
|
|
||||||
// Reset to selection step
|
// Reset to selection step
|
||||||
setCurrentStep(AUTOMATION_STEPS.SELECTION);
|
setCurrentStep(AUTOMATION_STEPS.SELECTION);
|
||||||
setStepData({ step: AUTOMATION_STEPS.SELECTION });
|
setStepData({ step: AUTOMATION_STEPS.SELECTION });
|
||||||
@ -160,7 +162,11 @@ const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
|||||||
review: {
|
review: {
|
||||||
isVisible: hasResults,
|
isVisible: hasResults,
|
||||||
operation: automateOperation,
|
operation: automateOperation,
|
||||||
title: t('automate.reviewTitle', 'Automation Results')
|
title: t('automate.reviewTitle', 'Automation Results'),
|
||||||
|
onFileClick: (file: File) => {
|
||||||
|
onPreviewFile?.(file);
|
||||||
|
setMode('viewer');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user