mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-26 17:52:59 +02:00
Update AutomationRun.tsx
This commit is contained in:
parent
1c95c6a2e8
commit
0e1a42bbb1
@ -12,7 +12,12 @@ import { useResourceCleanup } from "../../../utils/resourceManager";
|
|||||||
interface AutomationRunProps {
|
interface AutomationRunProps {
|
||||||
automation: AutomationConfig;
|
automation: AutomationConfig;
|
||||||
onComplete: () => void;
|
onComplete: () => void;
|
||||||
automateOperation?: any; // TODO: Type this properly when available
|
automateOperation?: {
|
||||||
|
isLoading: boolean;
|
||||||
|
files: File[];
|
||||||
|
downloadUrl: string | null;
|
||||||
|
executeOperation: (params: any, files: File[]) => Promise<void>;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function AutomationRun({ automation, onComplete, automateOperation }: AutomationRunProps) {
|
export default function AutomationRun({ automation, onComplete, automateOperation }: AutomationRunProps) {
|
||||||
@ -27,12 +32,12 @@ export default function AutomationRun({ automation, onComplete, automateOperatio
|
|||||||
|
|
||||||
// Use the operation hook's loading state
|
// Use the operation hook's loading state
|
||||||
const isExecuting = automateOperation?.isLoading ?? false;
|
const isExecuting = automateOperation?.isLoading ?? false;
|
||||||
const hasResults = automateOperation?.files.length > 0 || automateOperation?.downloadUrl !== null;
|
const hasResults = (automateOperation?.files?.length ?? 0) > 0 || automateOperation?.downloadUrl !== null;
|
||||||
|
|
||||||
// Initialize execution steps from automation
|
// Initialize execution steps from automation
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (automation?.operations) {
|
if (automation?.operations) {
|
||||||
const steps = automation.operations.map((op: any, index: number) => {
|
const steps = automation.operations.map((op: { operation: string }, index: number) => {
|
||||||
const tool = toolRegistry[op.operation as keyof typeof toolRegistry];
|
const tool = toolRegistry[op.operation as keyof typeof toolRegistry];
|
||||||
return {
|
return {
|
||||||
id: `${op.operation}-${index}`,
|
id: `${op.operation}-${index}`,
|
||||||
@ -193,8 +198,8 @@ export default function AutomationRun({ automation, onComplete, automateOperatio
|
|||||||
<Group justify="space-between" mt="xl">
|
<Group justify="space-between" mt="xl">
|
||||||
<Button
|
<Button
|
||||||
leftSection={<PlayArrowIcon />}
|
leftSection={<PlayArrowIcon />}
|
||||||
onClick={executeAutomation}
|
onClick={() => { void executeAutomation(); }}
|
||||||
disabled={(isExecuting ?? !selectedFiles) ?? selectedFiles.length === 0}
|
disabled={isExecuting || !selectedFiles || selectedFiles.length === 0}
|
||||||
loading={isExecuting}
|
loading={isExecuting}
|
||||||
>
|
>
|
||||||
{isExecuting
|
{isExecuting
|
||||||
|
Loading…
Reference in New Issue
Block a user