import React, { useState, useEffect } from "react"; import { GenericModal } from "../ui/GenericModal"; import { MenuItem, TextField, Typography, Switch, FormControlLabel } from "@mui/material"; import { Dropdown } from "../ui/DropdownMui"; import Button from "@mui/material/Button"; import { modalStyle } from "../recorder/AddWhereCondModal"; interface RunSettingsProps { isOpen: boolean; handleStart: (settings: RunSettings) => void; handleClose: () => void; isTask: boolean; params?: string[]; } export interface RunSettings { maxConcurrency: number; maxRepeats: number; debug: boolean; params?: any; } export const RunSettingsModal = ({ isOpen, handleStart, handleClose, isTask, params }: RunSettingsProps) => { const [settings, setSettings] = useState({ maxConcurrency: 1, maxRepeats: 1, debug: true, }); const [showInterpreterSettings, setShowInterpreterSettings] = useState(false); // Run immediately without modal if settings don't need to be shown useEffect(() => { if (!showInterpreterSettings) { handleStart(settings); // Start the run } // Ensure this runs only when the component mounts or settings change // eslint-disable-next-line react-hooks/exhaustive-deps }, [showInterpreterSettings]); // Do not render the modal if settings are not shown if (!showInterpreterSettings) { return null; } return (
{isTask && ( Recording parameters: {params?.map((item, index) => ( setSettings({ ...settings, params: settings.params ? { ...settings.params, [item]: e.target.value } : { [item]: e.target.value }, }) } /> ))} )} setShowInterpreterSettings(!showInterpreterSettings) } /> } label="Developer Mode Settings" sx={{ margin: "20px 0px" }} /> {showInterpreterSettings && ( setSettings({ ...settings, maxConcurrency: parseInt(e.target.value, 10), }) } defaultValue={settings.maxConcurrency} /> setSettings({ ...settings, maxRepeats: parseInt(e.target.value, 10), }) } defaultValue={settings.maxRepeats} /> setSettings({ ...settings, debug: e.target.value === "true", }) } > true false )}
); };