diff --git a/src/renderer/src/components/shared/DatasetTreeViewRenderer/index.jsx b/src/renderer/src/components/shared/DatasetTreeViewRenderer/index.jsx index a27bed283..fc8a8ff04 100644 --- a/src/renderer/src/components/shared/DatasetTreeViewRenderer/index.jsx +++ b/src/renderer/src/components/shared/DatasetTreeViewRenderer/index.jsx @@ -49,8 +49,6 @@ const getFileTypeIcon = (fileName) => { // FileItem component const FileItem = ({ name, content, onFileClick, getFileBackgroundColor }) => { const filesRelativePath = content.relativePath; - const filesEntity = getEntityForRelativePath("subjects", filesRelativePath); - const fileBackgroundColor = getFileBackgroundColor(filesRelativePath); return (
))} {Object.keys(content.files || {}).map((fileName) => ( diff --git a/src/renderer/src/components/shared/manifest/ManifestEntitySelector.jsx b/src/renderer/src/components/shared/manifest/ManifestEntitySelector.jsx index 0d3c863dd..30fb548aa 100644 --- a/src/renderer/src/components/shared/manifest/ManifestEntitySelector.jsx +++ b/src/renderer/src/components/shared/manifest/ManifestEntitySelector.jsx @@ -5,7 +5,9 @@ import DatasetTreeViewRenderer from "../DatasetTreeViewRenderer"; import { setActiveEntity, toggleRelativeFilePathForManifestEntity, + getEntityForRelativePath, } from "../../../stores/slices/manifestEntitySelectorSlice"; +import { get } from "jquery"; const ManifestEntitySelector = () => { const datasetStructureJSONObj = useGlobalStore((state) => state.datasetStructureJSONObj); @@ -32,6 +34,22 @@ const ManifestEntitySelector = () => { toggleRelativeFilePathForManifestEntity(entityType, activeEntity, fileContents.relativePath); }; + const getFolderBackgroundColor = (folderRelativePath) => { + const folderIsSelected = getEntityForRelativePath(folderRelativePath); + return folderIsSelected ? "blue" : "white"; + }; + + const getFileBackgroundColor = (fileRelativePath) => { + if (fileRelativePath === "primary/sub-1/code_description.xlsx") { + console.log("Active entity:", activeEntity); + } + const fileIsSelected = getEntityForRelativePath(fileRelativePath); + if (fileIsSelected) { + console.log("File is selected:", fileRelativePath); + } + return fileIsSelected ? "blue" : "white"; + }; + return ( @@ -65,6 +83,8 @@ const ManifestEntitySelector = () => { datasetStructure={datasetStructureJSONObj} onFolderClick={handleFolderClick} onFileClick={handleFileClick} + getFolderBackgroundColor={getFolderBackgroundColor} + getFileBackgroundColor={getFileBackgroundColor} /> diff --git a/src/renderer/src/stores/slices/manifestEntitySelectorSlice.js b/src/renderer/src/stores/slices/manifestEntitySelectorSlice.js index 603b8f556..54e70a2f3 100644 --- a/src/renderer/src/stores/slices/manifestEntitySelectorSlice.js +++ b/src/renderer/src/stores/slices/manifestEntitySelectorSlice.js @@ -81,6 +81,14 @@ export const toggleRelativeFilePathForManifestEntity = ( entityName, entityRelativePath ) => { + if (!entityType || !entityName || !entityRelativePath) { + console.log( + "Aborting toggleRelativeFilePathForManifestEntity: entityType, entityName, or entityRelativePath is missing" + ); + console.log(entityType, entityName, entityRelativePath); + + return; + } useGlobalStore.setState( produce((state) => { // Check if entityType exists, if not, create it @@ -115,12 +123,9 @@ export const toggleRelativeFilePathForManifestEntity = ( ); }; -export const getEntityForRelativePath = (entityType, relativePath) => { +export const getEntityForRelativePath = (relativePath) => { const manifestEntityObj = useGlobalStore((state) => state.manifestEntityObj); - if (!manifestEntityObj[entityType]) { - return null; - } - return Object.keys(manifestEntityObj[entityType]).find((entity) => - manifestEntityObj[entityType][entity]?.includes(relativePath) - ); + const entityType = useGlobalStore((state) => state.entityType); + const activeEntity = useGlobalStore((state) => state.activeEntity); + return manifestEntityObj?.[entityType]?.[activeEntity]?.includes(relativePath); };