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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
3ee2cd7d
Commit
3ee2cd7d
authored
Feb 03, 2021
by
jboyson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused tree files
These tree files were refactored into vue components and never got removed
parent
2a62b9da
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
0 additions
and
293 deletions
+0
-293
app/helpers/tree_helper.rb
app/helpers/tree_helper.rb
+0
-43
app/views/projects/tree/_readme.html.haml
app/views/projects/tree/_readme.html.haml
+0
-10
app/views/projects/tree/_tree_content.html.haml
app/views/projects/tree/_tree_content.html.haml
+0
-24
app/views/projects/tree/_tree_row.html.haml
app/views/projects/tree/_tree_row.html.haml
+0
-27
app/views/projects/tree/_truncated_notice_tree_row.html.haml
app/views/projects/tree/_truncated_notice_tree_row.html.haml
+0
-7
ee/app/helpers/ee/tree_helper.rb
ee/app/helpers/ee/tree_helper.rb
+0
-9
ee/spec/helpers/ee/tree_helper_spec.rb
ee/spec/helpers/ee/tree_helper_spec.rb
+0
-42
spec/helpers/tree_helper_spec.rb
spec/helpers/tree_helper_spec.rb
+0
-88
spec/views/projects/tree/_tree_row.html.haml_spec.rb
spec/views/projects/tree/_tree_row.html.haml_spec.rb
+0
-43
No files found.
app/helpers/tree_helper.rb
View file @
3ee2cd7d
...
...
@@ -6,28 +6,6 @@ module TreeHelper
FILE_LIMIT
=
1_000
# Sorts a repository's tree so that folders are before files and renders
# their corresponding partials
#
# tree - A `Tree` object for the current tree
# rubocop: disable CodeReuse/ActiveRecord
def
render_tree
(
tree
)
# Sort submodules and folders together by name ahead of files
folders
,
files
,
submodules
=
tree
.
trees
,
tree
.
blobs
,
tree
.
submodules
tree
=
[]
items
=
(
folders
+
submodules
).
sort_by
(
&
:name
)
+
files
if
items
.
size
>
FILE_LIMIT
tree
<<
render
(
partial:
'projects/tree/truncated_notice_tree_row'
,
locals:
{
limit:
FILE_LIMIT
,
total:
items
.
size
})
items
=
items
.
take
(
FILE_LIMIT
)
end
tree
<<
render
(
partial:
'projects/tree/tree_row'
,
collection:
items
)
if
items
.
present?
tree
.
join
.
html_safe
end
# rubocop: enable CodeReuse/ActiveRecord
# Return an image icon depending on the file type and mode
#
# type - String type of the tree item; either 'folder' or 'file'
...
...
@@ -37,20 +15,6 @@ module TreeHelper
sprite_icon
(
file_type_icon_class
(
type
,
mode
,
name
))
end
# Using Rails `*_path` methods can be slow, especially when generating
# many paths, as with a repository tree that has thousands of items.
def
fast_project_blob_path
(
project
,
blob_path
)
ActionDispatch
::
Journey
::
Router
::
Utils
.
escape_path
(
File
.
join
(
relative_url_root
,
project
.
path_with_namespace
,
'-'
,
'blob'
,
blob_path
)
)
end
def
fast_project_tree_path
(
project
,
tree_path
)
ActionDispatch
::
Journey
::
Router
::
Utils
.
escape_path
(
File
.
join
(
relative_url_root
,
project
.
path_with_namespace
,
'-'
,
'tree'
,
tree_path
)
)
end
# Simple shortcut to File.join
def
tree_join
(
*
args
)
File
.
join
(
*
args
)
...
...
@@ -167,13 +131,6 @@ module TreeHelper
Gitlab
.
config
.
gitlab
.
relative_url_root
.
presence
||
'/'
end
# project and path are used on the EE version
def
tree_content_data
(
logs_path
,
project
,
path
)
{
"logs-path"
=>
logs_path
}
end
def
breadcrumb_data_attributes
attrs
=
{
can_collaborate:
can_collaborate_with_project?
(
@project
).
to_s
,
...
...
app/views/projects/tree/_readme.html.haml
deleted
100644 → 0
View file @
2a62b9da
-
if
readme
.
rich_viewer
%article
.file-holder.readme-holder
{
id:
'readme'
,
class:
[(
"limited-width-container"
unless
fluid_layout
)]
}
.js-file-title.file-title-flex-parent
.file-header-content
=
blob_icon
readme
.
mode
,
readme
.
name
=
link_to
project_blob_path
(
@project
,
tree_join
(
@ref
,
readme
.
path
))
do
%strong
=
readme
.
name
=
render
'projects/blob/viewer'
,
viewer:
readme
.
rich_viewer
,
viewer_url:
project_blob_path
(
@project
,
tree_join
(
@ref
,
readme
.
path
),
viewer: :rich
,
format: :json
)
app/views/projects/tree/_tree_content.html.haml
deleted
100644 → 0
View file @
2a62b9da
.tree-content-holder.js-tree-content
{
data:
tree_content_data
(
@logs_path
,
@project
,
@path
)
}
.table-holder.bordered-box
%table
.table
#tree-slider
{
class:
"table_#{@hex_path} tree-table"
}
%thead
%tr
%th
=
s_
(
'ProjectFileTree|Name'
)
%th
.d-none.d-sm-table-cell
.float-left
=
_
(
'Last commit'
)
%th
.text-right
=
_
(
'Last update'
)
-
if
@path
.
present?
%tr
.tree-item
%td
.tree-item-file-name
=
link_to
".."
,
project_tree_path
(
@project
,
up_dir_path
),
class:
'gl-ml-3'
%td
%td
.d-none.d-sm-table-cell
=
render_tree
(
tree
)
-
if
tree
.
readme
=
render
"projects/tree/readme"
,
readme:
tree
.
readme
-
if
can_edit_tree?
=
render
'projects/blob/upload'
,
title:
_
(
'Upload New File'
),
placeholder:
_
(
'Upload New File'
),
button_title:
_
(
'Upload file'
),
form_path:
project_create_blob_path
(
@project
,
@id
),
method: :post
=
render
'projects/blob/new_dir'
app/views/projects/tree/_tree_row.html.haml
deleted
100644 → 0
View file @
2a62b9da
-
tree_row_name
=
tree_row
.
name
-
tree_row_type
=
tree_row
.
type
%tr
{
class:
"tree-item file_#{hexdigest(tree_row_name)}"
}
%td
.tree-item-file-name
-
if
tree_row_type
==
:tree
=
tree_icon
(
'folder'
,
tree_row
.
mode
,
tree_row
.
name
)
-
path
=
flatten_tree
(
@path
,
tree_row
)
%a
.str-truncated
{
href:
fast_project_tree_path
(
@project
,
tree_join
(
@id
||
@commit
.
id
,
path
)),
title:
path
}
%span
=
path
-
elsif
tree_row_type
==
:blob
=
tree_icon
(
'file'
,
tree_row
.
mode
,
tree_row_name
)
%a
.str-truncated
{
href:
fast_project_blob_path
(
@project
,
tree_join
(
@id
||
@commit
.
id
,
tree_row_name
)),
title:
tree_row_name
}
%span
=
tree_row_name
-
if
@lfs_blob_ids
.
include?
(
tree_row
.
id
)
%span
.badge.label-lfs.gl-ml-2
LFS
-
elsif
tree_row_type
==
:commit
=
tree_icon
(
'archive'
,
tree_row
.
mode
,
tree_row
.
name
)
=
submodule_link
(
tree_row
,
@ref
)
%td
.d-none.d-sm-table-cell.tree-commit
%td
.tree-time-ago.text-right
%span
.log_loading.hide
=
loading_icon
Loading commit data...
app/views/projects/tree/_truncated_notice_tree_row.html.haml
deleted
100644 → 0
View file @
2a62b9da
%tr
.tree-truncated-warning
%td
{
colspan:
'3'
}
=
sprite_icon
(
'warning-solid'
)
%span
Too many items to show. To preserve performance only
%strong
#{
number_with_delimiter
(
limit
)
}
of
#{
number_with_delimiter
(
total
)
}
items are displayed.
ee/app/helpers/ee/tree_helper.rb
View file @
3ee2cd7d
...
...
@@ -4,15 +4,6 @@ module EE
module
TreeHelper
extend
::
Gitlab
::
Utils
::
Override
override
:tree_content_data
def
tree_content_data
(
logs_path
,
project
,
path
)
super
.
merge
({
"path-locks-available"
=>
project
.
feature_available?
(
:file_locks
).
to_s
,
"path-locks-toggle"
=>
toggle_project_path_locks_path
(
project
),
"path-locks-path"
=>
path
})
end
override
:vue_file_list_data
def
vue_file_list_data
(
project
,
ref
)
super
.
merge
({
...
...
ee/spec/helpers/ee/tree_helper_spec.rb
deleted
100644 → 0
View file @
2a62b9da
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
TreeHelper
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
describe
'#tree_content_data'
do
let
(
:logs_path
)
{
"
#{
project
.
full_path
}
/refs/master/logs_tree/"
}
let
(
:path
)
{
'.gitlab/template_test'
}
context
'when file locks is available'
do
it
'returns the logs path'
do
stub_licensed_features
(
file_locks:
true
)
tree_content_data
=
{
"logs-path"
=>
logs_path
,
"path-locks-available"
=>
"true"
,
"path-locks-toggle"
=>
toggle_project_path_locks_path
(
project
),
"path-locks-path"
=>
path
}
expect
(
helper
.
tree_content_data
(
logs_path
,
project
,
path
)).
to
eq
(
tree_content_data
)
end
end
context
'when file lock is not available'
do
it
'returns the path information'
do
stub_licensed_features
(
file_locks:
false
)
tree_content_data
=
{
"logs-path"
=>
logs_path
,
"path-locks-available"
=>
"false"
,
"path-locks-toggle"
=>
toggle_project_path_locks_path
(
project
),
"path-locks-path"
=>
path
}
expect
(
helper
.
tree_content_data
(
logs_path
,
project
,
path
)).
to
eq
(
tree_content_data
)
end
end
end
end
spec/helpers/tree_helper_spec.rb
View file @
3ee2cd7d
...
...
@@ -19,94 +19,6 @@ RSpec.describe TreeHelper do
)
end
describe
'.render_tree'
do
before
do
@id
=
sha
@path
=
""
@project
=
project
@lfs_blob_ids
=
[]
end
it
'displays all entries without a warning'
do
tree
=
repository
.
tree
(
sha
,
'files'
)
html
=
render_tree
(
tree
)
expect
(
html
).
not_to
have_selector
(
'.tree-truncated-warning'
)
end
it
'truncates entries and adds a warning'
do
stub_const
(
'TreeHelper::FILE_LIMIT'
,
1
)
tree
=
repository
.
tree
(
sha
,
'files'
)
html
=
render_tree
(
tree
)
expect
(
html
).
to
have_selector
(
'.tree-truncated-warning'
,
count:
1
)
expect
(
html
).
to
have_selector
(
'.tree-item-file-name'
,
count:
1
)
end
end
describe
'.fast_project_blob_path'
do
it
'generates the same path as project_blob_path'
do
blob_path
=
repository
.
tree
(
sha
,
'with space'
).
entries
.
first
.
path
fast_path
=
fast_project_blob_path
(
project
,
blob_path
)
std_path
=
project_blob_path
(
project
,
blob_path
)
expect
(
fast_path
).
to
eq
(
std_path
)
end
it
'generates the same path with encoded file names'
do
tree
=
repository
.
tree
(
sha
,
'encoding'
)
blob_path
=
tree
.
entries
.
find
{
|
entry
|
entry
.
path
==
'encoding/テスト.txt'
}.
path
fast_path
=
fast_project_blob_path
(
project
,
blob_path
)
std_path
=
project_blob_path
(
project
,
blob_path
)
expect
(
fast_path
).
to
eq
(
std_path
)
end
it
'respects a configured relative URL'
do
allow
(
Gitlab
.
config
.
gitlab
).
to
receive
(
:relative_url_root
).
and_return
(
'/gitlab/root'
)
blob_path
=
repository
.
tree
(
sha
,
''
).
entries
.
first
.
path
fast_path
=
fast_project_blob_path
(
project
,
blob_path
)
expect
(
fast_path
).
to
start_with
(
'/gitlab/root'
)
end
it
'encodes files starting with #'
do
filename
=
'#test-file'
create_file
(
filename
)
fast_path
=
fast_project_blob_path
(
project
,
filename
)
expect
(
fast_path
).
to
end_with
(
'%23test-file'
)
end
end
describe
'.fast_project_tree_path'
do
let
(
:tree_path
)
{
repository
.
tree
(
sha
,
'with space'
).
path
}
let
(
:fast_path
)
{
fast_project_tree_path
(
project
,
tree_path
)
}
let
(
:std_path
)
{
project_tree_path
(
project
,
tree_path
)
}
it
'generates the same path as project_tree_path'
do
expect
(
fast_path
).
to
eq
(
std_path
)
end
it
'respects a configured relative URL'
do
allow
(
Gitlab
.
config
.
gitlab
).
to
receive
(
:relative_url_root
).
and_return
(
'/gitlab/root'
)
expect
(
fast_path
).
to
start_with
(
'/gitlab/root'
)
end
it
'encodes files starting with #'
do
filename
=
'#test-file'
create_file
(
filename
)
fast_path
=
fast_project_tree_path
(
project
,
filename
)
expect
(
fast_path
).
to
end_with
(
'%23test-file'
)
end
end
describe
'flatten_tree'
do
let
(
:tree
)
{
repository
.
tree
(
sha
,
'files'
)
}
let
(
:root_path
)
{
'files'
}
...
...
spec/views/projects/tree/_tree_row.html.haml_spec.rb
deleted
100644 → 0
View file @
2a62b9da
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'projects/tree/_tree_row'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
# rubocop: disable Rails/FindBy
# This is not ActiveRecord where..first
let
(
:blob_item
)
{
Gitlab
::
Git
::
Tree
.
where
(
repository
,
SeedRepo
::
Commit
::
ID
,
'files/ruby'
).
first
}
# rubocop: enable Rails/FindBy
before
do
assign
(
:project
,
project
)
assign
(
:repository
,
repository
)
assign
(
:id
,
File
.
join
(
'master'
,
''
))
assign
(
:lfs_blob_ids
,
[])
end
it
'renders blob item'
do
render_partial
(
blob_item
)
expect
(
rendered
).
to
have_content
(
blob_item
.
name
)
expect
(
rendered
).
not_to
have_selector
(
'.label-lfs'
,
text:
'LFS'
)
end
describe
'LFS blob'
do
before
do
assign
(
:lfs_blob_ids
,
[
blob_item
].
map
(
&
:id
))
render_partial
(
blob_item
)
end
it
'renders LFS badge'
do
expect
(
rendered
).
to
have_selector
(
'.label-lfs'
,
text:
'LFS'
)
end
end
def
render_partial
(
items
)
render
partial:
'projects/tree/tree_row'
,
collection:
[
items
].
flatten
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