Skip to content

Commit

Permalink
Merge pull request #249 from JdeRobot/store-actions-values
Browse files Browse the repository at this point in the history
Fix action states dissapearing when no instances exist
  • Loading branch information
javizqh authored Jan 10, 2025
2 parents e577b4a + 4ce073e commit 84b93cc
Show file tree
Hide file tree
Showing 11 changed files with 258 additions and 92 deletions.
7 changes: 0 additions & 7 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@ const App = ({ isUnibotics }: { isUnibotics: boolean }) => {
const [forceSaveCurrent, setForcedSaveCurrent] = useState<boolean>(false);
const [currentProjectname, setCurrentProjectname] = useState<string>("");
const [currentUniverseName, setCurrentUniverseName] = useState<string>("");
const [actionNodesData, setActionNodesData] = useState<Record<string, any>>(
{},
);
const [saveCurrentDiagram, setSaveCurrentDiagram] = useState<boolean>(false);
const [updateFileExplorer, setUpdateFileExplorer] = useState<boolean>(false);
const [isErrorModalOpen, setErrorModalOpen] = useState<boolean>(false);
const [projectChanges, setProjectChanges] = useState<boolean>(false);
const [gazeboEnabled, setGazeboEnabled] = useState<boolean>(false);
const [manager, setManager] = useState<CommsManager | null>(null);
const [diagramEditorReady, setDiagramEditorReady] = useState<boolean>(false);
const [showSim, setSimVisible] = useState<boolean>(false);
const [showTerminal, setTerminalVisible] = useState<boolean>(false);

Expand Down Expand Up @@ -190,9 +186,6 @@ const App = ({ isUnibotics }: { isUnibotics: boolean }) => {
currentFilename={currentFilename}
currentProjectname={currentProjectname}
setProjectChanges={setProjectChanges}
actionNodesData={actionNodesData}
showAccentColor={"editorShowAccentColors"}
diagramEditorReady={diagramEditorReady}
setAutosave={setAutosave}
forceSaveCurrent={forceSaveCurrent}
setForcedSaveCurrent={setForcedSaveCurrent}
Expand Down
6 changes: 0 additions & 6 deletions frontend/src/components/file_browser/FileBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ const FileBrowser = ({
currentFilename,
currentProjectname,
setProjectChanges,
actionNodesData,
showAccentColor,
diagramEditorReady,
setAutosave,
forceSaveCurrent,
setForcedSaveCurrent,
Expand Down Expand Up @@ -395,9 +392,6 @@ const FileBrowser = ({
currentFilename={currentFilename}
currentProjectname={currentProjectname}
setSelectedEntry={setSelectedEntry}
actionNodesData={actionNodesData}
showAccentColor={showAccentColor}
diagramEditorReady={diagramEditorReady}
fileList={fileList}
fetchFileList={fetchFileList}
onDelete={handleDeleteModal}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import React, { useEffect, useState } from "react";

import "./FileExplorer.css";
import TreeNode from "./TreeNode.jsx";
import TreeNode from "./TreeNode";
import MoreActionsMenu, { ContextMenuProps } from "./MoreActionsMenu.jsx";

const FileExplorer = ({
setCurrentFilename,
currentFilename,
currentProjectname,
setSelectedEntry,
actionNodesData,
showAccentColor,
diagramEditorReady,
fileList,
fetchFileList,
onDelete,
Expand Down Expand Up @@ -65,9 +62,6 @@ const FileExplorer = ({
depth={0}
parentGroup=""
currentFilename={currentFilename}
showAccentColor={showAccentColor}
diagramEditorReady={diagramEditorReady}
actionNodesData={actionNodesData}
handleFileClick={handleFileClick}
handleFolderClick={handleFolderClick}
menuProps={MenuProps}
Expand All @@ -76,7 +70,6 @@ const FileExplorer = ({
{showMenu && (
<MoreActionsMenu
menuProps={MenuProps}
actionNodesData={actionNodesData}
onDelete={onDelete}
onCreateFile={onCreateFile}
onCreateFolder={onCreateFolder}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import "./MoreActionsMenu.css";

function MoreActionsMenu({
menuProps,
actionNodesData,
onDelete,
onCreateFile,
onCreateFolder,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
import React, { useEffect, useState } from "react";
import React, { useEffect, useState, useContext } from "react";

import { ReactComponent as ActionIcon } from "./img/action.svg";
import FileIcon from "./FileIcon.jsx";
import { OptionsContext } from "../../options/Options";
import { ContextMenuProps } from "./MoreActionsMenu";
import { getActionFrame } from "../../helper/TreeEditorHelper";

interface Entry {
name: string;
is_dir: boolean;
path: string;
files: Entry[];
}

function TreeNode({
node,
depth,
parentGroup,
currentFilename,
showAccentColor,
diagramEditorReady,
actionNodesData,
handleFileClick,
handleFolderClick,
menuProps,
}: {
node: Entry;
depth: number;
parentGroup: string;
currentFilename: string;
handleFileClick: Function;
handleFolderClick: Function;
menuProps: ContextMenuProps;
}) {
const [isCollapsed, setCollapsed] = useState(false);
const [group, setGroup] = useState(parentGroup);
const [isCollapsed, setCollapsed] = useState<boolean>(false);
const [group, setGroup] = useState<string>(parentGroup);
const settings = React.useContext(OptionsContext);

useEffect(() => {
if (node.is_dir) {
Expand Down Expand Up @@ -65,13 +81,12 @@ function TreeNode({
);
}}
/>
{showAccentColor && diagramEditorReady && (
{settings.editorShowAccentColors.value && (
<div
className="bt-accent-color"
style={{
backgroundColor: actionNodesData[node.name.replace(".py", "")]
? actionNodesData[node.name.replace(".py", "")]["color"]
: "none",
// backgroundColor: getActionFrame(node.name.replace(".py", "")) ? getActionFrame(node.name.replace(".py", ""))?.getColor() : "none",
backgroundColor: "none",
}}
/>
)}
Expand All @@ -84,9 +99,6 @@ function TreeNode({
depth={depth + 1}
parentGroup={group}
currentFilename={currentFilename}
showAccentColor={showAccentColor}
diagramEditorReady={diagramEditorReady}
actionNodesData={actionNodesData}
handleFileClick={handleFileClick}
handleFolderClick={handleFolderClick}
menuProps={menuProps}
Expand Down
Loading

0 comments on commit 84b93cc

Please sign in to comment.