Addressed PR comments

Updated comments in `FileExplorer.js`

Moved `isFolder()`, `isNotFolder()`, and `byName()` outside of `fileTreeSort()` in `lib/pipeline/pipeline.js`.
This commit is contained in:
emizzle 2018-10-10 08:13:29 +11:00 committed by Pascal Precht
parent 895c0d86ac
commit 35a701fb90
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 17 additions and 15 deletions

View File

@ -72,7 +72,7 @@ class FileExplorer extends React.Component {
// if it's a folder, filter the children
if (node.children) {
let children = this.filterHidden(node.children);
const children = this.filterHidden(node.children);
if (children.length) {
updatedNode.children = children;
}
@ -81,11 +81,12 @@ class FileExplorer extends React.Component {
// if this is the selected node, set it as active
if (this.nodeEquals(node, cursor)) {
updatedNode.active = cursor.active;
// if this node has children, set it as toggled
// if this node is the selected node and is a folder, set
// it as toggled (expanded) according to the selected node
if (node.children) updatedNode.toggled = cursor.toggled;
}
// if this is a directory, and it lies in the path
// of the selected node, ensure it's toggled
// if this node is a folder, and it's a parent of the selected
// folder, force toggle it
if (node.children && this.isNodeInPath(node, cursor)) {
updatedNode.toggled = true;
}

View File

@ -74,7 +74,6 @@ class Pipeline {
(req, res) => {
const rootPath = fs.dappPath();
function fileTreeSort(objects){
function isFolder(object) {
return object.children && object.children.length;
}
@ -87,6 +86,8 @@ class Pipeline {
return a.name.localeCompare(b.name);
}
function fileTreeSort(objects){
const folders = objects.filter(isFolder).sort(byName);
const files = objects.filter(isNotFolder).sort(byName);