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
a052f681
Commit
a052f681
authored
Jan 28, 2019
by
Camil Staps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pagination to {project}/starrers view
parent
6baff650
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
20 deletions
+12
-20
app/controllers/projects/starrers_controller.rb
app/controllers/projects/starrers_controller.rb
+3
-5
app/finders/users_star_projects_finder.rb
app/finders/users_star_projects_finder.rb
+1
-8
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+5
-0
app/helpers/users_helper.rb
app/helpers/users_helper.rb
+0
-5
app/views/projects/starrers/index.html.haml
app/views/projects/starrers/index.html.haml
+3
-2
No files found.
app/controllers/projects/starrers_controller.rb
View file @
a052f681
...
@@ -6,14 +6,12 @@ class Projects::StarrersController < Projects::ApplicationController
...
@@ -6,14 +6,12 @@ class Projects::StarrersController < Projects::ApplicationController
# Authorize
# Authorize
before_action
:require_non_empty_project
before_action
:require_non_empty_project
# rubocop: disable CodeReuse/ActiveRecord
def
index
def
index
@sort
=
params
[
:sort
].
presence
||
sort_value_name
@sort
=
params
[
:sort
].
presence
||
sort_value_name
params
[
:project
]
=
@project
@starrers
=
UsersStarProjectsFinder
.
new
(
params
).
execute
@starrers
=
UsersStarProjectsFinder
.
new
(
params
).
execute
@starrers
=
@starrers
.
sort_by_attribute
(
@sort
)
@starrers
=
@starrers
.
by_project
(
@project
)
@starrers
=
@starrers
.
sort_by_attribute
(
@sort
).
page
(
params
[
:page
])
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
app/finders/users_star_projects_finder.rb
View file @
a052f681
...
@@ -12,7 +12,6 @@ class UsersStarProjectsFinder
...
@@ -12,7 +12,6 @@ class UsersStarProjectsFinder
def
execute
def
execute
stars
=
UsersStarProject
.
all
.
order_id_desc
stars
=
UsersStarProject
.
all
.
order_id_desc
stars
=
by_search
(
stars
)
stars
=
by_search
(
stars
)
stars
=
by_project
(
stars
)
stars
stars
end
end
...
@@ -20,12 +19,6 @@ class UsersStarProjectsFinder
...
@@ -20,12 +19,6 @@ class UsersStarProjectsFinder
private
private
def
by_search
(
items
)
def
by_search
(
items
)
return
items
unless
params
[
:search
].
present?
params
[
:search
].
present?
?
items
.
search
(
params
[
:search
])
:
items
items
.
search
(
params
[
:search
])
end
def
by_project
(
items
)
params
[
:project
].
present?
?
items
.
by_project
(
params
[
:project
])
:
items
end
end
end
end
app/helpers/projects_helper.rb
View file @
a052f681
...
@@ -601,6 +601,11 @@ module ProjectsHelper
...
@@ -601,6 +601,11 @@ module ProjectsHelper
end
end
end
end
def
filter_starrer_path
(
options
=
{})
options
=
params
.
slice
(
:sort
).
merge
(
options
).
permit!
"
#{
request
.
path
}
?
#{
options
.
to_param
}
"
end
def
sidebar_projects_paths
def
sidebar_projects_paths
%w[
%w[
projects#show
projects#show
...
...
app/helpers/users_helper.rb
View file @
a052f681
...
@@ -108,9 +108,4 @@ module UsersHelper
...
@@ -108,9 +108,4 @@ module UsersHelper
items
items
end
end
def
filter_user_path
(
options
=
{})
options
=
params
.
slice
(
:sort
).
merge
(
options
).
permit!
"
#{
request
.
path
}
?
#{
options
.
to_param
}
"
end
end
end
app/views/projects/starrers/index.html.haml
View file @
a052f681
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
.nav-text
.nav-text
%span
.flex-project-title
%span
.flex-project-title
=
_
(
"Starrers of <strong>%{project_name}</strong>"
).
html_safe
%
{
project_name:
sanitize_project_name
(
@project
.
name
)
}
=
_
(
"Starrers of <strong>%{project_name}</strong>"
).
html_safe
%
{
project_name:
sanitize_project_name
(
@project
.
name
)
}
%span
.badge.badge-pill
=
@starrers
.
size
%span
.badge.badge-pill
=
@starrers
.
total_count
-
if
@starrers
.
size
>
0
-
if
@starrers
.
size
>
0
.nav-controls
.nav-controls
=
form_tag
request
.
original_url
,
method: :get
,
class:
'form-inline user-search-form flex-users-form'
do
=
form_tag
request
.
original_url
,
method: :get
,
class:
'form-inline user-search-form flex-users-form'
do
...
@@ -20,10 +20,11 @@
...
@@ -20,10 +20,11 @@
=
_
(
"Sort by"
)
=
_
(
"Sort by"
)
-
starrers_sort_options_hash
.
each
do
|
value
,
title
|
-
starrers_sort_options_hash
.
each
do
|
value
,
title
|
%li
%li
=
link_to
filter_
us
er_path
(
sort:
value
),
class:
(
"is-active"
if
@sort
==
value
)
do
=
link_to
filter_
starr
er_path
(
sort:
value
),
class:
(
"is-active"
if
@sort
==
value
)
do
=
title
=
title
-
if
@starrers
.
size
>
0
-
if
@starrers
.
size
>
0
.row.prepend-top-10
.row.prepend-top-10
=
render
partial:
'starrer'
,
collection:
@starrers
,
as: :starrer
=
render
partial:
'starrer'
,
collection:
@starrers
,
as: :starrer
=
paginate
@starrers
,
theme:
'gitlab'
-
else
-
else
.nothing-here-block
Nobody has starred this repository yet
.nothing-here-block
Nobody has starred this repository yet
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