diff options
author | Adam Buckland <adamjbuckland@gmail.com> | 2016-07-27 13:47:23 +0100 |
---|---|---|
committer | Adam Buckland <adamjbuckland@gmail.com> | 2016-08-09 14:08:47 +0100 |
commit | 8abc757539454e13835073318f896796b1a85faf (patch) | |
tree | 78cf0a861e61362016f34751a9bc5d3d79a7070d /app/helpers/tree_helper.rb | |
parent | 551ffc0a4d25a381e9f8f6a8d6f2793bb87f3145 (diff) | |
download | gitlab-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.rb | 18 |
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 |