diff --git a/client/src/Components/App/App.tsx b/client/src/Components/App/App.tsx index 42fbbe093..559d020e3 100644 --- a/client/src/Components/App/App.tsx +++ b/client/src/Components/App/App.tsx @@ -4,13 +4,18 @@ import ParameterView from "../ParameterView/ParameterView"; import TreeView from "../TreeView/TreeView"; function App() { + const [parameters, setParameters] = useState([]); + const [selection, setSelection ] = useState([]); return (
- - - + +
); } diff --git a/client/src/Components/ParameterView/ParameterView.css b/client/src/Components/ParameterView/ParameterView.css index d76acd92f..74df6b29d 100644 --- a/client/src/Components/ParameterView/ParameterView.css +++ b/client/src/Components/ParameterView/ParameterView.css @@ -1,18 +1,16 @@ -.parameterViewDiv{ +.parameter-view { + padding: 1rem; position: -webkit-sticky; position: sticky; top: 0; - padding-right: 1rem; } .parameterViewDiv h2{ padding-top: 1rem; - padding-left: 1rem; } .parameterViewDiv h5{ padding-top: 1rem; - padding-left: 1rem; } .parameterViewDiv a{ @@ -58,3 +56,7 @@ .documentation-text { clear: both; } + +.parameter-view-path { + height: 1.5rem; +} \ No newline at end of file diff --git a/client/src/Components/ParameterView/ParameterView.tsx b/client/src/Components/ParameterView/ParameterView.tsx index 14e5e5a6e..01dbc2b26 100644 --- a/client/src/Components/ParameterView/ParameterView.tsx +++ b/client/src/Components/ParameterView/ParameterView.tsx @@ -2,14 +2,25 @@ import ParameterNode from "./ParameterNode"; import React from "react"; import PythonParameter from "../../model/PythonParameter"; -type ParameterViewProps = {inputParameters: PythonParameter[]} +type ParameterViewProps = { + inputParameters: PythonParameter[], + selection: string[], + setSelection: any +}; -const ParameterView = ({inputParameters}: ParameterViewProps) => { +const ParameterView = ({inputParameters, selection, setSelection }: ParameterViewProps) => { const hasInputParameters = inputParameters.length > 0; + console.log(selection); return ( -
+
+
+ { selection.length > 0 ? + selection.map(n => {n}) + .reduce((p, c) => [p, ( / ), c]) : + "" } +

Parameters

{ inputParameters?.map(function (parameters) { @@ -18,7 +29,7 @@ const ParameterView = ({inputParameters}: ParameterViewProps) => { } { !hasInputParameters && -
No Parameters available
+ There are no Parameters. }
diff --git a/client/src/Components/Tree/ClassNode.tsx b/client/src/Components/Tree/ClassNode.tsx index 865610c98..0468c5671 100644 --- a/client/src/Components/Tree/ClassNode.tsx +++ b/client/src/Components/Tree/ClassNode.tsx @@ -5,26 +5,25 @@ import FunctionNode from "./FunctionNode"; import {isEmptyList} from "../../Utility/listOperations"; type ClassNodeProps = { + parentPath: string[], pythonClass: PythonClass, - selection: string, - setSelection: (newValue: string) => void, + selection: string[], + setSelection: (newValue: string[]) => void, moduleName: string, setParameters: any, } -const ClassNode = ({pythonClass, selection, setSelection, moduleName, setParameters}: ClassNodeProps) => { - const [childVisible, setChildVisibility] = useState(false); +const ClassNode = ({parentPath, pythonClass, selection, setSelection, moduleName, setParameters}: ClassNodeProps) => { + const [childVisible, setChildVisibility] = useState(false); const hasMethods = isEmptyList(pythonClass.methods); - - const fullQualifiedName = moduleName + "." + pythonClass.name; - + const path = parentPath.concat(pythonClass.name); const cssClasses = classNames( "pl-3rem", "tree-view-row", { "text-muted": !hasMethods, "cursor-na":!hasMethods, - "selected": selection === fullQualifiedName, + "selected": (selection.join() === path.join()) && hasMethods, } ); @@ -32,36 +31,27 @@ const ClassNode = ({pythonClass, selection, setSelection, moduleName, setParamet
{ - setSelection(fullQualifiedName) + setSelection(path); setChildVisibility(!childVisible); - console.log(pythonClass.name + " has been selected."); }}> - { hasMethods && { childVisible ? "▼" : "▶" }} - - 𝒞 - - { " " } - - {pythonClass.name} - + { hasMethods && { childVisible ? "▼" : "▶" } } + 𝒞 + { " " } + { pythonClass.name }
- { - hasMethods && childVisible && - <> - {pythonClass.methods.map(method => ( - - ))} - - } + { hasMethods && childVisible &&
+ { pythonClass.methods.map(method => ( + + ))} +
}
- ) + ); }; export default ClassNode; \ No newline at end of file diff --git a/client/src/Components/Tree/FunctionNode.tsx b/client/src/Components/Tree/FunctionNode.tsx index 18e52aa8b..bb9b70324 100644 --- a/client/src/Components/Tree/FunctionNode.tsx +++ b/client/src/Components/Tree/FunctionNode.tsx @@ -5,38 +5,36 @@ import {isEmptyList} from "../../Utility/listOperations"; type FunctionNodeProps = { pythonFunction: PythonFunction, - selection: string, - setSelection: (newValue: string) => void, + selection: string[], + setSelection: (newValue: string[]) => void, setParameters: any, isMethod?: boolean, + /** A parent of a Python class can be a class or a Python module. */ - parentFullQualifiedName: string, + parentPath: string[], } -const FunctionNode = ({pythonFunction, selection, setSelection, setParameters, parentFullQualifiedName, isMethod=false}:FunctionNodeProps) => { - - const fullQualifiedName = parentFullQualifiedName + "." + pythonFunction.name; +const FunctionNode = ({pythonFunction, selection, setSelection, setParameters, parentPath, isMethod = false} : FunctionNodeProps) => { + const path = parentPath.concat(pythonFunction.name) const hasParameters = isEmptyList(pythonFunction.parameters); - const cssClasses = classNames( - "tree-view-row", - { + "tree-view-row", { "text-muted": !hasParameters, "cursor-na": !hasParameters, "pl-3-5rem": !isMethod, "pl-5rem": isMethod, - "selected": selection === fullQualifiedName && hasParameters, + "selected": (selection.join() === path.join()) && hasParameters } ); return (
-
{ - setSelection(fullQualifiedName); - setParameters(pythonFunction.parameters) - }}> +
{ + setSelection(path); + setParameters(pythonFunction.parameters) + }}> 𝑓 diff --git a/client/src/Components/Tree/ModuleNode.tsx b/client/src/Components/Tree/ModuleNode.tsx index b6789467e..ee966c97e 100644 --- a/client/src/Components/Tree/ModuleNode.tsx +++ b/client/src/Components/Tree/ModuleNode.tsx @@ -6,39 +6,43 @@ import classNames from "classnames"; import PythonModule from "../../model/PythonModule"; type ModuleNodeProps = { + parentPath: string[], pythonModule: PythonModule, - selection: string, - setSelection: (newValue: string) => void, + selection: string[], + setSelection: (newValue: string[]) => void, setParameters: any, } -const ModuleNode = ({pythonModule, selection, setSelection, setParameters}: ModuleNodeProps) => { - const [childVisible, setChildVisibility] = useState(false); +const ModuleNode = ({parentPath, pythonModule, selection, setSelection, setParameters}: ModuleNodeProps) => { + + /** This is the Name of this module without its packages name prefixed. */ + const [_, ...moduleName] = pythonModule.name.split("."); + + const path = parentPath.concat(moduleName) + const [childVisible, setChildVisibility] = useState(false); let hasClasses = isEmptyList(pythonModule.classes); let hasFunctions = isEmptyList(pythonModule.functions); + const hasChildren = hasClasses || hasFunctions; const cssClasses = classNames( - "tree-view-row", - { - "text-muted": !(hasClasses || hasFunctions), - "cursor-na":!(hasClasses || hasFunctions), - "pl-2rem": !(hasClasses || hasFunctions), - "pl-1-5rem": (hasClasses || hasFunctions), - "selected": (selection === pythonModule.name) && (hasClasses || hasFunctions), + "tree-view-row", { + "text-muted": !hasChildren, + "cursor-na":!hasChildren, + "pl-2rem": !hasChildren, + "pl-1-5rem": hasChildren, + "selected": (selection.join() === path.join()) && hasChildren, } ); - return ( + return (
{ - setSelection(pythonModule.name) + setSelection(path) setChildVisibility(!childVisible) - }}> - { (hasClasses || hasFunctions) && - { childVisible ? "▼" : "▶" } - } + }}> + { (hasClasses || hasFunctions) && { childVisible ? "▼" : "▶" } } @@ -48,34 +52,27 @@ const ModuleNode = ({pythonModule, selection, setSelection, setParameters}: Modu
- { - hasClasses && childVisible && -
- {pythonModule.classes.map(moduleClass => ( - - ))} -
- } - { - hasFunctions && childVisible && -
- {pythonModule.functions.map(moduleFunction => ( - - ))} -
- } + { hasClasses && childVisible &&
+ { pythonModule.classes.map(moduleClass => ( + + ))} +
} + { hasFunctions && childVisible &&
+ { pythonModule.functions.map(moduleFunction => ( + + ))} +
}
) diff --git a/client/src/Components/Tree/Tree.tsx b/client/src/Components/Tree/Tree.tsx index 8c7f944d5..07788b005 100644 --- a/client/src/Components/Tree/Tree.tsx +++ b/client/src/Components/Tree/Tree.tsx @@ -1,20 +1,23 @@ -import React, {useState} from 'react' +import React from 'react' import ModuleNode from "./ModuleNode"; import PythonPackage from "../../model/PythonPackage"; type TreeProps = { pythonPackage: PythonPackage, setParameters: any, + selection: string[], + setSelection: any } -const Tree = ({pythonPackage, setParameters}: TreeProps) => { +const Tree = ({pythonPackage, setParameters, selection, setSelection}: TreeProps) => { - const [selection, setSelection ] = useState(""); + const path = [pythonPackage.name]; return (
{pythonPackage.modules.map(module => ( - { + +const TreeView = ({setParameters, selection, setSelection}: TreeViewProps) => { let pythonPackage = PythonPackageBuilder.make(packageJson); return(

{pythonPackage.name}

- +
) } diff --git a/node_modules/.yarn-integrity b/node_modules/.yarn-integrity new file mode 100644 index 000000000..6b671344d --- /dev/null +++ b/node_modules/.yarn-integrity @@ -0,0 +1,10 @@ +{ + "systemParams": "win32-x64-93", + "modulesFolders": [], + "flags": [], + "linkedModules": [], + "topLevelPatterns": [], + "lockfileEntries": {}, + "files": [], + "artifacts": {} +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 000000000..fb57ccd13 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +