// @flow import React, {Component} from "react"; import {buildTree} from "./commitUtils"; import type {CommitData, FileTree} from "./commitUtils"; export class FileExplorer extends Component<{ selectedPath: string, onSelectPath: (newPath: string) => void, data: CommitData, }> { render() { // within the FileExplorer, paths start with "./", outside they don't // which is hacky and should be cleaned up const fileNames = Object.keys(this.props.data.fileToCommits).sort(); const tree = buildTree(fileNames); const selectPath = (path) => { if (path.startsWith("./")) { path = path.slice(2); } this.props.onSelectPath(path); }; return (
{isFolder && ( )} {this.props.name}
{(this.state.expanded || this.props.alwaysExpand) && subEntries}