mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-26 14:19:24 +00:00
Tool flow
This commit is contained in:
parent
50afa105ce
commit
1136c00547
@ -125,13 +125,6 @@ export default function AutomationRun({ automation, onBack, onComplete }: Automa
|
||||
</Text>
|
||||
</Card>
|
||||
|
||||
{/* File Selection Warning */}
|
||||
{(!activeFiles || activeFiles.length === 0) && (
|
||||
<Alert color="orange" title={t('automate.sequence.noFiles', 'No Files Selected')}>
|
||||
{t('automate.sequence.noFilesDesc', 'Please select files to process before running the automation.')}
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{/* Progress Bar */}
|
||||
{isExecuting && (
|
||||
<div>
|
||||
|
@ -9,6 +9,7 @@ export interface FilesStepConfig {
|
||||
isCollapsed?: boolean;
|
||||
placeholder?: string;
|
||||
onCollapsedClick?: () => void;
|
||||
isVisible?: boolean;
|
||||
}
|
||||
|
||||
export interface MiddleStepConfig {
|
||||
@ -63,7 +64,7 @@ export function createToolFlow(config: ToolFlowConfig) {
|
||||
<Stack gap="sm" p="sm" h="95vh" w="100%" style={{ overflow: 'auto' }}>
|
||||
<ToolStepProvider forceStepNumbers={config.forceStepNumbers}>
|
||||
{/* Files Step */}
|
||||
{steps.createFilesStep({
|
||||
{config.files.isVisible !== false && steps.createFilesStep({
|
||||
selectedFiles: config.files.selectedFiles,
|
||||
isCollapsed: config.files.isCollapsed,
|
||||
placeholder: config.files.placeholder,
|
||||
|
@ -4,6 +4,7 @@ import { useFileContext } from "../contexts/FileContext";
|
||||
import { useToolFileSelection } from "../contexts/FileSelectionContext";
|
||||
|
||||
import { createToolFlow } from "../components/tools/shared/createToolFlow";
|
||||
import { createFilesToolStep } from "../components/tools/shared/filesToolStep";
|
||||
import AutomationSelection from "../components/tools/automate/AutomationSelection";
|
||||
import AutomationCreation, { AutomationMode } from "../components/tools/automate/AutomationCreation";
|
||||
import AutomationRun from "../components/tools/automate/AutomationRun";
|
||||
@ -83,36 +84,55 @@ const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
||||
}
|
||||
};
|
||||
|
||||
return createToolFlow({
|
||||
files: {
|
||||
selectedFiles: [],
|
||||
isCollapsed: hasResults, // Hide files step for automate tool
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
title: t('automate.selection.title', 'Automation Selection'),
|
||||
const createStep = (title: string, props: any, content?: React.ReactNode) => ({
|
||||
title,
|
||||
...props,
|
||||
content
|
||||
});
|
||||
|
||||
// Always create files step to avoid conditional hook calls
|
||||
const filesStep = createFilesToolStep(createStep, {
|
||||
selectedFiles,
|
||||
isCollapsed: hasResults,
|
||||
placeholder: t('automate.files.placeholder', 'Select files to process with this automation')
|
||||
});
|
||||
|
||||
const automationSteps = [
|
||||
createStep(t('automate.selection.title', 'Automation Selection'), {
|
||||
isVisible: true,
|
||||
isCollapsed: currentStep !== 'selection',
|
||||
onCollapsedClick: () => setCurrentStep('selection'),
|
||||
content: currentStep === 'selection' ? renderCurrentStep() : null
|
||||
},
|
||||
{
|
||||
title: stepData.mode === AutomationMode.EDIT
|
||||
onCollapsedClick: () => setCurrentStep('selection')
|
||||
}, currentStep === 'selection' ? renderCurrentStep() : null),
|
||||
|
||||
createStep(stepData.mode === AutomationMode.EDIT
|
||||
? t('automate.creation.editTitle', 'Edit Automation')
|
||||
: t('automate.creation.createTitle', 'Create Automation'),
|
||||
: t('automate.creation.createTitle', 'Create Automation'), {
|
||||
isVisible: currentStep === 'creation',
|
||||
isCollapsed: false,
|
||||
content: currentStep === 'creation' ? renderCurrentStep() : null
|
||||
},
|
||||
isCollapsed: false
|
||||
}, currentStep === 'creation' ? renderCurrentStep() : null),
|
||||
|
||||
// Files step - only visible during run mode
|
||||
{
|
||||
title: t('automate.run.title', 'Run Automation'),
|
||||
...filesStep,
|
||||
isVisible: currentStep === 'run'
|
||||
},
|
||||
|
||||
// Run step
|
||||
createStep(t('automate.run.title', 'Run Automation'), {
|
||||
isVisible: currentStep === 'run',
|
||||
isCollapsed: false,
|
||||
content: currentStep === 'run' ? renderCurrentStep() : null
|
||||
}
|
||||
],
|
||||
isCollapsed: false
|
||||
}, currentStep === 'run' ? renderCurrentStep() : null)
|
||||
];
|
||||
|
||||
return createToolFlow({
|
||||
files: {
|
||||
selectedFiles: currentStep === 'run' ? selectedFiles : [],
|
||||
isCollapsed: currentStep !== 'run' || hasResults,
|
||||
isVisible: false, // Hide the default files step since we add our own
|
||||
},
|
||||
steps: automationSteps,
|
||||
review: {
|
||||
isVisible: hasResults, // Hide review step for automate tool
|
||||
isVisible: hasResults,
|
||||
operation: automateOperation,
|
||||
title: t('automate.reviewTitle', 'Automation Results')
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user