From d6032153f98bf23ebf3c5e5c8c260c292299fbf4 Mon Sep 17 00:00:00 2001 From: gokhangunduz Date: Fri, 11 Aug 2023 16:48:46 +0300 Subject: [PATCH] refactor(robot-context): :tada: update robot sub components for context logic --- package.json | 2 +- src/components/CodeEditor/CodeEditor.tsx | 16 +++++----------- src/pages/RobotPage/RobotPage.tsx | 19 +++---------------- .../RobotPage/Teleoperation/Teleoperation.tsx | 6 ++---- 4 files changed, 11 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index e8a98dde..e6b35a52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ui", - "version": "0.11.1", + "version": "0.11.2", "private": true, "dependencies": { "@emotion/css": "^11.10.6", diff --git a/src/components/CodeEditor/CodeEditor.tsx b/src/components/CodeEditor/CodeEditor.tsx index e52894b3..d12a7a2f 100644 --- a/src/components/CodeEditor/CodeEditor.tsx +++ b/src/components/CodeEditor/CodeEditor.tsx @@ -3,23 +3,17 @@ import CardLayout from "../../layouts/CardLayout"; import { FullScreen, useFullScreenHandle } from "react-full-screen"; import { BsFullscreen, BsFullscreenExit } from "react-icons/bs"; import { useAppSelector } from "../../hooks/redux"; +import useRobot from "../../hooks/useRobot"; -interface ICodeEditor { - activeTab: string; - responseRobot: any; - setIsSettedCookie: any; -} - -export default function CodeEditor({ - activeTab, - responseRobot, - setIsSettedCookie, -}: ICodeEditor): ReactElement { +export default function CodeEditor(): ReactElement { const [activeTabCodeEditor, setActiveTabCodeEditor] = useState< "Cloud IDE" | "Physical IDE" >("Cloud IDE"); const handleFullScreen = useFullScreenHandle(); + + const { activeTab, responseRobot, setIsSettedCookie } = useRobot(); + const { urls } = useAppSelector((state) => state.robot); const codeEditorTabs = [ diff --git a/src/pages/RobotPage/RobotPage.tsx b/src/pages/RobotPage/RobotPage.tsx index 05ba75d4..8c992c93 100644 --- a/src/pages/RobotPage/RobotPage.tsx +++ b/src/pages/RobotPage/RobotPage.tsx @@ -1,4 +1,4 @@ -import React, { ReactElement, useState } from "react"; +import React, { ReactElement } from "react"; import HiddenVDIFrame from "../../components/HiddenVDIFrame/HiddenVDIFrame"; import TaskManagementLayout from "../../layouts/TaskManagementLayout"; import RosConnector from "../../components/RosConnector/RosConnector"; @@ -17,14 +17,7 @@ import useRobot from "../../hooks/useRobot"; import Overview from "./Overview/Overview"; export default function RobotPage(): ReactElement { - const { - activeTab, - setActiveTab, - responseRobot, - ros, - topicList, - setIsSettedCookie, - } = useRobot(); + const { activeTab, setActiveTab, responseRobot } = useRobot(); const { urls } = useAppSelector((state) => state.robot); @@ -83,8 +76,6 @@ export default function RobotPage(): ReactElement { case "Teleoperation": return ( + diff --git a/src/pages/RobotPage/Teleoperation/Teleoperation.tsx b/src/pages/RobotPage/Teleoperation/Teleoperation.tsx index e62afa4a..775af6e1 100644 --- a/src/pages/RobotPage/Teleoperation/Teleoperation.tsx +++ b/src/pages/RobotPage/Teleoperation/Teleoperation.tsx @@ -13,17 +13,14 @@ import "gridstack/dist/gridstack-extra.css"; import "gridstack/dist/gridstack.min.css"; import { GridStack } from "gridstack"; import ROSLIB from "roslib"; +import useRobot from "../../../hooks/useRobot"; interface ITeleoperation { - ros: any; - topicList: string[]; vdiIngressEndpoint: string; handleForceUpdate: (page: IrobotPages["activeTab"]) => void; } export default function Teleoperation({ - ros, - topicList, vdiIngressEndpoint, handleForceUpdate, }: ITeleoperation): ReactElement { @@ -39,6 +36,7 @@ export default function Teleoperation({ const [selectableTopic, setSelectableTopic] = useState([]); const [selectedTopic, setSelectedTopic] = useState(""); const handleFullScreen = useFullScreenHandle(); + const { ros, topicList } = useRobot(); // GRID useEffect(() => {