Merge pull request #855 from RohitR311/edit-page
fix: add default names for captured action data
This commit is contained in:
@@ -543,17 +543,50 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
|
|||||||
const screenshotInputs: JSX.Element[] = [];
|
const screenshotInputs: JSX.Element[] = [];
|
||||||
const listInputs: JSX.Element[] = [];
|
const listInputs: JSX.Element[] = [];
|
||||||
|
|
||||||
|
let textCount = 0;
|
||||||
|
let screenshotCount = 0;
|
||||||
|
let listCount = 0;
|
||||||
|
|
||||||
robot.recording.workflow.forEach((pair, pairIndex) => {
|
robot.recording.workflow.forEach((pair, pairIndex) => {
|
||||||
if (!pair.what) return;
|
if (!pair.what) return;
|
||||||
|
|
||||||
pair.what.forEach((action, actionIndex) => {
|
pair.what.forEach((action, actionIndex) => {
|
||||||
if (!editableActions.has(String(action.action))) return;
|
if (!editableActions.has(String(action.action))) return;
|
||||||
|
|
||||||
const currentName =
|
let currentName =
|
||||||
action.name ||
|
action.name ||
|
||||||
(action.args && action.args[0] && typeof action.args[0] === 'object' && action.args[0].__name) ||
|
(action.args && action.args[0] && typeof action.args[0] === 'object' && action.args[0].__name) ||
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
if (!currentName) {
|
||||||
|
switch (action.action) {
|
||||||
|
case 'scrapeSchema':
|
||||||
|
textCount++;
|
||||||
|
currentName = `Text ${textCount}`;
|
||||||
|
break;
|
||||||
|
case 'screenshot':
|
||||||
|
screenshotCount++;
|
||||||
|
currentName = `Screenshot ${screenshotCount}`;
|
||||||
|
break;
|
||||||
|
case 'scrapeList':
|
||||||
|
listCount++;
|
||||||
|
currentName = `List ${listCount}`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (action.action) {
|
||||||
|
case 'scrapeSchema':
|
||||||
|
textCount++;
|
||||||
|
break;
|
||||||
|
case 'screenshot':
|
||||||
|
screenshotCount++;
|
||||||
|
break;
|
||||||
|
case 'scrapeList':
|
||||||
|
listCount++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const textField = (
|
const textField = (
|
||||||
<TextField
|
<TextField
|
||||||
key={`action-name-${pairIndex}-${actionIndex}`}
|
key={`action-name-${pairIndex}-${actionIndex}`}
|
||||||
@@ -579,6 +612,34 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (textInputs.length === 1 && textCount === 1) {
|
||||||
|
robot.recording.workflow.forEach((pair, pairIndex) => {
|
||||||
|
if (!pair.what) return;
|
||||||
|
|
||||||
|
pair.what.forEach((action, actionIndex) => {
|
||||||
|
if (action.action === 'scrapeSchema') {
|
||||||
|
const existingName =
|
||||||
|
action.name ||
|
||||||
|
(action.args && action.args[0] && typeof action.args[0] === 'object' && action.args[0].__name) ||
|
||||||
|
'';
|
||||||
|
|
||||||
|
const currentName = !existingName ? 'Texts' : existingName;
|
||||||
|
|
||||||
|
textInputs[0] = (
|
||||||
|
<TextField
|
||||||
|
key={`action-name-${pairIndex}-${actionIndex}`}
|
||||||
|
type="text"
|
||||||
|
value={currentName}
|
||||||
|
onChange={(e) => handleActionNameChange(pairIndex, actionIndex, e.target.value)}
|
||||||
|
style={{ marginBottom: '12px' }}
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const hasAnyInputs = textInputs.length > 0 || screenshotInputs.length > 0 || listInputs.length > 0;
|
const hasAnyInputs = textInputs.length > 0 || screenshotInputs.length > 0 || listInputs.length > 0;
|
||||||
if (!hasAnyInputs) return null;
|
if (!hasAnyInputs) return null;
|
||||||
|
|
||||||
|
|||||||
@@ -87,8 +87,8 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe
|
|||||||
const hasOldFormat = !row.serializableOutput.scrapeSchema && !row.serializableOutput.scrapeList && Object.keys(row.serializableOutput).length > 0;
|
const hasOldFormat = !row.serializableOutput.scrapeSchema && !row.serializableOutput.scrapeList && Object.keys(row.serializableOutput).length > 0;
|
||||||
|
|
||||||
if (hasLegacySchema || hasLegacyList || hasOldFormat) {
|
if (hasLegacySchema || hasLegacyList || hasOldFormat) {
|
||||||
setIsLegacyData(true);
|
|
||||||
processLegacyData(row.serializableOutput);
|
processLegacyData(row.serializableOutput);
|
||||||
|
setIsLegacyData(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,11 +154,12 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe
|
|||||||
const data = legacyOutput[key];
|
const data = legacyOutput[key];
|
||||||
|
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
const isNestedArray = data.length > 0 && Array.isArray(data[0]);
|
const firstNonNullElement = data.find(item => item !== null && item !== undefined);
|
||||||
|
const isNestedArray = firstNonNullElement && Array.isArray(firstNonNullElement);
|
||||||
|
|
||||||
if (isNestedArray) {
|
if (isNestedArray) {
|
||||||
data.forEach((subArray, index) => {
|
data.forEach((subArray, index) => {
|
||||||
if (Array.isArray(subArray) && subArray.length > 0) {
|
if (subArray !== null && subArray !== undefined && Array.isArray(subArray) && subArray.length > 0) {
|
||||||
const filteredData = subArray.filter(row =>
|
const filteredData = subArray.filter(row =>
|
||||||
row && typeof row === 'object' && Object.values(row).some(value => value !== undefined && value !== "")
|
row && typeof row === 'object' && Object.values(row).some(value => value !== undefined && value !== "")
|
||||||
);
|
);
|
||||||
@@ -171,7 +172,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const filteredData = data.filter(row =>
|
const filteredData = data.filter(row =>
|
||||||
row && typeof row === 'object' && Object.values(row).some(value => value !== undefined && value !== "")
|
row && typeof row === 'object' && !Array.isArray(row) && Object.values(row).some(value => value !== undefined && value !== "")
|
||||||
);
|
);
|
||||||
|
|
||||||
if (filteredData.length > 0) {
|
if (filteredData.length > 0) {
|
||||||
@@ -208,7 +209,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe
|
|||||||
|
|
||||||
if (Array.isArray(schemaOutput)) {
|
if (Array.isArray(schemaOutput)) {
|
||||||
const filteredData = schemaOutput.filter(row =>
|
const filteredData = schemaOutput.filter(row =>
|
||||||
row && Object.values(row).some(value => value !== undefined && value !== "")
|
row && typeof row === 'object' && Object.values(row).some(value => value !== undefined && value !== "")
|
||||||
);
|
);
|
||||||
|
|
||||||
if (filteredData.length > 0) {
|
if (filteredData.length > 0) {
|
||||||
@@ -231,7 +232,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe
|
|||||||
const data = schemaOutput[key];
|
const data = schemaOutput[key];
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
const filteredData = data.filter(row =>
|
const filteredData = data.filter(row =>
|
||||||
Object.values(row).some(value => value !== undefined && value !== "")
|
row && typeof row === 'object' && Object.values(row).some(value => value !== undefined && value !== "")
|
||||||
);
|
);
|
||||||
|
|
||||||
dataByKey[key] = filteredData;
|
dataByKey[key] = filteredData;
|
||||||
@@ -272,7 +273,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe
|
|||||||
const tableData = scrapeListData[key];
|
const tableData = scrapeListData[key];
|
||||||
if (Array.isArray(tableData) && tableData.length > 0) {
|
if (Array.isArray(tableData) && tableData.length > 0) {
|
||||||
const filteredData = tableData.filter(row =>
|
const filteredData = tableData.filter(row =>
|
||||||
Object.values(row).some(value => value !== undefined && value !== "")
|
row && typeof row === 'object' && Object.values(row).some(value => value !== undefined && value !== "")
|
||||||
);
|
);
|
||||||
if (filteredData.length > 0) {
|
if (filteredData.length > 0) {
|
||||||
tablesList.push(filteredData);
|
tablesList.push(filteredData);
|
||||||
|
|||||||
@@ -564,14 +564,15 @@ class ClientSelectorGenerator {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element.children.length > 0) {
|
const text = (element.textContent || "").trim();
|
||||||
return false;
|
const hasVisibleText = text.length > 0;
|
||||||
|
|
||||||
|
if (hasVisibleText || element.querySelector("svg")) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = (element.textContent || "").trim();
|
if (element.children.length > 0) {
|
||||||
|
return false;
|
||||||
if (text.length > 0) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user