chore: lint
This commit is contained in:
@@ -126,35 +126,35 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
|||||||
|
|
||||||
function extractInitialCredentials(workflow: any[]): Credentials {
|
function extractInitialCredentials(workflow: any[]): Credentials {
|
||||||
const credentials: Credentials = {};
|
const credentials: Credentials = {};
|
||||||
|
|
||||||
const isPrintableCharacter = (char: string): boolean => {
|
const isPrintableCharacter = (char: string): boolean => {
|
||||||
return char.length === 1 && !!char.match(/^[\x20-\x7E]$/);
|
return char.length === 1 && !!char.match(/^[\x20-\x7E]$/);
|
||||||
};
|
};
|
||||||
|
|
||||||
workflow.forEach(step => {
|
workflow.forEach(step => {
|
||||||
if (!step.what) return;
|
if (!step.what) return;
|
||||||
|
|
||||||
let currentSelector = '';
|
let currentSelector = '';
|
||||||
let currentValue = '';
|
let currentValue = '';
|
||||||
let currentType = '';
|
let currentType = '';
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
while (i < step.what.length) {
|
while (i < step.what.length) {
|
||||||
const action = step.what[i];
|
const action = step.what[i];
|
||||||
|
|
||||||
if (!action.action || !action.args?.[0]) {
|
if (!action.action || !action.args?.[0]) {
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const selector = action.args[0];
|
const selector = action.args[0];
|
||||||
|
|
||||||
// Handle full word type actions first
|
// Handle full word type actions first
|
||||||
if (action.action === 'type' &&
|
if (action.action === 'type' &&
|
||||||
action.args?.length >= 2 &&
|
action.args?.length >= 2 &&
|
||||||
typeof action.args[1] === 'string' &&
|
typeof action.args[1] === 'string' &&
|
||||||
action.args[1].length > 1) {
|
action.args[1].length > 1) {
|
||||||
|
|
||||||
if (!credentials[selector]) {
|
if (!credentials[selector]) {
|
||||||
credentials[selector] = {
|
credentials[selector] = {
|
||||||
value: action.args[1],
|
value: action.args[1],
|
||||||
@@ -164,12 +164,12 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
|||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle character-by-character sequences (both type and press)
|
// Handle character-by-character sequences (both type and press)
|
||||||
if ((action.action === 'type' || action.action === 'press') &&
|
if ((action.action === 'type' || action.action === 'press') &&
|
||||||
action.args?.length >= 2 &&
|
action.args?.length >= 2 &&
|
||||||
typeof action.args[1] === 'string') {
|
typeof action.args[1] === 'string') {
|
||||||
|
|
||||||
if (selector !== currentSelector) {
|
if (selector !== currentSelector) {
|
||||||
if (currentSelector && currentValue) {
|
if (currentSelector && currentValue) {
|
||||||
credentials[currentSelector] = {
|
credentials[currentSelector] = {
|
||||||
@@ -181,23 +181,23 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
|||||||
currentValue = credentials[selector]?.value || '';
|
currentValue = credentials[selector]?.value || '';
|
||||||
currentType = action.args[2] || credentials[selector]?.type || 'text';
|
currentType = action.args[2] || credentials[selector]?.type || 'text';
|
||||||
}
|
}
|
||||||
|
|
||||||
const character = action.args[1];
|
const character = action.args[1];
|
||||||
|
|
||||||
if (isPrintableCharacter(character)) {
|
if (isPrintableCharacter(character)) {
|
||||||
currentValue += character;
|
currentValue += character;
|
||||||
} else if (character === 'Backspace') {
|
} else if (character === 'Backspace') {
|
||||||
currentValue = currentValue.slice(0, -1);
|
currentValue = currentValue.slice(0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentType && action.args[2]?.toLowerCase() === 'password') {
|
if (!currentType && action.args[2]?.toLowerCase() === 'password') {
|
||||||
currentType = 'password';
|
currentType = 'password';
|
||||||
}
|
}
|
||||||
|
|
||||||
let j = i + 1;
|
let j = i + 1;
|
||||||
while (j < step.what.length) {
|
while (j < step.what.length) {
|
||||||
const nextAction = step.what[j];
|
const nextAction = step.what[j];
|
||||||
if (!nextAction.action || !nextAction.args?.[0] ||
|
if (!nextAction.action || !nextAction.args?.[0] ||
|
||||||
nextAction.args[0] !== selector ||
|
nextAction.args[0] !== selector ||
|
||||||
(nextAction.action !== 'type' && nextAction.action !== 'press')) {
|
(nextAction.action !== 'type' && nextAction.action !== 'press')) {
|
||||||
break;
|
break;
|
||||||
@@ -209,18 +209,18 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
|||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
credentials[currentSelector] = {
|
credentials[currentSelector] = {
|
||||||
value: currentValue,
|
value: currentValue,
|
||||||
type: currentType
|
type: currentType
|
||||||
};
|
};
|
||||||
|
|
||||||
i = j;
|
i = j;
|
||||||
} else {
|
} else {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentSelector && currentValue) {
|
if (currentSelector && currentValue) {
|
||||||
credentials[currentSelector] = {
|
credentials[currentSelector] = {
|
||||||
value: currentValue,
|
value: currentValue,
|
||||||
@@ -228,7 +228,7 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return credentials;
|
return credentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,15 +459,15 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
|||||||
onChange={(e) => handleRobotNameChange(e.target.value)}
|
onChange={(e) => handleRobotNameChange(e.target.value)}
|
||||||
style={{ marginBottom: '20px' }}
|
style={{ marginBottom: '20px' }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
label="Robot Target URL"
|
label="Robot Target URL"
|
||||||
key="Robot Target URL"
|
key="Robot Target URL"
|
||||||
type='text'
|
type='text'
|
||||||
value={targetUrl || ''}
|
value={targetUrl || ''}
|
||||||
onChange={(e) => handleTargetUrlChange(e.target.value)}
|
onChange={(e) => handleTargetUrlChange(e.target.value)}
|
||||||
style={{ marginBottom: '20px', marginTop: '15px' }}
|
style={{ marginBottom: '20px', marginTop: '15px' }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{robot.recording.workflow?.[0]?.what?.[0]?.args?.[0]?.limit !== undefined && (
|
{robot.recording.workflow?.[0]?.what?.[0]?.args?.[0]?.limit !== undefined && (
|
||||||
<TextField
|
<TextField
|
||||||
|
|||||||
Reference in New Issue
Block a user