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>
|
</Text>
|
||||||
</Card>
|
</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 */}
|
{/* Progress Bar */}
|
||||||
{isExecuting && (
|
{isExecuting && (
|
||||||
<div>
|
<div>
|
||||||
|
@ -9,6 +9,7 @@ export interface FilesStepConfig {
|
|||||||
isCollapsed?: boolean;
|
isCollapsed?: boolean;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
onCollapsedClick?: () => void;
|
onCollapsedClick?: () => void;
|
||||||
|
isVisible?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MiddleStepConfig {
|
export interface MiddleStepConfig {
|
||||||
@ -63,7 +64,7 @@ export function createToolFlow(config: ToolFlowConfig) {
|
|||||||
<Stack gap="sm" p="sm" h="95vh" w="100%" style={{ overflow: 'auto' }}>
|
<Stack gap="sm" p="sm" h="95vh" w="100%" style={{ overflow: 'auto' }}>
|
||||||
<ToolStepProvider forceStepNumbers={config.forceStepNumbers}>
|
<ToolStepProvider forceStepNumbers={config.forceStepNumbers}>
|
||||||
{/* Files Step */}
|
{/* Files Step */}
|
||||||
{steps.createFilesStep({
|
{config.files.isVisible !== false && steps.createFilesStep({
|
||||||
selectedFiles: config.files.selectedFiles,
|
selectedFiles: config.files.selectedFiles,
|
||||||
isCollapsed: config.files.isCollapsed,
|
isCollapsed: config.files.isCollapsed,
|
||||||
placeholder: config.files.placeholder,
|
placeholder: config.files.placeholder,
|
||||||
|
@ -4,6 +4,7 @@ import { useFileContext } from "../contexts/FileContext";
|
|||||||
import { useToolFileSelection } from "../contexts/FileSelectionContext";
|
import { useToolFileSelection } from "../contexts/FileSelectionContext";
|
||||||
|
|
||||||
import { createToolFlow } from "../components/tools/shared/createToolFlow";
|
import { createToolFlow } from "../components/tools/shared/createToolFlow";
|
||||||
|
import { createFilesToolStep } from "../components/tools/shared/filesToolStep";
|
||||||
import AutomationSelection from "../components/tools/automate/AutomationSelection";
|
import AutomationSelection from "../components/tools/automate/AutomationSelection";
|
||||||
import AutomationCreation, { AutomationMode } from "../components/tools/automate/AutomationCreation";
|
import AutomationCreation, { AutomationMode } from "../components/tools/automate/AutomationCreation";
|
||||||
import AutomationRun from "../components/tools/automate/AutomationRun";
|
import AutomationRun from "../components/tools/automate/AutomationRun";
|
||||||
@ -83,36 +84,55 @@ const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return createToolFlow({
|
const createStep = (title: string, props: any, content?: React.ReactNode) => ({
|
||||||
files: {
|
title,
|
||||||
selectedFiles: [],
|
...props,
|
||||||
isCollapsed: hasResults, // Hide files step for automate tool
|
content
|
||||||
},
|
});
|
||||||
steps: [
|
|
||||||
{
|
// Always create files step to avoid conditional hook calls
|
||||||
title: t('automate.selection.title', 'Automation Selection'),
|
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,
|
isVisible: true,
|
||||||
isCollapsed: currentStep !== 'selection',
|
isCollapsed: currentStep !== 'selection',
|
||||||
onCollapsedClick: () => setCurrentStep('selection'),
|
onCollapsedClick: () => setCurrentStep('selection')
|
||||||
content: currentStep === 'selection' ? renderCurrentStep() : null
|
}, currentStep === 'selection' ? renderCurrentStep() : null),
|
||||||
},
|
|
||||||
{
|
createStep(stepData.mode === AutomationMode.EDIT
|
||||||
title: stepData.mode === AutomationMode.EDIT
|
|
||||||
? t('automate.creation.editTitle', 'Edit Automation')
|
? t('automate.creation.editTitle', 'Edit Automation')
|
||||||
: t('automate.creation.createTitle', 'Create Automation'),
|
: t('automate.creation.createTitle', 'Create Automation'), {
|
||||||
isVisible: currentStep === 'creation',
|
isVisible: currentStep === 'creation',
|
||||||
isCollapsed: false,
|
isCollapsed: false
|
||||||
content: currentStep === 'creation' ? renderCurrentStep() : null
|
}, 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',
|
isVisible: currentStep === 'run',
|
||||||
isCollapsed: false,
|
isCollapsed: false
|
||||||
content: currentStep === 'run' ? renderCurrentStep() : null
|
}, 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: {
|
review: {
|
||||||
isVisible: hasResults, // Hide review step for automate tool
|
isVisible: hasResults,
|
||||||
operation: automateOperation,
|
operation: automateOperation,
|
||||||
title: t('automate.reviewTitle', 'Automation Results')
|
title: t('automate.reviewTitle', 'Automation Results')
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user