Skip to content

Commit b032de4

Browse files
authored
Merge pull request #854 from getmaxun/edit-page
feat: group action inputs by type
2 parents bbb0508 + f5e9cec commit b032de4

File tree

2 files changed

+47
-9
lines changed

2 files changed

+47
-9
lines changed

src/components/robot/pages/RobotConfigPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export const RobotConfigPage: React.FC<RobotConfigPageProps> = ({
6262
<Box sx={{
6363
maxWidth: 1000,
6464
margin: '50px auto',
65-
maxHeight: '100vh',
6665
display: 'flex',
6766
flexDirection: 'column',
6867
width: '1000px',

src/components/robot/pages/RobotEditPage.tsx

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
506506

507507
return (
508508
<>
509-
<Typography variant="body1" style={{ marginBottom: "20px" }}>
509+
<Typography variant="h6" style={{ marginBottom: "20px", marginTop: "20px" }}>
510510
{t("List Limits")}
511511
</Typography>
512512

@@ -539,22 +539,22 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
539539
if (!robot || !robot.recording || !robot.recording.workflow) return null;
540540

541541
const editableActions = new Set(['screenshot', 'scrapeList', 'scrapeSchema']);
542-
const inputs: JSX.Element[] = [];
542+
const textInputs: JSX.Element[] = [];
543+
const screenshotInputs: JSX.Element[] = [];
544+
const listInputs: JSX.Element[] = [];
543545

544546
robot.recording.workflow.forEach((pair, pairIndex) => {
545547
if (!pair.what) return;
546548

547549
pair.what.forEach((action, actionIndex) => {
548-
// Only show editable name inputs for meaningful action types
549550
if (!editableActions.has(String(action.action))) return;
550551

551-
// derive current name from possible fields
552552
const currentName =
553553
action.name ||
554554
(action.args && action.args[0] && typeof action.args[0] === 'object' && action.args[0].__name) ||
555555
'';
556556

557-
inputs.push(
557+
const textField = (
558558
<TextField
559559
key={`action-name-${pairIndex}-${actionIndex}`}
560560
type="text"
@@ -564,17 +564,56 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
564564
fullWidth
565565
/>
566566
);
567+
568+
switch (action.action) {
569+
case 'scrapeSchema':
570+
textInputs.push(textField);
571+
break;
572+
case 'screenshot':
573+
screenshotInputs.push(textField);
574+
break;
575+
case 'scrapeList':
576+
listInputs.push(textField);
577+
break;
578+
}
567579
});
568580
});
569581

570-
if (inputs.length === 0) return null;
582+
const hasAnyInputs = textInputs.length > 0 || screenshotInputs.length > 0 || listInputs.length > 0;
583+
if (!hasAnyInputs) return null;
571584

572585
return (
573586
<>
574-
<Typography variant="body1" style={{ marginBottom: '10px' }}>
587+
<Typography variant="h6" style={{ marginBottom: '20px', marginTop: '20px' }}>
575588
{t('Actions')}
576589
</Typography>
577-
{inputs}
590+
591+
{textInputs.length > 0 && (
592+
<>
593+
<Typography variant="subtitle1" style={{ marginBottom: '8px' }}>
594+
Texts
595+
</Typography>
596+
{textInputs}
597+
</>
598+
)}
599+
600+
{screenshotInputs.length > 0 && (
601+
<>
602+
<Typography variant="subtitle1" style={{ marginBottom: '8px', marginTop: textInputs.length > 0 ? '16px' : '0' }}>
603+
Screenshots
604+
</Typography>
605+
{screenshotInputs}
606+
</>
607+
)}
608+
609+
{listInputs.length > 0 && (
610+
<>
611+
<Typography variant="subtitle1" style={{ marginBottom: '8px', marginTop: (textInputs.length > 0 || screenshotInputs.length > 0) ? '16px' : '0' }}>
612+
Lists
613+
</Typography>
614+
{listInputs}
615+
</>
616+
)}
578617
</>
579618
);
580619
};

0 commit comments

Comments
 (0)