Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
3f073738
Commit
3f073738
authored
Aug 09, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'adambuckland/gitlab-ce-19727-sort-submodules-with-files'
parents
c3636296
8abc7575
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
15 deletions
+39
-15
CHANGELOG
CHANGELOG
+1
-0
app/helpers/tree_helper.rb
app/helpers/tree_helper.rb
+3
-15
app/views/projects/tree/_tree_row.html.haml
app/views/projects/tree/_tree_row.html.haml
+6
-0
spec/features/projects/files/files_sort_submodules_with_folders_spec.rb
...projects/files/files_sort_submodules_with_folders_spec.rb
+29
-0
No files found.
CHANGELOG
View file @
3f073738
...
...
@@ -86,6 +86,7 @@ v 8.11.0 (unreleased)
- Update devise initializer to turn on changed password notification emails. !5648 (tombell)
- Avoid to show the original password field when password is automatically set. !5712 (duduribeiro)
- Fix importing GitLab projects with an invalid MR source project
- Sort folders with submodules in Files view !5521
v 8.10.5 (unreleased)
...
...
app/helpers/tree_helper.rb
View file @
3f073738
...
...
@@ -4,23 +4,11 @@ module TreeHelper
#
# contents - A Grit::Tree object for the current tree
def
render_tree
(
tree
)
#
Render Folders before Files/Submodu
les
#
Sort submodules and folders together by name ahead of fi
les
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
...
...
app/views/projects/tree/_tree_row.html.haml
0 → 100644
View file @
3f073738
-
if
tree_row
.
type
==
:tree
=
render
partial:
'projects/tree/tree_item'
,
object:
tree_row
,
as:
'tree_item'
,
locals:
{
type:
'folder'
}
-
elsif
tree_row
.
type
==
:blob
=
render
partial:
'projects/tree/blob_item'
,
object:
tree_row
,
as:
'blob_item'
,
locals:
{
type:
'file'
}
-
elsif
tree_row
.
type
==
:commit
=
render
partial:
'projects/tree/submodule_item'
,
object:
tree_row
,
as:
'submodule_item'
spec/features/projects/files/files_sort_submodules_with_folders_spec.rb
0 → 100644
View file @
3f073738
require
'spec_helper'
feature
'User views files page'
,
feature:
true
do
include
WaitForAjax
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:forked_project_with_submodules
)
}
before
do
project
.
team
<<
[
user
,
:master
]
login_as
user
visit
namespace_project_tree_path
(
project
.
namespace
,
project
,
project
.
repository
.
root_ref
)
end
scenario
'user sees folders and submodules sorted together, followed by files'
do
rows
=
all
(
'td.tree-item-file-name'
).
map
(
&
:text
)
tree
=
project
.
repository
.
tree
folders
=
tree
.
trees
.
map
(
&
:name
)
files
=
tree
.
blobs
.
map
(
&
:name
)
submodules
=
tree
.
submodules
.
map
do
|
submodule
|
submodule
.
name
+
" @ "
+
submodule
.
id
[
0
..
7
]
end
sorted_titles
=
(
folders
+
submodules
).
sort
+
files
expect
(
rows
).
to
eq
(
sorted_titles
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment