Merge branch 'develop' into ui-fix
This commit is contained in:
@@ -5,8 +5,13 @@ import { ScheduleSettings } from "../components/robot/ScheduleSettings";
|
||||
import { CreateRunResponse, ScheduleRunResponse } from "../pages/MainPage";
|
||||
import { apiUrl } from "../apiConfig";
|
||||
|
||||
interface CredentialInfo {
|
||||
value: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface Credentials {
|
||||
[key: string]: string;
|
||||
[key: string]: CredentialInfo;
|
||||
}
|
||||
|
||||
export const getStoredRecordings = async (): Promise<string[] | null> => {
|
||||
|
||||
@@ -29,20 +29,6 @@ export interface IntegrationSettings {
|
||||
data: string;
|
||||
}
|
||||
|
||||
// Helper functions to replace js-cookie functionality
|
||||
const getCookie = (name: string): string | null => {
|
||||
const value = `; ${document.cookie}`;
|
||||
const parts = value.split(`; ${name}=`);
|
||||
if (parts.length === 2) {
|
||||
return parts.pop()?.split(';').shift() || null;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const removeCookie = (name: string): void => {
|
||||
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
|
||||
};
|
||||
|
||||
export const IntegrationSettingsModal = ({
|
||||
isOpen,
|
||||
handleStart,
|
||||
@@ -154,17 +140,6 @@ export const IntegrationSettingsModal = ({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Check if there is a success message in cookies
|
||||
const status = getCookie("robot_auth_status");
|
||||
const message = getCookie("robot_auth_message");
|
||||
|
||||
if (status === "success" && message) {
|
||||
notify("success", message);
|
||||
// Clear the cookies after reading
|
||||
removeCookie("robot_auth_status");
|
||||
removeCookie("robot_auth_message");
|
||||
}
|
||||
|
||||
// Check if we're on the callback URL
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const code = urlParams.get("code");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { RecordingsTable } from "./RecordingsTable";
|
||||
import { Grid } from "@mui/material";
|
||||
import { RunSettings, RunSettingsModal } from "../run/RunSettings";
|
||||
@@ -8,6 +8,8 @@ import { RobotSettingsModal } from "./RobotSettings";
|
||||
import { RobotEditModal } from "./RobotEdit";
|
||||
import { RobotDuplicationModal } from "./RobotDuplicate";
|
||||
import { useNavigate, useLocation, useParams } from "react-router-dom";
|
||||
import { useGlobalInfoStore } from "../../context/globalInfo";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
interface RecordingsProps {
|
||||
handleEditRecording: (id: string, fileName: string) => void;
|
||||
@@ -26,6 +28,8 @@ export const Recordings = ({
|
||||
const location = useLocation();
|
||||
const { selectedRecordingId } = useParams();
|
||||
const [params, setParams] = useState<string[]>([]);
|
||||
const { notify } = useGlobalInfoStore();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleNavigate = (path: string, id: string, name: string, params: string[]) => {
|
||||
setParams(params);
|
||||
@@ -39,6 +43,31 @@ export const Recordings = ({
|
||||
navigate("/robots"); // Navigate back to the main robots page
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Helper function to get and clear a cookie
|
||||
const getAndClearCookie = (name: string) => {
|
||||
const value = document.cookie
|
||||
.split('; ')
|
||||
.find(row => row.startsWith(`${name}=`))
|
||||
?.split('=')[1];
|
||||
|
||||
if (value) {
|
||||
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
const authStatus = getAndClearCookie('robot_auth_status');
|
||||
const robotId = getAndClearCookie('robot_auth_robotId');
|
||||
|
||||
if (authStatus === 'success' && robotId) {
|
||||
notify(authStatus, t("recordingtable.notifications.auth_success"));
|
||||
|
||||
handleNavigate(`/robots/${robotId}/integrate`, robotId, "", []);''
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Determine which modal to open based on the current route
|
||||
const getCurrentModal = () => {
|
||||
const currentPath = location.pathname;
|
||||
|
||||
@@ -11,8 +11,32 @@ import TableRow from '@mui/material/TableRow';
|
||||
import { memo, useCallback, useEffect, useMemo } from "react";
|
||||
import { WorkflowFile } from "maxun-core";
|
||||
import SearchIcon from '@mui/icons-material/Search';
|
||||
import { IconButton, Button, Box, Typography, TextField, MenuItem, Menu, ListItemIcon, ListItemText, CircularProgress, RadioGroup, FormControlLabel, Radio } from "@mui/material";
|
||||
import { Schedule, DeleteForever, Edit, PlayCircle, Settings, Power, ContentCopy, MoreHoriz } from "@mui/icons-material";
|
||||
import {
|
||||
IconButton,
|
||||
Button,
|
||||
Box,
|
||||
Typography,
|
||||
TextField,
|
||||
MenuItem,
|
||||
Menu,
|
||||
ListItemIcon,
|
||||
ListItemText,
|
||||
CircularProgress,
|
||||
RadioGroup,
|
||||
FormControlLabel,
|
||||
Radio,
|
||||
Checkbox,
|
||||
} from "@mui/material";
|
||||
import {
|
||||
Schedule,
|
||||
DeleteForever,
|
||||
Edit,
|
||||
PlayCircle,
|
||||
Settings,
|
||||
Power,
|
||||
ContentCopy,
|
||||
MoreHoriz
|
||||
} from "@mui/icons-material";
|
||||
import { useGlobalInfoStore } from "../../context/globalInfo";
|
||||
import { checkRunsForRecording, deleteRecordingFromStorage, getStoredRecordings } from "../../api/storage";
|
||||
import { Add } from "@mui/icons-material";
|
||||
@@ -110,7 +134,14 @@ const TableRowMemoized = memo(({ row, columns, handlers }: any) => {
|
||||
});
|
||||
|
||||
|
||||
export const RecordingsTable = ({ handleEditRecording, handleRunRecording, handleScheduleRecording, handleIntegrateRecording, handleSettingsRecording, handleEditRobot, handleDuplicateRobot }: RecordingsTableProps) => {
|
||||
export const RecordingsTable = ({
|
||||
handleEditRecording,
|
||||
handleRunRecording,
|
||||
handleScheduleRecording,
|
||||
handleIntegrateRecording,
|
||||
handleSettingsRecording,
|
||||
handleEditRobot,
|
||||
handleDuplicateRobot }: RecordingsTableProps) => {
|
||||
const { t } = useTranslation();
|
||||
const [page, setPage] = React.useState(0);
|
||||
const [rowsPerPage, setRowsPerPage] = React.useState(10);
|
||||
@@ -128,7 +159,20 @@ export const RecordingsTable = ({ handleEditRecording, handleRunRecording, handl
|
||||
{ id: 'options', label: t('recordingtable.options'), minWidth: 80 },
|
||||
], [t]);
|
||||
|
||||
const { notify, setRecordings, browserId, setBrowserId, setInitialUrl, recordingUrl, setRecordingUrl, isLogin, setIsLogin, recordingName, setRecordingName, recordingId, setRecordingId } = useGlobalInfoStore();
|
||||
const {
|
||||
notify,
|
||||
setRecordings,
|
||||
browserId,
|
||||
setBrowserId,
|
||||
setInitialUrl,
|
||||
recordingUrl,
|
||||
setRecordingUrl,
|
||||
isLogin,
|
||||
setIsLogin,
|
||||
recordingName,
|
||||
setRecordingName,
|
||||
recordingId,
|
||||
setRecordingId } = useGlobalInfoStore();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleChangePage = useCallback((event: unknown, newPage: number) => {
|
||||
@@ -343,7 +387,7 @@ export const RecordingsTable = ({ handleEditRecording, handleRunRecording, handl
|
||||
onRowsPerPageChange={handleChangeRowsPerPage}
|
||||
/>
|
||||
<GenericModal isOpen={isModalOpen} onClose={() => setModalOpen(false)} modalStyle={modalStyle}>
|
||||
<div style={{ padding: '20px' }}>
|
||||
<div style={{ padding: '10px' }}>
|
||||
<Typography variant="h6" gutterBottom>{t('recordingtable.modal.title')}</Typography>
|
||||
<TextField
|
||||
label={t('recordingtable.modal.label')}
|
||||
@@ -351,21 +395,22 @@ export const RecordingsTable = ({ handleEditRecording, handleRunRecording, handl
|
||||
fullWidth
|
||||
value={recordingUrl}
|
||||
onChange={setBrowserRecordingUrl}
|
||||
style={{ marginBottom: '20px', marginTop: '20px' }}
|
||||
style={{ marginBottom: '10px', marginTop: '20px' }}
|
||||
/>
|
||||
|
||||
<Typography variant="h6" gutterBottom>{t('recordingtable.modal.login_title')}</Typography>
|
||||
<RadioGroup
|
||||
aria-labelledby="login-requirement-radio-group"
|
||||
name="login-requirement"
|
||||
value={isLogin ? 'yes' : 'no'}
|
||||
onChange={(e) => setIsLogin(e.target.value === 'yes')}
|
||||
style={{ marginBottom: '20px' }}
|
||||
>
|
||||
<FormControlLabel value="yes" control={<Radio />} label="Yes" />
|
||||
<FormControlLabel value="no" control={<Radio />} label="No" />
|
||||
</RadioGroup>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={isLogin}
|
||||
onChange={(e) => setIsLogin(e.target.checked)}
|
||||
color="primary"
|
||||
/>
|
||||
}
|
||||
label={t('recordingtable.modal.login_title')}
|
||||
style={{ marginBottom: '10px' }}
|
||||
/>
|
||||
|
||||
<br />
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
|
||||
@@ -21,19 +21,6 @@ interface RobotWorkflow {
|
||||
workflow: WhereWhatPair[];
|
||||
}
|
||||
|
||||
interface RobotEditOptions {
|
||||
name: string;
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
interface Credentials {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
interface CredentialVisibility {
|
||||
[key: string]: boolean;
|
||||
}
|
||||
|
||||
interface ScheduleConfig {
|
||||
runEvery: number;
|
||||
runEveryUnit: 'MINUTES' | 'HOURS' | 'DAYS' | 'WEEKS' | 'MONTHS';
|
||||
@@ -57,7 +44,6 @@ export interface RobotSettings {
|
||||
google_access_token?: string | null;
|
||||
google_refresh_token?: string | null;
|
||||
schedule?: ScheduleConfig | null;
|
||||
isLogin?: boolean;
|
||||
}
|
||||
|
||||
interface RobotSettingsProps {
|
||||
@@ -67,19 +53,60 @@ interface RobotSettingsProps {
|
||||
initialSettings?: RobotSettings | null;
|
||||
}
|
||||
|
||||
interface CredentialInfo {
|
||||
value: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface Credentials {
|
||||
[key: string]: CredentialInfo;
|
||||
}
|
||||
|
||||
interface CredentialVisibility {
|
||||
[key: string]: boolean;
|
||||
}
|
||||
|
||||
interface GroupedCredentials {
|
||||
passwords: string[];
|
||||
emails: string[];
|
||||
usernames: string[];
|
||||
others: string[];
|
||||
}
|
||||
|
||||
export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettings }: RobotSettingsProps) => {
|
||||
const { t } = useTranslation();
|
||||
const [robot, setRobot] = useState<RobotSettings | null>(null);
|
||||
const [credentials, setCredentials] = useState<Credentials>({});
|
||||
const { recordingId, notify } = useGlobalInfoStore();
|
||||
const [credentialSelectors, setCredentialSelectors] = useState<string[]>([]);
|
||||
const [credentialGroups, setCredentialGroups] = useState<GroupedCredentials>({
|
||||
passwords: [],
|
||||
emails: [],
|
||||
usernames: [],
|
||||
others: []
|
||||
});
|
||||
const [showPasswords, setShowPasswords] = useState<CredentialVisibility>({});
|
||||
|
||||
const handleClickShowPassword = (selector: string) => {
|
||||
setShowPasswords(prev => ({
|
||||
...prev,
|
||||
[selector]: !prev[selector]
|
||||
}));
|
||||
const isEmailPattern = (value: string): boolean => {
|
||||
return value.includes('@');
|
||||
};
|
||||
|
||||
const isUsernameSelector = (selector: string): boolean => {
|
||||
return selector.toLowerCase().includes('username') ||
|
||||
selector.toLowerCase().includes('user') ||
|
||||
selector.toLowerCase().includes('email');
|
||||
};
|
||||
|
||||
const determineCredentialType = (selector: string, info: CredentialInfo): 'password' | 'email' | 'username' | 'other' => {
|
||||
if (info.type === 'password' || selector.toLowerCase().includes('password')) {
|
||||
return 'password';
|
||||
}
|
||||
if (isEmailPattern(info.value) || selector.toLowerCase().includes('email')) {
|
||||
return 'email';
|
||||
}
|
||||
if (isUsernameSelector(selector)) {
|
||||
return 'username';
|
||||
}
|
||||
return 'other';
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -90,66 +117,110 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
||||
|
||||
useEffect(() => {
|
||||
if (robot?.recording?.workflow) {
|
||||
const selectors = findCredentialSelectors(robot.recording.workflow);
|
||||
setCredentialSelectors(selectors);
|
||||
|
||||
const initialCredentials = extractInitialCredentials(robot.recording.workflow);
|
||||
setCredentials(initialCredentials);
|
||||
const extractedCredentials = extractInitialCredentials(robot.recording.workflow);
|
||||
setCredentials(extractedCredentials);
|
||||
setCredentialGroups(groupCredentialsByType(extractedCredentials));
|
||||
}
|
||||
}, [robot]);
|
||||
|
||||
const findCredentialSelectors = (workflow: WhereWhatPair[]): string[] => {
|
||||
const selectors = new Set<string>();
|
||||
|
||||
workflow?.forEach(step => {
|
||||
step.what?.forEach(action => {
|
||||
if (
|
||||
(action.action === 'type' || action.action === 'press') &&
|
||||
action.args &&
|
||||
action.args[0] &&
|
||||
typeof action.args[0] === 'string'
|
||||
) {
|
||||
selectors.add(action.args[0]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return Array.from(selectors);
|
||||
};
|
||||
|
||||
const extractInitialCredentials = (workflow: any[]): Record<string, string> => {
|
||||
const credentials: Record<string, string> = {};
|
||||
const extractInitialCredentials = (workflow: any[]): Credentials => {
|
||||
const credentials: Credentials = {};
|
||||
|
||||
// Helper function to check if a character is printable
|
||||
const isPrintableCharacter = (char: string): boolean => {
|
||||
return char.length === 1 && !!char.match(/^[\x20-\x7E]$/);
|
||||
};
|
||||
|
||||
|
||||
// Process each step in the workflow
|
||||
workflow.forEach(step => {
|
||||
if (!step.what) return;
|
||||
|
||||
|
||||
// Keep track of the current input field being processed
|
||||
let currentSelector = '';
|
||||
let currentValue = '';
|
||||
let currentType = '';
|
||||
|
||||
// Process actions in sequence to maintain correct text state
|
||||
step.what.forEach((action: any) => {
|
||||
if (
|
||||
(action.action === 'type' || action.action === 'press') &&
|
||||
action.args?.length >= 2 &&
|
||||
(action.action === 'type' || action.action === 'press') &&
|
||||
action.args?.length >= 2 &&
|
||||
typeof action.args[1] === 'string'
|
||||
) {
|
||||
let currentSelector: string = action.args[0];
|
||||
let character: string = action.args[1];
|
||||
|
||||
if (!credentials.hasOwnProperty(currentSelector)) {
|
||||
credentials[currentSelector] = '';
|
||||
const selector: string = action.args[0];
|
||||
const character: string = action.args[1];
|
||||
const inputType: string = action.args[2] || '';
|
||||
|
||||
// Detect `input[type="password"]`
|
||||
if (!currentType && inputType.toLowerCase() === 'password') {
|
||||
currentType = 'password';
|
||||
}
|
||||
|
||||
if (isPrintableCharacter(character)) {
|
||||
credentials[currentSelector] += character;
|
||||
|
||||
// If we're dealing with a new selector, store the previous one
|
||||
if (currentSelector && selector !== currentSelector) {
|
||||
if (!credentials[currentSelector]) {
|
||||
credentials[currentSelector] = {
|
||||
value: currentValue,
|
||||
type: currentType
|
||||
};
|
||||
} else {
|
||||
credentials[currentSelector].value = currentValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Update current tracking variables
|
||||
if (selector !== currentSelector) {
|
||||
currentSelector = selector;
|
||||
currentValue = credentials[selector]?.value || '';
|
||||
currentType = inputType || credentials[selector]?.type || '';
|
||||
}
|
||||
|
||||
// Handle different types of key actions
|
||||
if (character === 'Backspace') {
|
||||
// Remove the last character when backspace is pressed
|
||||
currentValue = currentValue.slice(0, -1);
|
||||
} else if (isPrintableCharacter(character)) {
|
||||
// Add the character to the current value
|
||||
currentValue += character;
|
||||
}
|
||||
// Note: We ignore other special keys like 'Shift', 'Enter', etc.
|
||||
}
|
||||
});
|
||||
|
||||
// Store the final state of the last processed selector
|
||||
if (currentSelector) {
|
||||
credentials[currentSelector] = {
|
||||
value: currentValue,
|
||||
type: currentType
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return credentials;
|
||||
};
|
||||
|
||||
const groupCredentialsByType = (credentials: Credentials): GroupedCredentials => {
|
||||
return Object.entries(credentials).reduce((acc: GroupedCredentials, [selector, info]) => {
|
||||
const credentialType = determineCredentialType(selector, info);
|
||||
|
||||
switch (credentialType) {
|
||||
case 'password':
|
||||
acc.passwords.push(selector);
|
||||
break;
|
||||
case 'email':
|
||||
acc.emails.push(selector);
|
||||
break;
|
||||
case 'username':
|
||||
acc.usernames.push(selector);
|
||||
break;
|
||||
default:
|
||||
acc.others.push(selector);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, { passwords: [], emails: [], usernames: [], others: [] });
|
||||
};
|
||||
|
||||
const getRobot = async () => {
|
||||
if (recordingId) {
|
||||
const robot = await getStoredRecording(recordingId);
|
||||
@@ -157,7 +228,14 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
||||
} else {
|
||||
notify('error', t('robot_edit.notifications.update_failed'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleClickShowPassword = (selector: string) => {
|
||||
setShowPasswords(prev => ({
|
||||
...prev,
|
||||
[selector]: !prev[selector]
|
||||
}));
|
||||
};
|
||||
|
||||
const handleRobotNameChange = (newName: string) => {
|
||||
setRobot((prev) =>
|
||||
@@ -167,8 +245,11 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
||||
|
||||
const handleCredentialChange = (selector: string, value: string) => {
|
||||
setCredentials(prev => ({
|
||||
...prev,
|
||||
[selector]: value
|
||||
...prev,
|
||||
[selector]: {
|
||||
...prev[selector],
|
||||
value
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -177,7 +258,6 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
||||
if (!prev) return prev;
|
||||
|
||||
const updatedWorkflow = [...prev.recording.workflow];
|
||||
|
||||
if (
|
||||
updatedWorkflow.length > 0 &&
|
||||
updatedWorkflow[0]?.what &&
|
||||
@@ -193,21 +273,101 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
||||
});
|
||||
};
|
||||
|
||||
const renderAllCredentialFields = () => {
|
||||
return (
|
||||
<>
|
||||
{renderCredentialFields(
|
||||
credentialGroups.usernames,
|
||||
t('Username'),
|
||||
'text'
|
||||
)}
|
||||
|
||||
{renderCredentialFields(
|
||||
credentialGroups.emails,
|
||||
t('Email'),
|
||||
'text'
|
||||
)}
|
||||
|
||||
{renderCredentialFields(
|
||||
credentialGroups.passwords,
|
||||
t('Password'),
|
||||
'password'
|
||||
)}
|
||||
|
||||
{renderCredentialFields(
|
||||
credentialGroups.others,
|
||||
t('Other'),
|
||||
'text'
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const renderCredentialFields = (selectors: string[], headerText: string, defaultType: 'text' | 'password' = 'text') => {
|
||||
if (selectors.length === 0) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <Typography variant="h6" style={{ marginBottom: '20px' }}>
|
||||
{headerText}
|
||||
</Typography> */}
|
||||
{selectors.map((selector, index) => {
|
||||
const isVisible = showPasswords[selector];
|
||||
|
||||
return (
|
||||
<TextField
|
||||
key={selector}
|
||||
type={isVisible ? 'text' : 'password'}
|
||||
label={headerText === 'Other' ? `${`Input`} ${index + 1}` : headerText}
|
||||
value={credentials[selector]?.value || ''}
|
||||
onChange={(e) => handleCredentialChange(selector, e.target.value)}
|
||||
style={{ marginBottom: '20px' }}
|
||||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
<IconButton
|
||||
aria-label="Show input"
|
||||
onClick={() => handleClickShowPassword(selector)}
|
||||
edge="end"
|
||||
disabled={!credentials[selector]?.value}
|
||||
>
|
||||
{isVisible ? <Visibility /> : <VisibilityOff />}
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
if (!robot) return;
|
||||
|
||||
try {
|
||||
const credentialsForPayload = Object.entries(credentials).reduce((acc, [selector, info]) => {
|
||||
const enforceType = info.type === 'password' ? 'password' : 'text';
|
||||
|
||||
acc[selector] = {
|
||||
value: info.value,
|
||||
type: enforceType
|
||||
};
|
||||
return acc;
|
||||
}, {} as Record<string, CredentialInfo>);
|
||||
|
||||
const payload = {
|
||||
name: robot.recording_meta.name,
|
||||
limit: robot.recording.workflow[0]?.what[0]?.args?.[0]?.limit,
|
||||
credentials: credentials,
|
||||
credentials: credentialsForPayload,
|
||||
};
|
||||
|
||||
const success = await updateRecording(robot.recording_meta.id, payload);
|
||||
|
||||
if (success) {
|
||||
notify('success', t('robot_edit.notifications.update_success'));
|
||||
handleStart(robot); // Inform parent about the updated robot
|
||||
handleStart(robot);
|
||||
handleClose();
|
||||
|
||||
setTimeout(() => {
|
||||
@@ -233,87 +393,63 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
|
||||
{t('robot_edit.title')}
|
||||
</Typography>
|
||||
<Box style={{ display: 'flex', flexDirection: 'column' }}>
|
||||
{
|
||||
robot && (
|
||||
<>
|
||||
{robot && (
|
||||
<>
|
||||
<TextField
|
||||
label={t('robot_edit.change_name')}
|
||||
key="Robot Name"
|
||||
type='text'
|
||||
value={robot.recording_meta.name}
|
||||
onChange={(e) => handleRobotNameChange(e.target.value)}
|
||||
style={{ marginBottom: '20px' }}
|
||||
/>
|
||||
|
||||
{robot.recording.workflow?.[0]?.what?.[0]?.args?.[0]?.limit !== undefined && (
|
||||
<TextField
|
||||
label={t('robot_edit.change_name')}
|
||||
key="Robot Name"
|
||||
type='text'
|
||||
value={robot.recording_meta.name}
|
||||
onChange={(e) => handleRobotNameChange(e.target.value)}
|
||||
label={t('robot_edit.robot_limit')}
|
||||
type="number"
|
||||
value={robot.recording.workflow[0].what[0].args[0].limit || ''}
|
||||
onChange={(e) => {
|
||||
const value = parseInt(e.target.value, 10);
|
||||
if (value >= 1) {
|
||||
handleLimitChange(value);
|
||||
}
|
||||
}}
|
||||
inputProps={{ min: 1 }}
|
||||
style={{ marginBottom: '20px' }}
|
||||
/>
|
||||
{robot.recording.workflow?.[0]?.what?.[0]?.args?.[0]?.limit !== undefined && (
|
||||
<TextField
|
||||
label={t('robot_edit.robot_limit')}
|
||||
type="number"
|
||||
value={robot.recording.workflow[0].what[0].args[0].limit || ''}
|
||||
onChange={(e) => {
|
||||
const value = parseInt(e.target.value, 10);
|
||||
if (value >= 1) {
|
||||
handleLimitChange(value);
|
||||
}
|
||||
}}
|
||||
inputProps={{ min: 1 }}
|
||||
style={{ marginBottom: '20px' }}
|
||||
/>
|
||||
)}
|
||||
)}
|
||||
|
||||
{(robot.isLogin || credentialSelectors.length > 0) && (
|
||||
<>
|
||||
<Typography variant="h6" style={{ marginBottom: '20px' }}>
|
||||
{t('Login Credentials')}
|
||||
</Typography>
|
||||
|
||||
{credentialSelectors.map((selector) => (
|
||||
<TextField
|
||||
key={selector}
|
||||
type={showPasswords[selector] ? 'text' : 'password'}
|
||||
label={`Credential for ${selector}`}
|
||||
value={credentials[selector] || ''}
|
||||
onChange={(e) => handleCredentialChange(selector, e.target.value)}
|
||||
style={{ marginBottom: '20px' }}
|
||||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
<IconButton
|
||||
aria-label="toggle password visibility"
|
||||
onClick={() => handleClickShowPassword(selector)}
|
||||
edge="end"
|
||||
>
|
||||
{showPasswords[selector] ? <Visibility /> : <VisibilityOff />}
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
{(Object.keys(credentials).length > 0) && (
|
||||
<>
|
||||
<Typography variant="body1" style={{ marginBottom: '20px' }}>
|
||||
{t('Input Texts')}
|
||||
</Typography>
|
||||
{renderAllCredentialFields()}
|
||||
</>
|
||||
)}
|
||||
|
||||
<Box mt={2} display="flex" justifyContent="flex-end">
|
||||
<Button variant="contained" color="primary" onClick={handleSave}>
|
||||
{t('robot_edit.save')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleClose}
|
||||
color="primary"
|
||||
variant="outlined"
|
||||
style={{ marginLeft: '10px' }}
|
||||
sx={{
|
||||
color: '#ff00c3 !important',
|
||||
borderColor: '#ff00c3 !important',
|
||||
backgroundColor: 'whitesmoke !important',
|
||||
}}>
|
||||
{t('robot_edit.cancel')}
|
||||
</Button>
|
||||
</Box>
|
||||
</>
|
||||
)
|
||||
}
|
||||
<Box mt={2} display="flex" justifyContent="flex-end">
|
||||
<Button variant="contained" color="primary" onClick={handleSave}>
|
||||
{t('robot_edit.save')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleClose}
|
||||
color="primary"
|
||||
variant="outlined"
|
||||
style={{ marginLeft: '10px' }}
|
||||
sx={{
|
||||
color: '#ff00c3 !important',
|
||||
borderColor: '#ff00c3 !important',
|
||||
backgroundColor: 'whitesmoke !important',
|
||||
}}>
|
||||
{t('robot_edit.cancel')}
|
||||
</Button>
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
</>
|
||||
</GenericModal>
|
||||
);
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user