mirror of
https://github.com/zoriya/flood.git
synced 2025-12-20 06:05:15 +00:00
Organize filestructure
This commit is contained in:
31
client/source/scripts/components/filesystem/DirectoryTree.js
Normal file
31
client/source/scripts/components/filesystem/DirectoryTree.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import React from 'react';
|
||||
|
||||
import DirectoryFileList from './DirectoryFileList';
|
||||
import DirectoryTreeNode from './DirectoryTreeNode';
|
||||
|
||||
export default class DirectoryTree extends React.Component {
|
||||
getDirectoryTreeDomNodes(tree, depth = 0) {
|
||||
let index = 0;
|
||||
depth++;
|
||||
|
||||
return Object.keys(tree).map((branchName) => {
|
||||
let branch = tree[branchName];
|
||||
index++;
|
||||
|
||||
if (branchName === 'files') {
|
||||
return <DirectoryFileList branch={branch} key={`${index}${depth}`} />;
|
||||
} else {
|
||||
return <DirectoryTreeNode depth={depth} directoryName={branchName}
|
||||
subTree={branch} key={`${index}${depth}`} />;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="directory-tree__tree">
|
||||
{this.getDirectoryTreeDomNodes(this.props.tree, this.props.depth)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user