summaryrefslogtreecommitdiff
path: root/app/helpers/tree_helper.rb
diff options
context:
space:
mode:
authorAdam Buckland <adamjbuckland@gmail.com>2016-07-27 13:47:23 +0100
committerAdam Buckland <adamjbuckland@gmail.com>2016-08-09 14:08:47 +0100
commit8abc757539454e13835073318f896796b1a85faf (patch)
tree78cf0a861e61362016f34751a9bc5d3d79a7070d /app/helpers/tree_helper.rb
parent551ffc0a4d25a381e9f8f6a8d6f2793bb87f3145 (diff)
downloadgitlab-ce-8abc757539454e13835073318f896796b1a85faf.tar.gz
Update tree view to sort folders with submodules
Currently trees are sorted in the fashion: - folders - files - submodules with each section sorted alphabetically This changes to this system: - folders and submodules (sorted together) - files
Diffstat (limited to 'app/helpers/tree_helper.rb')
-rw-r--r--app/helpers/tree_helper.rb18
1 files changed, 3 insertions, 15 deletions
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
index dbedf417fa5..4a76c679bad 100644
--- a/app/helpers/tree_helper.rb
+++ b/app/helpers/tree_helper.rb
@@ -4,23 +4,11 @@ module TreeHelper
#
# contents - A Grit::Tree object for the current tree
def render_tree(tree)
- # Render Folders before Files/Submodules
+ # Sort submodules and folders together by name ahead of files
folders, files, submodules = tree.trees, tree.blobs, tree.submodules
-
tree = ""
-
- # Render folders if we have any
- tree << render(partial: 'projects/tree/tree_item', collection: folders,
- locals: { type: 'folder' }) if folders.present?
-
- # Render files if we have any
- tree << render(partial: 'projects/tree/blob_item', collection: files,
- locals: { type: 'file' }) if files.present?
-
- # Render submodules if we have any
- tree << render(partial: 'projects/tree/submodule_item',
- collection: submodules) if submodules.present?
-
+ items = (folders + submodules).sort_by(&:name) + files
+ tree << render(partial: "projects/tree/tree_row", collection: items) if items.present?
tree.html_safe
end