@@ -9,6 +9,7 @@ import {
|
|||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import { ArrowBack } from '@mui/icons-material';
|
import { ArrowBack } from '@mui/icons-material';
|
||||||
import { useNavigate, useLocation } from 'react-router-dom';
|
import { useNavigate, useLocation } from 'react-router-dom';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
interface RobotConfigPageProps {
|
interface RobotConfigPageProps {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -23,6 +24,7 @@ interface RobotConfigPageProps {
|
|||||||
icon?: React.ReactNode;
|
icon?: React.ReactNode;
|
||||||
onBackToSelection?: () => void;
|
onBackToSelection?: () => void;
|
||||||
backToSelectionText?: string;
|
backToSelectionText?: string;
|
||||||
|
onArrowBack?: () => void; // Optional prop for custom back action
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RobotConfigPage: React.FC<RobotConfigPageProps> = ({
|
export const RobotConfigPage: React.FC<RobotConfigPageProps> = ({
|
||||||
@@ -30,50 +32,72 @@ export const RobotConfigPage: React.FC<RobotConfigPageProps> = ({
|
|||||||
children,
|
children,
|
||||||
onSave,
|
onSave,
|
||||||
onCancel,
|
onCancel,
|
||||||
saveButtonText = "Save",
|
saveButtonText,
|
||||||
cancelButtonText = "Cancel",
|
cancelButtonText,
|
||||||
showSaveButton = true,
|
showSaveButton = true,
|
||||||
showCancelButton = true,
|
showCancelButton = true,
|
||||||
isLoading = false,
|
isLoading = false,
|
||||||
icon,
|
icon,
|
||||||
onBackToSelection,
|
onBackToSelection,
|
||||||
backToSelectionText = "← Back"
|
backToSelectionText,
|
||||||
|
onArrowBack,
|
||||||
}) => {
|
}) => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
if (onCancel) {
|
if (onCancel) {
|
||||||
onCancel();
|
onCancel();
|
||||||
|
} else {
|
||||||
|
// Try to determine the correct path based on current URL
|
||||||
|
const currentPath = location.pathname;
|
||||||
|
const basePath = currentPath.includes('/prebuilt-robots') ? '/prebuilt-robots' : '/robots';
|
||||||
|
navigate(basePath);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{
|
<Box sx={{
|
||||||
maxWidth: 1000,
|
maxWidth: 1000,
|
||||||
margin: 'auto',
|
margin: '50px auto',
|
||||||
px: 4,
|
maxHeight: '100vh',
|
||||||
py: 3,
|
|
||||||
minHeight: '80vh',
|
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
width: '1000px',
|
width: '1000px',
|
||||||
|
height: '100%',
|
||||||
|
overflowY: 'auto', // Allow scrolling if content exceeds height
|
||||||
}}>
|
}}>
|
||||||
|
{/* Header Section - Fixed Position */}
|
||||||
<Box sx={{
|
<Box sx={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
minHeight: '64px',
|
maxHeight: '64px',
|
||||||
mb: 2,
|
mb: 2,
|
||||||
flexShrink: 0
|
flexShrink: 0
|
||||||
}}>
|
}}>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={handleBack}
|
onClick={onArrowBack ? onArrowBack : handleBack}
|
||||||
sx={{
|
sx={{
|
||||||
mr: 2,
|
ml: -1,
|
||||||
|
mr: 1,
|
||||||
color: theme.palette.text.primary,
|
color: theme.palette.text.primary,
|
||||||
|
backgroundColor: 'transparent !important',
|
||||||
'&:hover': {
|
'&:hover': {
|
||||||
bgcolor: theme.palette.action.hover
|
backgroundColor: 'transparent !important',
|
||||||
}
|
},
|
||||||
|
'&:active': {
|
||||||
|
backgroundColor: 'transparent !important',
|
||||||
|
},
|
||||||
|
'&:focus': {
|
||||||
|
backgroundColor: 'transparent !important',
|
||||||
|
},
|
||||||
|
'&:focus-visible': {
|
||||||
|
backgroundColor: 'transparent !important',
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
|
disableRipple
|
||||||
>
|
>
|
||||||
<ArrowBack />
|
<ArrowBack />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
@@ -95,29 +119,32 @@ export const RobotConfigPage: React.FC<RobotConfigPageProps> = ({
|
|||||||
</Box>
|
</Box>
|
||||||
<Divider sx={{ mb: 4, flexShrink: 0 }} />
|
<Divider sx={{ mb: 4, flexShrink: 0 }} />
|
||||||
|
|
||||||
|
{/* Content Section */}
|
||||||
<Box sx={{
|
<Box sx={{
|
||||||
flex: 1,
|
flex: 1,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
minHeight: 0
|
minHeight: 0,
|
||||||
|
mt: 2,
|
||||||
|
mb: 3,
|
||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
{/* Action Buttons */}
|
||||||
{(showSaveButton || showCancelButton || onBackToSelection) && (
|
{(showSaveButton || showCancelButton || onBackToSelection) && (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: onBackToSelection ? 'space-between' : 'flex-end',
|
justifyContent: onBackToSelection ? 'space-between' : 'flex-start',
|
||||||
gap: 2,
|
gap: 2,
|
||||||
pt: 3,
|
pt: 3, // Reduce padding top to minimize space above
|
||||||
mt: 2,
|
|
||||||
borderTop: `1px solid ${theme.palette.divider}`,
|
borderTop: `1px solid ${theme.palette.divider}`,
|
||||||
flexShrink: 0,
|
flexShrink: 0,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
px: 3
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{/* Left side - Back to Selection button */}
|
||||||
{onBackToSelection && (
|
{onBackToSelection && (
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -128,10 +155,11 @@ export const RobotConfigPage: React.FC<RobotConfigPageProps> = ({
|
|||||||
borderColor: '#ff00c3 !important',
|
borderColor: '#ff00c3 !important',
|
||||||
backgroundColor: 'white !important',
|
backgroundColor: 'white !important',
|
||||||
}} >
|
}} >
|
||||||
{backToSelectionText}
|
{backToSelectionText || t("buttons.back_arrow")}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Right side - Save/Cancel buttons */}
|
||||||
<Box sx={{ display: 'flex', gap: 2 }}>
|
<Box sx={{ display: 'flex', gap: 2 }}>
|
||||||
{showCancelButton && (
|
{showCancelButton && (
|
||||||
<Button
|
<Button
|
||||||
@@ -143,7 +171,7 @@ export const RobotConfigPage: React.FC<RobotConfigPageProps> = ({
|
|||||||
borderColor: '#ff00c3 !important',
|
borderColor: '#ff00c3 !important',
|
||||||
backgroundColor: 'white !important',
|
backgroundColor: 'white !important',
|
||||||
}} >
|
}} >
|
||||||
{cancelButtonText}
|
{cancelButtonText || t("buttons.cancel")}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{showSaveButton && onSave && (
|
{showSaveButton && onSave && (
|
||||||
@@ -163,7 +191,7 @@ export const RobotConfigPage: React.FC<RobotConfigPageProps> = ({
|
|||||||
boxShadow: 'none',
|
boxShadow: 'none',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isLoading ? 'Saving...' : saveButtonText}
|
{isLoading ? t("buttons.saving") : (saveButtonText || t("buttons.save"))}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -19,10 +19,17 @@ import { useNavigate, useLocation } from "react-router-dom";
|
|||||||
interface RobotMeta {
|
interface RobotMeta {
|
||||||
name: string;
|
name: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
prebuiltId?: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
pairs: number;
|
pairs: number;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
params: any[];
|
params: any[];
|
||||||
|
type?: string;
|
||||||
|
description?: string;
|
||||||
|
usedByUsers?: number[];
|
||||||
|
subscriptionLevel?: number;
|
||||||
|
access?: string;
|
||||||
|
sample?: any[];
|
||||||
url?: string;
|
url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +139,10 @@ export const RobotDuplicatePage = ({ handleStart }: RobotSettingsProps) => {
|
|||||||
t("robot_duplication.notifications.duplicate_success")
|
t("robot_duplication.notifications.duplicate_success")
|
||||||
);
|
);
|
||||||
handleStart(robot);
|
handleStart(robot);
|
||||||
navigate("/robots");
|
const basePath = location.pathname.includes("/prebuilt-robots")
|
||||||
|
? "/prebuilt-robots"
|
||||||
|
: "/robots";
|
||||||
|
navigate(basePath);
|
||||||
} else {
|
} else {
|
||||||
notify("error", t("robot_duplication.notifications.duplicate_error"));
|
notify("error", t("robot_duplication.notifications.duplicate_error"));
|
||||||
}
|
}
|
||||||
@@ -145,7 +155,10 @@ export const RobotDuplicatePage = ({ handleStart }: RobotSettingsProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
navigate("/robots");
|
const basePath = location.pathname.includes("/prebuilt-robots")
|
||||||
|
? "/prebuilt-robots"
|
||||||
|
: "/robots";
|
||||||
|
navigate(basePath);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -156,6 +169,7 @@ export const RobotDuplicatePage = ({ handleStart }: RobotSettingsProps) => {
|
|||||||
saveButtonText={t("robot_duplication.buttons.duplicate")}
|
saveButtonText={t("robot_duplication.buttons.duplicate")}
|
||||||
cancelButtonText={t("robot_duplication.buttons.cancel")}
|
cancelButtonText={t("robot_duplication.buttons.cancel")}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
|
showCancelButton={false}
|
||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
<Box style={{ display: "flex", flexDirection: "column" }}>
|
<Box style={{ display: "flex", flexDirection: "column" }}>
|
||||||
|
|||||||
@@ -18,10 +18,17 @@ import { useNavigate, useLocation } from "react-router-dom";
|
|||||||
interface RobotMeta {
|
interface RobotMeta {
|
||||||
name: string;
|
name: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
prebuiltId?: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
pairs: number;
|
pairs: number;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
params: any[];
|
params: any[];
|
||||||
|
type?: string;
|
||||||
|
description?: string;
|
||||||
|
usedByUsers?: number[];
|
||||||
|
subscriptionLevel?: number;
|
||||||
|
access?: string;
|
||||||
|
sample?: any[];
|
||||||
url?: string;
|
url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +180,7 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
|
|||||||
action.args &&
|
action.args &&
|
||||||
action.args.length > 0
|
action.args.length > 0
|
||||||
) {
|
) {
|
||||||
|
// Check if first argument has a limit property
|
||||||
const arg = action.args[0];
|
const arg = action.args[0];
|
||||||
if (arg && typeof arg === "object" && "limit" in arg) {
|
if (arg && typeof arg === "object" && "limit" in arg) {
|
||||||
limits.push({
|
limits.push({
|
||||||
@@ -214,6 +222,7 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
|
|||||||
|
|
||||||
const selector = action.args[0];
|
const selector = action.args[0];
|
||||||
|
|
||||||
|
// Handle full word type actions first
|
||||||
if (
|
if (
|
||||||
action.action === "type" &&
|
action.action === "type" &&
|
||||||
action.args?.length >= 2 &&
|
action.args?.length >= 2 &&
|
||||||
@@ -230,6 +239,7 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle character-by-character sequences (both type and press)
|
||||||
if (
|
if (
|
||||||
(action.action === "type" || action.action === "press") &&
|
(action.action === "type" || action.action === "press") &&
|
||||||
action.args?.length >= 2 &&
|
action.args?.length >= 2 &&
|
||||||
@@ -582,7 +592,8 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
|
|||||||
setRerenderRobots(true);
|
setRerenderRobots(true);
|
||||||
notify("success", t("robot_edit.notifications.update_success"));
|
notify("success", t("robot_edit.notifications.update_success"));
|
||||||
handleStart(robot);
|
handleStart(robot);
|
||||||
navigate("/robots");
|
const basePath = "/robots";
|
||||||
|
navigate(basePath);
|
||||||
} else {
|
} else {
|
||||||
notify("error", t("robot_edit.notifications.update_failed"));
|
notify("error", t("robot_edit.notifications.update_failed"));
|
||||||
}
|
}
|
||||||
@@ -595,7 +606,8 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
navigate("/robots");
|
const basePath = "/robots";
|
||||||
|
navigate(basePath);
|
||||||
};
|
};
|
||||||
|
|
||||||
const lastPair =
|
const lastPair =
|
||||||
@@ -610,6 +622,7 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
|
|||||||
onCancel={handleCancel}
|
onCancel={handleCancel}
|
||||||
saveButtonText={t("robot_edit.save")}
|
saveButtonText={t("robot_edit.save")}
|
||||||
cancelButtonText={t("robot_edit.cancel")}
|
cancelButtonText={t("robot_edit.cancel")}
|
||||||
|
showCancelButton={false}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -612,7 +612,7 @@ export const RobotIntegrationPage = ({
|
|||||||
case "webhook":
|
case "webhook":
|
||||||
return "Webhook Integration";
|
return "Webhook Integration";
|
||||||
default:
|
default:
|
||||||
return "Integration Settings";
|
return "Integration";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -677,13 +677,58 @@ export const RobotIntegrationPage = ({
|
|||||||
else return date.toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" });
|
else return date.toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleBack = () => {
|
||||||
|
if (!recordingId) {
|
||||||
|
console.error("Cannot navigate: recordingId is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelectedIntegrationType(null);
|
||||||
|
setSettings({ ...settings, integrationType: "airtable" });
|
||||||
|
const basePath = robotPath === "prebuilt-robots" ? "/prebuilt-robots" : "/robots";
|
||||||
|
navigate(`${basePath}/${recordingId}/integrate`);
|
||||||
|
};
|
||||||
|
|
||||||
// --- MAIN RENDER ---
|
// --- MAIN RENDER ---
|
||||||
if (!selectedIntegrationType && !integrationType) {
|
if (!selectedIntegrationType && !integrationType) {
|
||||||
return (
|
return (
|
||||||
<RobotConfigPage title="Integration Settings" onCancel={handleCancel} cancelButtonText={t("robot_edit.cancel")} showSaveButton={false} backToSelectionText={"← " + t("right_panel.buttons.back")} onBackToSelection={() => navigate(`/${robotPath}/${recordingId}/integrate`)}>
|
<RobotConfigPage
|
||||||
<div style={{ display: "flex", flexDirection: "column", alignItems: "flex-start", position: "relative", minHeight: "400px" }}>
|
title={getIntegrationTitle()}
|
||||||
<div style={{ display: "flex", flexDirection: "column", alignItems: "center", padding: "20px", width: "100%" }}>
|
// onCancel={handleCancel}
|
||||||
<div style={{ display: "flex", gap: "20px" }}>
|
cancelButtonText={t("buttons.cancel")}
|
||||||
|
showSaveButton={false}
|
||||||
|
// onBackToSelection={handleBack}
|
||||||
|
onArrowBack={handleBack}
|
||||||
|
showCancelButton={false}
|
||||||
|
backToSelectionText={t("buttons.back_arrow")}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "flex-start",
|
||||||
|
position: "relative",
|
||||||
|
minHeight: "400px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "flex-start",
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "repeat(4, minmax(160px, 1fr))",
|
||||||
|
gap: "20px",
|
||||||
|
justifyContent: "start",
|
||||||
|
maxWidth: "900px",
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Button variant="outlined" onClick={() => {
|
<Button variant="outlined" onClick={() => {
|
||||||
if (!recordingId) return;
|
if (!recordingId) return;
|
||||||
setSelectedIntegrationType("googleSheets");
|
setSelectedIntegrationType("googleSheets");
|
||||||
@@ -725,15 +770,17 @@ export const RobotIntegrationPage = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleBack = () => {
|
|
||||||
if (!recordingId) return;
|
|
||||||
setSelectedIntegrationType(null);
|
|
||||||
const basePath = robotPath === "prebuilt-robots" ? "/prebuilt-robots" : "/robots";
|
|
||||||
navigate(`${basePath}/${recordingId}/integrate`);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RobotConfigPage title={getIntegrationTitle()} onCancel={handleCancel} cancelButtonText={t("robot_edit.cancel")} showSaveButton={false} onBackToSelection={handleBack} backToSelectionText={"← " + t("right_panel.buttons.back")}>
|
<RobotConfigPage
|
||||||
|
title={getIntegrationTitle()}
|
||||||
|
// onCancel={handleCancel}
|
||||||
|
cancelButtonText={t("buttons.cancel")}
|
||||||
|
showSaveButton={false}
|
||||||
|
// onBackToSelection={handleBack}
|
||||||
|
onArrowBack={handleBack}
|
||||||
|
showCancelButton={false}
|
||||||
|
backToSelectionText={t("buttons.back_arrow")}
|
||||||
|
>
|
||||||
<div style={{ display: "flex", flexDirection: "column", alignItems: "flex-start", position: "relative", minHeight: "400px" }}>
|
<div style={{ display: "flex", flexDirection: "column", alignItems: "flex-start", position: "relative", minHeight: "400px" }}>
|
||||||
<div style={{ width: "100%" }}>
|
<div style={{ width: "100%" }}>
|
||||||
{(selectedIntegrationType === "googleSheets" || integrationType === "googleSheets") && (
|
{(selectedIntegrationType === "googleSheets" || integrationType === "googleSheets") && (
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ export const RobotSettingsPage = ({ handleStart }: RobotSettingsProps) => {
|
|||||||
onCancel={handleCancel}
|
onCancel={handleCancel}
|
||||||
cancelButtonText={t("robot_settings.buttons.close")}
|
cancelButtonText={t("robot_settings.buttons.close")}
|
||||||
showSaveButton={false}
|
showSaveButton={false}
|
||||||
|
showCancelButton={false}
|
||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
<Box style={{ display: "flex", flexDirection: "column" }}>
|
<Box style={{ display: "flex", flexDirection: "column" }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user