Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions client/src/Components/Tree/TreeNode.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,3 @@
.icon {
margin-right: 0.25rem;
}

.treeNodeLink {
text-decoration: none;
color: inherit;
}

.treeNodeLink:hover {
color: inherit;
}
9 changes: 5 additions & 4 deletions client/src/Components/Tree/TreeNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {IconDefinition} from "@fortawesome/free-solid-svg-icons";
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import classNames from "classnames";
import React, {useState} from "react";
import {useLocation} from "react-router";
import {useHistory} from "react-router-dom";
import PythonDeclaration from "../../model/python/PythonDeclaration";
import {ChildrenProp} from "../../util/types";
import VisibilityIndicator from "../Util/VisibilityIndicator";
import TreeNodeCSS from "./TreeNode.module.css";
import {Link} from "react-router-dom";
import {useLocation} from "react-router";

interface TreeNodeProps extends ChildrenProp {
declaration: PythonDeclaration
Expand All @@ -18,6 +18,7 @@ interface TreeNodeProps extends ChildrenProp {

export default function TreeNode(props: TreeNodeProps): JSX.Element {
const [showChildren, setShowChildren] = useState(selfOrChildIsSelected(props.declaration));
const history = useHistory();

const className = classNames({
[TreeNodeCSS.selected]: isSelected(props.declaration),
Expand All @@ -31,6 +32,7 @@ export default function TreeNode(props: TreeNodeProps): JSX.Element {

const handleClick = () => {
setShowChildren(prevState => !prevState);
history.push(`/${props.declaration.path().join("/")}`);
};

return (
Expand All @@ -47,8 +49,7 @@ export default function TreeNode(props: TreeNodeProps): JSX.Element {
icon={props.icon}
fixedWidth
/>
<Link className={TreeNodeCSS.treeNodeLink}
to={`/${props.declaration.path().join("/")}`}>{props.declaration.name}</Link>
{props.declaration.name}
</div>
<div className={TreeNodeCSS.children}>
{showChildren && props.children}
Expand Down