From 35a701fb903c655421fd5cd35b5cf374dce96d9f Mon Sep 17 00:00:00 2001 From: emizzle Date: Wed, 10 Oct 2018 08:13:29 +1100 Subject: [PATCH] Addressed PR comments Updated comments in `FileExplorer.js` Moved `isFolder()`, `isNotFolder()`, and `byName()` outside of `fileTreeSort()` in `lib/pipeline/pipeline.js`. --- embark-ui/src/components/FileExplorer.js | 9 +++++---- lib/modules/pipeline/index.js | 23 ++++++++++++----------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/embark-ui/src/components/FileExplorer.js b/embark-ui/src/components/FileExplorer.js index 27b513cd..bbabd287 100644 --- a/embark-ui/src/components/FileExplorer.js +++ b/embark-ui/src/components/FileExplorer.js @@ -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; } diff --git a/lib/modules/pipeline/index.js b/lib/modules/pipeline/index.js index 85c0a570..7f56a418 100644 --- a/lib/modules/pipeline/index.js +++ b/lib/modules/pipeline/index.js @@ -74,18 +74,19 @@ class Pipeline { (req, res) => { const rootPath = fs.dappPath(); + function isFolder(object) { + return object.children && object.children.length; + } + + function isNotFolder(object){ + return !isFolder(object); + } + + function byName(a, b) { + return a.name.localeCompare(b.name); + } + function fileTreeSort(objects){ - function isFolder(object) { - return object.children && object.children.length; - } - - function isNotFolder(object){ - return !isFolder(object); - } - - function byName(a, b) { - return a.name.localeCompare(b.name); - } const folders = objects.filter(isFolder).sort(byName); const files = objects.filter(isNotFolder).sort(byName);