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
Jérome Perrin
gitlab-ce
Commits
f96ce407
Commit
f96ce407
authored
9 years ago
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve implementation to check read access to forks and add pagination.
parent
baa5f7fc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
+22
-14
app/controllers/projects/forks_controller.rb
app/controllers/projects/forks_controller.rb
+16
-6
app/views/projects/forks/index.html.haml
app/views/projects/forks/index.html.haml
+6
-8
No files found.
app/controllers/projects/forks_controller.rb
View file @
f96ce407
...
@@ -4,12 +4,22 @@ class Projects::ForksController < Projects::ApplicationController
...
@@ -4,12 +4,22 @@ class Projects::ForksController < Projects::ApplicationController
before_action
:authorize_download_code!
before_action
:authorize_download_code!
def
index
def
index
@sort
=
params
[
:sort
]
||
'id_desc'
base_query
=
project
.
forks
.
includes
(
:creator
)
@all_forks
=
project
.
forks
.
includes
(
:creator
).
order_by
(
@sort
)
@public_forks
,
@protected_forks
=
@all_forks
.
partition
do
|
project
|
@forks
=
if
current_user
can?
(
current_user
,
:read_project
,
project
)
base_query
.
where
(
'projects.visibility_level IN (?) OR projects.id IN (?)'
,
Project
::
PUBLIC
,
current_user
.
authorized_projects
.
pluck
(
:id
))
else
base_query
.
where
(
'projects.visibility_level = ?'
,
Project
::
PUBLIC
)
end
end
@total_forks_count
=
base_query
.
size
@private_forks_count
=
@total_forks_count
-
@forks
.
size
@public_forks_count
=
@total_forks_count
-
@private_forks_count
@sort
=
params
[
:sort
]
||
'id_desc'
@forks
=
@forks
.
order_by
(
@sort
).
page
(
params
[
:page
]).
per
(
PER_PAGE
)
end
end
def
new
def
new
...
...
This diff is collapsed.
Click to expand it.
app/views/projects/forks/index.html.haml
View file @
f96ce407
.top-area
.top-area
.nav-text
.nav-text
-
public_count
=
@public_forks
.
size
-
full_count_title
=
"
#{
@public_forks_count
}
public and
#{
@private_forks_count
}
private"
-
protected_count
=
@protected_forks
.
size
==
#{
pluralize
(
@total_forks_count
,
'fork'
)
}
:
#{
full_count_title
}
-
full_count_title
=
"
#{
public_count
}
public and
#{
protected_count
}
private"
==
#{
pluralize
(
@all_forks
.
size
,
'fork'
)
}
:
#{
full_count_title
}
.nav-controls
.nav-controls
=
search_field_tag
:filter_projects
,
nil
,
placeholder:
'Search forks'
,
class:
'projects-list-filter project-filter-form-field form-control input-short'
,
=
search_field_tag
:filter_projects
,
nil
,
placeholder:
'Search forks'
,
class:
'projects-list-filter project-filter-form-field form-control input-short'
,
...
@@ -41,17 +39,17 @@
...
@@ -41,17 +39,17 @@
.projects-list-holder
.projects-list-holder
-
if
@
public_
forks
.
blank?
-
if
@forks
.
blank?
%ul
.content-list
%ul
.content-list
%li
%li
.nothing-here-block
No forks to show
.nothing-here-block
No forks to show
-
else
-
else
=
render
'shared/projects/list'
,
projects:
@
public_
forks
,
use_creator_avatar:
true
,
=
render
'shared/projects/list'
,
projects:
@forks
,
use_creator_avatar:
true
,
forks:
true
,
show_last_commit_as_description:
true
forks:
true
,
show_last_commit_as_description:
true
-
if
protected
_count
>
0
-
if
@private_forks
_count
>
0
%ul
.projects-list.private-forks-notice
%ul
.projects-list.private-forks-notice
%li
.project-row
%li
.project-row
=
icon
(
'lock fw'
,
base:
'circle'
,
class:
'fa-lg private-fork-icon'
)
=
icon
(
'lock fw'
,
base:
'circle'
,
class:
'fa-lg private-fork-icon'
)
%strong
=
pluralize
(
protected
_count
,
'private fork'
)
%strong
=
pluralize
(
@private_forks
_count
,
'private fork'
)
%span
you have no access to.
%span
you have no access to.
This diff is collapsed.
Click to expand it.
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