Merge pull request #390 from RohitR311/sheet-redirect
fix: open modal to fetch spreadsheets after google oauth
This commit is contained in:
@@ -41,7 +41,8 @@
|
||||
"duplicate": "Duplizieren",
|
||||
"notifications": {
|
||||
"delete_warning": "Roboter kann nicht gelöscht werden, da zugehörige Ausführungen vorhanden sind",
|
||||
"delete_success": "Roboter erfolgreich gelöscht"
|
||||
"delete_success": "Roboter erfolgreich gelöscht",
|
||||
"auth_success": "Roboter erfolgreich authentifiziert"
|
||||
}
|
||||
},
|
||||
"mainmenu": {
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
"search":"Search Robots...",
|
||||
"notifications": {
|
||||
"delete_warning": "Cannot delete robot as it has associated runs",
|
||||
"delete_success": "Robot deleted successfully"
|
||||
"delete_success": "Robot deleted successfully",
|
||||
"auth_success": "Robot successfully authenticated"
|
||||
}
|
||||
},
|
||||
"mainmenu":{
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
"search": "Buscar robots...",
|
||||
"notifications": {
|
||||
"delete_warning": "No se puede eliminar el robot ya que tiene ejecuciones asociadas",
|
||||
"delete_success": "Robot eliminado exitosamente"
|
||||
"delete_success": "Robot eliminado exitosamente",
|
||||
"auth_success": "Robot autenticado exitosamente"
|
||||
}
|
||||
},
|
||||
"mainmenu": {
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
"search": "ロボットを検索...",
|
||||
"notifications": {
|
||||
"delete_warning": "関連する実行があるため、ロボットを削除できません",
|
||||
"delete_success": "ロボットが正常に削除されました"
|
||||
"delete_success": "ロボットが正常に削除されました",
|
||||
"auth_success": "ロボットの認証に成功しました"
|
||||
}
|
||||
},
|
||||
"mainmenu": {
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
"search": "搜索机器人...",
|
||||
"notifications": {
|
||||
"delete_warning": "无法删除机器人,因为它有关联的运行记录",
|
||||
"delete_success": "机器人删除成功"
|
||||
"delete_success": "机器人删除成功",
|
||||
"auth_success": "机器人认证成功"
|
||||
}
|
||||
},
|
||||
"mainmenu": {
|
||||
|
||||
@@ -380,11 +380,19 @@ router.get(
|
||||
httpOnly: false,
|
||||
maxAge: 60000,
|
||||
}); // 1-minute expiration
|
||||
res.cookie("robot_auth_message", "Robot successfully authenticated", {
|
||||
// res.cookie("robot_auth_message", "Robot successfully authenticated", {
|
||||
// httpOnly: false,
|
||||
// maxAge: 60000,
|
||||
// });
|
||||
res.cookie('robot_auth_robotId', robotId, {
|
||||
httpOnly: false,
|
||||
maxAge: 60000,
|
||||
});
|
||||
res.redirect(`${process.env.PUBLIC_URL}/robots/${robotId}/integrate` as string || `http://localhost:5173/robots/${robotId}/integrate`);
|
||||
|
||||
const baseUrl = process.env.PUBLIC_URL || "http://localhost:5173";
|
||||
const redirectUrl = `${baseUrl}/robots/`;
|
||||
|
||||
res.redirect(redirectUrl);
|
||||
} catch (error: any) {
|
||||
res.status(500).json({ message: `Google OAuth error: ${error.message}` });
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user