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
0d236638
Commit
0d236638
authored
Sep 23, 2017
by
Vitaliy @blackst0ne Klachkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve list of sorting options
parent
024d10b7
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
304 additions
and
332 deletions
+304
-332
app/controllers/concerns/issuable_collections.rb
app/controllers/concerns/issuable_collections.rb
+20
-7
app/helpers/sorting_helper.rb
app/helpers/sorting_helper.rb
+173
-131
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+13
-11
app/models/concerns/sortable.rb
app/models/concerns/sortable.rb
+8
-7
app/models/issue.rb
app/models/issue.rb
+2
-1
app/views/shared/_sort_dropdown.html.haml
app/views/shared/_sort_dropdown.html.haml
+11
-31
changelogs/unreleased/improve_sorting_list.yml
changelogs/unreleased/improve_sorting_list.yml
+5
-0
features/project/issues/issues.feature
features/project/issues/issues.feature
+8
-10
features/project/merge_requests.feature
features/project/merge_requests.feature
+7
-9
features/steps/project/issues/issues.rb
features/steps/project/issues/issues.rb
+1
-1
features/steps/project/merge_requests.rb
features/steps/project/merge_requests.rb
+1
-1
features/steps/shared/issuable.rb
features/steps/shared/issuable.rb
+6
-6
spec/features/dashboard/issues_filter_spec.rb
spec/features/dashboard/issues_filter_spec.rb
+4
-4
spec/features/dashboard/merge_requests_spec.rb
spec/features/dashboard/merge_requests_spec.rb
+4
-4
spec/features/issuables/default_sort_order_spec.rb
spec/features/issuables/default_sort_order_spec.rb
+12
-26
spec/features/issues/filtered_search/filter_issues_spec.rb
spec/features/issues/filtered_search/filter_issues_spec.rb
+7
-9
spec/features/issues_spec.rb
spec/features/issues_spec.rb
+11
-41
spec/features/merge_requests/filter_merge_requests_spec.rb
spec/features/merge_requests/filter_merge_requests_spec.rb
+2
-2
spec/features/merge_requests/user_lists_merge_requests_spec.rb
...features/merge_requests/user_lists_merge_requests_spec.rb
+9
-31
No files found.
app/controllers/concerns/issuable_collections.rb
View file @
0d236638
...
...
@@ -117,19 +117,32 @@ module IssuableCollections
key
=
'issuable_sort'
cookies
[
key
]
=
params
[
:sort
]
if
params
[
:sort
].
present?
# id_desc and id_asc are old values for these two.
cookies
[
key
]
=
sort_value_recently_created
if
cookies
[
key
]
==
'id_desc'
cookies
[
key
]
=
sort_value_oldest_created
if
cookies
[
key
]
==
'id_asc'
cookies
[
key
]
=
update_cookie_value
(
cookies
[
key
])
params
[
:sort
]
=
cookies
[
key
]
end
def
default_sort_order
case
params
[
:state
]
when
'opened'
,
'all'
then
sort_value_recently_created
when
'opened'
,
'all'
then
sort_value_created_date
when
'merged'
,
'closed'
then
sort_value_recently_updated
else
sort_value_recently_created
else
sort_value_created_date
end
end
# Update old values to the actual ones.
def
update_cookie_value
(
value
)
case
value
when
'id_asc'
then
sort_value_oldest_created
when
'id_desc'
then
sort_value_recently_created
when
'created_asc'
then
sort_value_created_date
when
'created_desc'
then
sort_value_created_date
when
'due_date_asc'
then
sort_value_due_date
when
'due_date_desc'
then
sort_value_due_date
when
'milestone_due_asc'
then
sort_value_milestone
when
'milestone_due_desc'
then
sort_value_milestone
when
'downvotes_asc'
then
sort_value_popularity
when
'downvotes_desc'
then
sort_value_popularity
else
value
end
end
end
app/helpers/sorting_helper.rb
View file @
0d236638
module
SortingHelper
def
sort_options_hash
{
sort_value_name
=>
sort_title_name
,
sort_value_name_desc
=>
sort_title_name_desc
,
sort_value_recently_updated
=>
sort_title_recently_updated
,
sort_value_oldest_updated
=>
sort_title_oldest_updated
,
sort_value_created_date
=>
sort_title_created_date
,
sort_value_downvotes
=>
sort_title_downvotes
,
sort_value_due_date
=>
sort_title_due_date
,
sort_value_due_date_later
=>
sort_title_due_date_later
,
sort_value_due_date_soon
=>
sort_title_due_date_soon
,
sort_value_label_priority
=>
sort_title_label_priority
,
sort_value_largest_group
=>
sort_title_largest_group
,
sort_value_largest_repo
=>
sort_title_largest_repo
,
sort_value_milestone
=>
sort_title_milestone
,
sort_value_milestone_later
=>
sort_title_milestone_later
,
sort_value_milestone_soon
=>
sort_title_milestone_soon
,
sort_value_name
=>
sort_title_name
,
sort_value_name_desc
=>
sort_title_name_desc
,
sort_value_oldest_created
=>
sort_title_oldest_created
,
sort_value_oldest_signin
=>
sort_title_oldest_signin
,
sort_value_oldest_updated
=>
sort_title_oldest_updated
,
sort_value_recently_created
=>
sort_title_recently_created
,
sort_value_oldest_created
=>
sort_title_oldest_created
,
sort_value_milestone_soon
=>
sort_title_milestone_soon
,
sort_value_milestone_later
=>
sort_title_milestone_later
,
sort_value_due_date_soon
=>
sort_title_due_date_soon
,
sort_value_due_date_later
=>
sort_title_due_date_later
,
sort_value_largest_repo
=>
sort_title_largest_repo
,
sort_value_largest_group
=>
sort_title_largest_group
,
sort_value_recently_signin
=>
sort_title_recently_signin
,
sort_value_oldest_signin
=>
sort_title_oldest_signin
,
sort_value_downvotes
=>
sort_title_downvotes
,
sort_value_upvotes
=>
sort_title_upvotes
,
sort_value_priority
=>
sort_title_priority
,
sort_value_label_priority
=>
sort_title_label_priority
sort_value_recently_signin
=>
sort_title_recently_signin
,
sort_value_recently_updated
=>
sort_title_recently_updated
,
sort_value_popularity
=>
sort_title_popularity
,
sort_value_priority
=>
sort_title_priority
,
sort_value_upvotes
=>
sort_title_upvotes
}
end
def
projects_sort_options_hash
options
=
{
sort_value_
name
=>
sort_title_name
,
sort_value_
latest_activity
=>
sort_title_latest_activity
,
sort_value_oldest_activity
=>
sort_title_oldest_activity
,
sort_value_
recently_created
=>
sort_title_recently
_created
,
sort_value_
oldest_created
=>
sort_title_oldest
_created
sort_value_
latest_activity
=>
sort_title_latest_activity
,
sort_value_
name
=>
sort_title_name
,
sort_value_oldest_activity
=>
sort_title_oldest_activity
,
sort_value_
oldest_created
=>
sort_title_oldest
_created
,
sort_value_
recently_created
=>
sort_title_recently
_created
}
if
current_controller?
(
'admin/projects'
)
...
...
@@ -40,160 +44,174 @@ module SortingHelper
def
member_sort_options_hash
{
sort_value_access_level_asc
=>
sort_title_access_level_asc
,
sort_value_access_level_asc
=>
sort_title_access_level_asc
,
sort_value_access_level_desc
=>
sort_title_access_level_desc
,
sort_value_last_joined
=>
sort_title_last_joined
,
sort_value_
oldest_joined
=>
sort_title_oldest_joined
,
sort_value_name
=>
sort_title_name_a
sc
,
sort_value_
name_desc
=>
sort_title_name_desc
,
sort_value_
recently_signin
=>
sort_title_recently
_signin
,
sort_value_
oldest_signin
=>
sort_title_oldest
_signin
sort_value_last_joined
=>
sort_title_last_joined
,
sort_value_
name
=>
sort_title_name_asc
,
sort_value_name
_desc
=>
sort_title_name_de
sc
,
sort_value_
oldest_joined
=>
sort_title_oldest_joined
,
sort_value_
oldest_signin
=>
sort_title_oldest
_signin
,
sort_value_
recently_signin
=>
sort_title_recently
_signin
}
end
def
milestone_sort_options_hash
{
sort_value_name
=>
sort_title_name_asc
,
sort_value_name_desc
=>
sort_title_name_desc
,
sort_value_due_date_
soon
=>
sort_title_due_date_soon
,
sort_value_due_date_
later
=>
sort_title_due_date_later
,
sort_value_start_date_
soon
=>
sort_title_start_date_soon
,
sort_value_start_date_
later
=>
sort_title_start_date_later
sort_value_name
=>
sort_title_name_asc
,
sort_value_name_desc
=>
sort_title_name_desc
,
sort_value_due_date_
later
=>
sort_title_due_date_later
,
sort_value_due_date_
soon
=>
sort_title_due_date_soon
,
sort_value_start_date_
later
=>
sort_title_start_date_later
,
sort_value_start_date_
soon
=>
sort_title_start_date_soon
}
end
def
branches_sort_options_hash
{
sort_value_name
=>
sort_title_name
,
sort_value_
recently_updated
=>
sort_title_recently
_updated
,
sort_value_
oldest_updated
=>
sort_title_oldest
_updated
sort_value_name
=>
sort_title_name
,
sort_value_
oldest_updated
=>
sort_title_oldest
_updated
,
sort_value_
recently_updated
=>
sort_title_recently
_updated
}
end
def
tags_sort_options_hash
{
sort_value_name
=>
sort_title_name
,
sort_value_
recently_updated
=>
sort_title_recently
_updated
,
sort_value_
oldest_updated
=>
sort_title_oldest
_updated
sort_value_name
=>
sort_title_name
,
sort_value_
oldest_updated
=>
sort_title_oldest
_updated
,
sort_value_
recently_updated
=>
sort_title_recently
_updated
}
end
def
sort
_title_priority
s_
(
'SortOptions|Priority'
)
def
sort
able_item
(
item
,
path
,
sorted_by
)
link_to
item
,
path
,
class:
sorted_by
==
item
?
'is-active'
:
''
end
def
sort_title_label_priority
s_
(
'SortOptions|Label priority'
)
# Titles.
def
sort_title_access_level_asc
s_
(
'SortOptions|Access level, ascending'
)
end
def
sort_title_
oldest_updated
s_
(
'SortOptions|
Oldest updated
'
)
def
sort_title_
access_level_desc
s_
(
'SortOptions|
Access level, descending
'
)
end
def
sort_title_
recently_updated
s_
(
'SortOptions|
Last updated
'
)
def
sort_title_
created_date
s_
(
'SortOptions|
Created date
'
)
end
def
sort_title_
oldest_activity
s_
(
'SortOptions|
Oldest updated
'
)
def
sort_title_
downvotes
s_
(
'SortOptions|
Least popular
'
)
end
def
sort_title_
latest_activity
s_
(
'SortOptions|
Last updated
'
)
def
sort_title_
due_date
s_
(
'SortOptions|
Due date
'
)
end
def
sort_title_
oldest_created
s_
(
'SortOptions|
Oldest created
'
)
def
sort_title_
due_date_later
s_
(
'SortOptions|
Due later
'
)
end
def
sort_title_
recently_created
s_
(
'SortOptions|
Last created
'
)
def
sort_title_
due_date_soon
s_
(
'SortOptions|
Due soon
'
)
end
def
sort_title_
milestone_soon
s_
(
'SortOptions|
Milestone due soon
'
)
def
sort_title_
label_priority
s_
(
'SortOptions|
Label priority
'
)
end
def
sort_title_
milestone_later
s_
(
'SortOptions|
Milestone due later
'
)
def
sort_title_
largest_group
s_
(
'SortOptions|
Largest group
'
)
end
def
sort_title_
due_date_soon
s_
(
'SortOptions|
Due soon
'
)
def
sort_title_
largest_repo
s_
(
'SortOptions|
Largest repository
'
)
end
def
sort_title_
due_date_later
s_
(
'SortOptions|
Due later
'
)
def
sort_title_
last_joined
s_
(
'SortOptions|
Last joined
'
)
end
def
sort_title_
start_date_soon
s_
(
'SortOptions|
Start soon
'
)
def
sort_title_
latest_activity
s_
(
'SortOptions|
Last updated
'
)
end
def
sort_title_start_date_later
s_
(
'SortOptions|Start later'
)
def
sort_title_milestone
s_
(
'SortOptions|Milestone'
)
end
def
sort_title_milestone_later
s_
(
'SortOptions|Milestone due later'
)
end
def
sort_title_milestone_soon
s_
(
'SortOptions|Milestone due soon'
)
end
def
sort_title_name
s_
(
'SortOptions|Name'
)
end
def
sort_title_
largest_repo
s_
(
'SortOptions|
Largest repository
'
)
def
sort_title_
name_asc
s_
(
'SortOptions|
Name, ascending
'
)
end
def
sort_title_
largest_group
s_
(
'SortOptions|
Largest group
'
)
def
sort_title_
name_desc
s_
(
'SortOptions|
Name, descending
'
)
end
def
sort_title_
recently_signin
s_
(
'SortOptions|
Recent sign in
'
)
def
sort_title_
oldest_activity
s_
(
'SortOptions|
Oldest updated
'
)
end
def
sort_title_oldest_
signin
s_
(
'SortOptions|Oldest
sign in
'
)
def
sort_title_oldest_
created
s_
(
'SortOptions|Oldest
created
'
)
end
def
sort_title_
downvotes
s_
(
'SortOptions|
Least popular
'
)
def
sort_title_
oldest_joined
s_
(
'SortOptions|
Oldest joined
'
)
end
def
sort_title_
upvotes
s_
(
'SortOptions|
Most popular
'
)
def
sort_title_
oldest_signin
s_
(
'SortOptions|
Oldest sign in
'
)
end
def
sort_title_
last_join
ed
s_
(
'SortOptions|
Last join
ed'
)
def
sort_title_
oldest_updat
ed
s_
(
'SortOptions|
Oldest updat
ed'
)
end
def
sort_title_
oldest_joined
s_
(
'SortOptions|
Oldest joined
'
)
def
sort_title_
popularity
s_
(
'SortOptions|
Popularity
'
)
end
def
sort_title_
access_level_asc
s_
(
'SortOptions|
Access level, ascending
'
)
def
sort_title_
priority
s_
(
'SortOptions|
Priority
'
)
end
def
sort_title_
access_level_desc
s_
(
'SortOptions|
Access level, descending
'
)
def
sort_title_
recently_created
s_
(
'SortOptions|
Last created
'
)
end
def
sort_title_
name_asc
s_
(
'SortOptions|
Name, ascending
'
)
def
sort_title_
recently_signin
s_
(
'SortOptions|
Recent sign in
'
)
end
def
sort_title_
name_desc
s_
(
'SortOptions|
Name, descending
'
)
def
sort_title_
recently_updated
s_
(
'SortOptions|
Last updated
'
)
end
def
sort_
value_last_joined
'last_joined'
def
sort_
title_start_date_later
s_
(
'SortOptions|Start later'
)
end
def
sort_
value_oldest_joined
'oldest_joined'
def
sort_
title_start_date_soon
s_
(
'SortOptions|Start soon'
)
end
def
sort_title_upvotes
s_
(
'SortOptions|Most popular'
)
end
# Values.
def
sort_value_access_level_asc
'access_level_asc'
end
...
...
@@ -202,88 +220,112 @@ module SortingHelper
'access_level_desc'
end
def
sort_value_
name_desc
'
name_desc
'
def
sort_value_
created_date
'
created_date
'
end
def
sort_value_priority
'priority'
def
sort_value_downvotes
'downvotes_desc'
end
def
sort_value_due_date
'due_date'
end
def
sort_value_due_date_later
'due_date_desc'
end
def
sort_value_due_date_soon
'due_date_asc'
end
def
sort_value_label_priority
'label_priority'
end
def
sort_value_
oldest_updated
'
updated_a
sc'
def
sort_value_
largest_group
'
storage_size_de
sc'
end
def
sort_value_
recently_updated
'
updated
_desc'
def
sort_value_
largest_repo
'
storage_size
_desc'
end
def
sort_value_
oldest_activity
'la
test_activity_asc
'
def
sort_value_
last_joined
'la
st_joined
'
end
def
sort_value_latest_activity
'latest_activity_desc'
end
def
sort_value_
oldest_created
'
created_asc
'
def
sort_value_
milestone
'
milestone
'
end
def
sort_value_
recently_created
'
created
_desc'
def
sort_value_
milestone_later
'
milestone_due
_desc'
end
def
sort_value_milestone_soon
'milestone_due_asc'
end
def
sort_value_
milestone_later
'
milestone_due_de
sc'
def
sort_value_
name
'
name_a
sc'
end
def
sort_value_
due_date_soon
'
due_date_a
sc'
def
sort_value_
name_desc
'
name_de
sc'
end
def
sort_value_
due_date_later
'
due_date_de
sc'
def
sort_value_
oldest_activity
'
latest_activity_a
sc'
end
def
sort_value_
start_date_soon
'
start_date
_asc'
def
sort_value_
oldest_created
'
created
_asc'
end
def
sort_value_
start_date_later
'
start_date_desc
'
def
sort_value_
oldest_signin
'
oldest_sign_in
'
end
def
sort_value_
name
'
name_asc
'
def
sort_value_
oldest_joined
'
oldest_joined
'
end
def
sort_value_
largest_repo
'
storage_size_de
sc'
def
sort_value_
oldest_updated
'
updated_a
sc'
end
def
sort_value_largest_group
'storage_size_desc'
def
sort_value_popularity
'popularity'
end
def
sort_value_priority
'priority'
end
def
sort_value_recently_created
'created_desc'
end
def
sort_value_recently_signin
'recent_sign_in'
end
def
sort_value_
oldest_signin
'
oldest_sign_in
'
def
sort_value_
recently_updated
'
updated_desc
'
end
def
sort_value_downvotes
'downvotes_desc'
def
sort_value_start_date_later
'start_date_desc'
end
def
sort_value_start_date_soon
'start_date_asc'
end
def
sort_value_upvotes
...
...
app/models/concerns/issuable.rb
View file @
0d236638
...
...
@@ -143,16 +143,18 @@ module Issuable
end
def
sort
(
method
,
excluded_labels:
[])
sorted
=
case
method
.
to_s
when
'milestone_due_asc'
then
order_milestone_due_asc
when
'milestone_due_desc'
then
order_milestone_due_desc
when
'downvotes_desc'
then
order_downvotes_desc
when
'upvotes_desc'
then
order_upvotes_desc
when
'label_priority'
then
order_labels_priority
(
excluded_labels:
excluded_labels
)
when
'priority'
then
order_due_date_and_labels_priority
(
excluded_labels:
excluded_labels
)
else
order_by
(
method
)
end
sorted
=
case
method
.
to_s
when
'downvotes_desc'
then
order_downvotes_desc
when
'label_priority'
then
order_labels_priority
(
excluded_labels:
excluded_labels
)
when
'milestone'
then
order_milestone_due_asc
when
'milestone_due_asc'
then
order_milestone_due_asc
when
'milestone_due_desc'
then
order_milestone_due_desc
when
'popularity'
then
order_upvotes_desc
when
'priority'
then
order_due_date_and_labels_priority
(
excluded_labels:
excluded_labels
)
when
'upvotes_desc'
then
order_upvotes_desc
else
order_by
(
method
)
end
# Break ties with the ID column for pagination
sorted
.
order
(
id: :desc
)
...
...
@@ -214,7 +216,7 @@ module Issuable
def
grouping_columns
(
sort
)
grouping_columns
=
[
arel_table
[
:id
]]
if
%w(milestone_due_desc milestone_due_asc)
.
include?
(
sort
)
if
%w(milestone_due_desc milestone_due_asc
milestone
)
.
include?
(
sort
)
milestone_table
=
Milestone
.
arel_table
grouping_columns
<<
milestone_table
[
:id
]
grouping_columns
<<
milestone_table
[
:due_date
]
...
...
app/models/concerns/sortable.rb
View file @
0d236638
...
...
@@ -19,14 +19,15 @@ module Sortable
module
ClassMethods
def
order_by
(
method
)
case
method
.
to_s
when
'name_asc'
then
order_name_asc
when
'name_desc'
then
order_name_desc
when
'updated_asc'
then
order_updated_asc
when
'updated_desc'
then
order_updated_desc
when
'created_asc'
then
order_created_asc
when
'created_asc'
then
order_created_asc
when
'created_date'
then
order_created_desc
when
'created_desc'
then
order_created_desc
when
'id_desc'
then
order_id_desc
when
'id_asc'
then
order_id_asc
when
'id_asc'
then
order_id_asc
when
'id_desc'
then
order_id_desc
when
'name_asc'
then
order_name_asc
when
'name_desc'
then
order_name_desc
when
'updated_asc'
then
order_updated_asc
when
'updated_desc'
then
order_updated_desc
else
all
end
...
...
app/models/issue.rb
View file @
0d236638
...
...
@@ -116,7 +116,8 @@ class Issue < ActiveRecord::Base
def
self
.
sort
(
method
,
excluded_labels:
[])
case
method
.
to_s
when
'due_date_asc'
then
order_due_date_asc
when
'due_date'
then
order_due_date_asc
when
'due_date_asc'
then
order_due_date_asc
when
'due_date_desc'
then
order_due_date_desc
else
super
...
...
app/views/shared/_sort_dropdown.html.haml
View file @
0d236638
-
sorted_by
=
sort_options_hash
[
@sort
]
-
viewing_issues
=
controller
.
controller_name
==
'issues'
||
controller
.
action_name
==
'issues'
.dropdown.inline.prepend-left-10
%button
.dropdown-toggle
{
type:
'button'
,
data:
{
toggle:
'dropdown'
}
}
-
if
@sort
.
present?
=
sort_options_hash
[
@sort
]
-
else
=
sort_title_recently_created
%button
.dropdown-toggle
{
type:
'button'
,
data:
{
toggle:
'dropdown'
}
}
=
sorted_by
=
icon
(
'chevron-down'
)
%ul
.dropdown-menu.dropdown-menu-align-right.dropdown-menu-sort
%ul
.dropdown-menu.dropdown-menu-align-right.dropdown-menu-s
electable.dropdown-menu-s
ort
%li
=
link_to
page_filter_path
(
sort:
sort_value_priority
,
label:
true
)
do
=
sort_title_priority
=
link_to
page_filter_path
(
sort:
sort_value_label_priority
,
label:
true
)
do
=
sort_title_label_priority
=
link_to
page_filter_path
(
sort:
sort_value_recently_created
,
label:
true
)
do
=
sort_title_recently_created
=
link_to
page_filter_path
(
sort:
sort_value_oldest_created
,
label:
true
)
do
=
sort_title_oldest_created
=
link_to
page_filter_path
(
sort:
sort_value_recently_updated
,
label:
true
)
do
=
sort_title_recently_updated
=
link_to
page_filter_path
(
sort:
sort_value_oldest_updated
,
label:
true
)
do
=
sort_title_oldest_updated
=
link_to
page_filter_path
(
sort:
sort_value_milestone_soon
,
label:
true
)
do
=
sort_title_milestone_soon
=
link_to
page_filter_path
(
sort:
sort_value_milestone_later
,
label:
true
)
do
=
sort_title_milestone_later
-
if
viewing_issues
=
link_to
page_filter_path
(
sort:
sort_value_due_date_soon
,
label:
true
)
do
=
sort_title_due_date_soon
=
link_to
page_filter_path
(
sort:
sort_value_due_date_later
,
label:
true
)
do
=
sort_title_due_date_later
=
link_to
page_filter_path
(
sort:
sort_value_upvotes
,
label:
true
)
do
=
sort_title_upvotes
=
link_to
page_filter_path
(
sort:
sort_value_downvotes
,
label:
true
)
do
=
sort_title_downvotes
=
sortable_item
(
sort_title_priority
,
page_filter_path
(
sort:
sort_value_priority
,
label:
true
),
sorted_by
)
=
sortable_item
(
sort_title_created_date
,
page_filter_path
(
sort:
sort_value_created_date
,
label:
true
),
sorted_by
)
=
sortable_item
(
sort_title_recently_updated
,
page_filter_path
(
sort:
sort_value_recently_updated
,
label:
true
),
sorted_by
)
=
sortable_item
(
sort_title_milestone
,
page_filter_path
(
sort:
sort_value_milestone
,
label:
true
),
sorted_by
)
=
sortable_item
(
sort_title_due_date
,
page_filter_path
(
sort:
sort_value_due_date
,
label:
true
),
sorted_by
)
if
viewing_issues
=
sortable_item
(
sort_title_popularity
,
page_filter_path
(
sort:
sort_value_popularity
,
label:
true
),
sorted_by
)
=
sortable_item
(
sort_title_label_priority
,
page_filter_path
(
sort:
sort_value_label_priority
,
label:
true
),
sorted_by
)
changelogs/unreleased/improve_sorting_list.yml
0 → 100644
View file @
0d236638
---
title
:
Improve list of sorting options
merge_request
:
14320
author
:
Vitaliy @blackst0ne Klachkov
type
:
added
features/project/issues/issues.feature
View file @
0d236638
...
...
@@ -51,36 +51,34 @@ Feature: Project Issues
@javascript
Scenario
:
Visiting Issues after being sorted the list
Given
I visit project
"Shop"
issues page
And
I sort the list by
"
Olde
st updated"
And
I sort the list by
"
La
st updated"
And
I visit my project's home page
And
I visit project
"Shop"
issues page
Then
The list should be sorted by
"
Olde
st updated"
Then
The list should be sorted by
"
La
st updated"
@javascript
Scenario
:
Visiting Merge Requests after being sorted the list
Given
project
"Shop"
has a
"Bugfix MR"
merge request open
And
I visit project
"Shop"
issues page
And
I sort the list by
"
Olde
st updated"
And
I sort the list by
"
La
st updated"
And
I visit project
"Shop"
merge requests page
Then
The list should be sorted by
"
Olde
st updated"
Then
The list should be sorted by
"
La
st updated"
@javascript
Scenario
:
Visiting Merge Requests from a differente Project after sorting
Given
project
"Shop"
has a
"Bugfix MR"
merge request open
And
I visit project
"Shop"
merge requests page
And
I sort the list by
"
Olde
st updated"
And
I sort the list by
"
La
st updated"
And
I visit dashboard merge requests page
Then
The list should be sorted by
"
Olde
st updated"
Then
The list should be sorted by
"
La
st updated"
@javascript
Scenario
:
Sort issues by upvotes/downvotes
Given
project
"Shop"
have
"Bugfix"
open issue
And
issue
"Release 0.4"
have 2 upvotes and 1 downvote
And
issue
"Tweet control"
have 1 upvote and 2 downvotes
And
I sort the list by
"Most popular"
Then
The list should be sorted by
"Most popular"
And
I sort the list by
"Least popular"
Then
The list should be sorted by
"Least popular"
And
I sort the list by
"Popularity"
Then
The list should be sorted by
"Popularity"
# Markdown
...
...
features/project/merge_requests.feature
View file @
0d236638
...
...
@@ -91,28 +91,26 @@ Feature: Project Merge Requests
@javascript
Scenario
:
Visiting Merge Requests after being sorted the list
Given
I visit project
"Shop"
merge requests page
And
I sort the list by
"
Olde
st updated"
And
I sort the list by
"
La
st updated"
And
I visit my project's home page
And
I visit project
"Shop"
merge requests page
Then
The list should be sorted by
"
Olde
st updated"
Then
The list should be sorted by
"
La
st updated"
@javascript
Scenario
:
Visiting Merge Requests from a different Project after sorting
Given
I visit project
"Shop"
merge requests page
And
I sort the list by
"
Olde
st updated"
And
I sort the list by
"
La
st updated"
And
I visit dashboard merge requests page
Then
The list should be sorted by
"
Olde
st updated"
Then
The list should be sorted by
"
La
st updated"
@javascript
Scenario
:
Sort merge requests by upvotes
/downvotes
Scenario
:
Sort merge requests by upvotes
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
project
"Shop"
have
"Bug NS-06"
open merge request
And
merge request
"Bug NS-04"
have 2 upvotes and 1 downvote
And
merge request
"Bug NS-06"
have 1 upvote and 2 downvotes
And
I sort the list by
"Most popular"
Then
The list should be sorted by
"Most popular"
And
I sort the list by
"Least popular"
Then
The list should be sorted by
"Least popular"
And
I sort the list by
"Popularity"
Then
The list should be sorted by
"Popularity"
@javascript
Scenario
:
I
comment on a merge request diff
...
...
features/steps/project/issues/issues.rb
View file @
0d236638
...
...
@@ -223,7 +223,7 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
end
end
step
'The list should be sorted by "
Most popular
"'
do
step
'The list should be sorted by "
Popularity
"'
do
page
.
within
'.issues-list'
do
page
.
within
'li.issue:nth-child(1)'
do
expect
(
page
).
to
have_content
'Release 0.4'
...
...
features/steps/project/merge_requests.rb
View file @
0d236638
...
...
@@ -222,7 +222,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
end
end
step
'The list should be sorted by "
Most popular
"'
do
step
'The list should be sorted by "
Popularity
"'
do
page
.
within
'.mr-list'
do
page
.
within
'li.merge-request:nth-child(1)'
do
expect
(
page
).
to
have_content
'Bug NS-04'
...
...
features/steps/shared/issuable.rb
View file @
0d236638
...
...
@@ -109,10 +109,10 @@ module SharedIssuable
edit_issuable
end
step
'I sort the list by "
Olde
st updated"'
do
step
'I sort the list by "
La
st updated"'
do
find
(
'button.dropdown-toggle'
).
click
page
.
within
(
'.content ul.dropdown-menu.dropdown-menu-align-right li'
)
do
click_link
"
Olde
st updated"
click_link
"
La
st updated"
end
end
...
...
@@ -124,16 +124,16 @@ module SharedIssuable
end
end
step
'I sort the list by "
Most popular
"'
do
step
'I sort the list by "
Popularity
"'
do
find
(
'button.dropdown-toggle'
).
click
page
.
within
(
'.content ul.dropdown-menu.dropdown-menu-align-right li'
)
do
click_link
'
Most popular
'
click_link
'
Popularity
'
end
end
step
'The list should be sorted by "
Olde
st updated"'
do
expect
(
find
(
'.issues-filters'
)).
to
have_content
(
'
Olde
st updated'
)
step
'The list should be sorted by "
La
st updated"'
do
expect
(
find
(
'.issues-filters'
)).
to
have_content
(
'
La
st updated'
)
end
step
'I click link "Next" in the sidebar'
do
...
...
spec/features/dashboard/issues_filter_spec.rb
View file @
0d236638
...
...
@@ -90,17 +90,17 @@ feature 'Dashboard Issues filtering', :js do
context
'sorting'
do
it
'shows sorted issues'
do
sorting_by
(
'
Oldest updated
'
)
sorting_by
(
'
Created date
'
)
visit_issues
expect
(
find
(
'.issues-filters'
)).
to
have_content
(
'
Oldest updated
'
)
expect
(
find
(
'.issues-filters'
)).
to
have_content
(
'
Created date
'
)
end
it
'keeps sorting issues after visiting Projects Issues page'
do
sorting_by
(
'
Oldest updated
'
)
sorting_by
(
'
Created date
'
)
visit
project_issues_path
(
project
)
expect
(
find
(
'.issues-filters'
)).
to
have_content
(
'
Oldest updated
'
)
expect
(
find
(
'.issues-filters'
)).
to
have_content
(
'
Created date
'
)
end
end
...
...
spec/features/dashboard/merge_requests_spec.rb
View file @
0d236638
...
...
@@ -112,19 +112,19 @@ feature 'Dashboard Merge Requests' do
end
it
'shows sorted merge requests'
do
sorting_by
(
'
Oldest updated
'
)
sorting_by
(
'
Created date
'
)
visit
merge_requests_dashboard_path
(
assignee_id:
current_user
.
id
)
expect
(
find
(
'.issues-filters'
)).
to
have_content
(
'
Oldest updated
'
)
expect
(
find
(
'.issues-filters'
)).
to
have_content
(
'
Created date
'
)
end
it
'keeps sorting merge requests after visiting Projects MR page'
do
sorting_by
(
'
Oldest updated
'
)
sorting_by
(
'
Created date
'
)
visit
project_merge_requests_path
(
project
)
expect
(
find
(
'.issues-filters'
)).
to
have_content
(
'
Oldest updated
'
)
expect
(
find
(
'.issues-filters'
)).
to
have_content
(
'
Created date
'
)
end
end
end
spec/features/issuables/default_sort_order_spec.rb
View file @
0d236638
...
...
@@ -40,10 +40,10 @@ describe 'Projects > Issuables > Default sort order' do
context
'in the "merge requests / open" tab'
,
js:
true
do
let
(
:issuable_type
)
{
:merge_request
}
it
'is "
last created
"'
do
it
'is "
created date
"'
do
visit_merge_requests_with_state
(
project
,
'open'
)
expect
(
selected_sort_order
).
to
eq
(
'
last created
'
)
expect
(
selected_sort_order
).
to
eq
(
'
created date
'
)
expect
(
first_merge_request
).
to
include
(
last_created_issuable
.
title
)
expect
(
last_merge_request
).
to
include
(
first_created_issuable
.
title
)
end
...
...
@@ -76,10 +76,10 @@ describe 'Projects > Issuables > Default sort order' do
context
'in the "merge requests / all" tab'
,
js:
true
do
let
(
:issuable_type
)
{
:merge_request
}
it
'is "
last created
"'
do
it
'is "
created date
"'
do
visit_merge_requests_with_state
(
project
,
'all'
)
expect
(
find
(
'.issues-other-filters'
)).
to
have_content
(
'
Last created
'
)
expect
(
find
(
'.issues-other-filters'
)).
to
have_content
(
'
Created date
'
)
expect
(
first_merge_request
).
to
include
(
last_created_issuable
.
title
)
expect
(
last_merge_request
).
to
include
(
first_created_issuable
.
title
)
end
...
...
@@ -105,10 +105,10 @@ describe 'Projects > Issuables > Default sort order' do
context
'in the "issues" tab'
,
js:
true
do
let
(
:issuable_type
)
{
:issue
}
it
'is "
last created
"'
do
it
'is "
created date
"'
do
visit_issues
project
expect
(
find
(
'.issues-other-filters'
)).
to
have_content
(
'
Last created
'
)
expect
(
find
(
'.issues-other-filters'
)).
to
have_content
(
'
Created date
'
)
expect
(
first_issue
).
to
include
(
last_created_issuable
.
title
)
expect
(
last_issue
).
to
include
(
first_created_issuable
.
title
)
end
...
...
@@ -117,10 +117,10 @@ describe 'Projects > Issuables > Default sort order' do
context
'in the "issues / open" tab'
,
js:
true
do
let
(
:issuable_type
)
{
:issue
}
it
'is "
last created
"'
do
it
'is "
created date
"'
do
visit_issues_with_state
(
project
,
'open'
)
expect
(
find
(
'.issues-other-filters'
)).
to
have_content
(
'
Last created
'
)
expect
(
find
(
'.issues-other-filters'
)).
to
have_content
(
'
Created date
'
)
expect
(
first_issue
).
to
include
(
last_created_issuable
.
title
)
expect
(
last_issue
).
to
include
(
first_created_issuable
.
title
)
end
...
...
@@ -141,10 +141,10 @@ describe 'Projects > Issuables > Default sort order' do
context
'in the "issues / all" tab'
,
js:
true
do
let
(
:issuable_type
)
{
:issue
}
it
'is "
last created
"'
do
it
'is "
created date
"'
do
visit_issues_with_state
(
project
,
'all'
)
expect
(
find
(
'.issues-other-filters'
)).
to
have_content
(
'
Last created
'
)
expect
(
find
(
'.issues-other-filters'
)).
to
have_content
(
'
Created date
'
)
expect
(
first_issue
).
to
include
(
last_created_issuable
.
title
)
expect
(
last_issue
).
to
include
(
first_created_issuable
.
title
)
end
...
...
@@ -157,26 +157,12 @@ describe 'Projects > Issuables > Default sort order' do
visit_issues
(
project
,
sort:
'id_desc'
)
end
it
'shows the sort order as
last created
'
do
expect
(
find
(
'.issues-other-filters'
)).
to
have_content
(
'
Last created
'
)
it
'shows the sort order as
created date
'
do
expect
(
find
(
'.issues-other-filters'
)).
to
have_content
(
'
Created date
'
)
expect
(
first_issue
).
to
include
(
last_created_issuable
.
title
)
expect
(
last_issue
).
to
include
(
first_created_issuable
.
title
)
end
end
context
'when the sort in the URL is id_asc'
do
let
(
:issuable_type
)
{
:issue
}
before
do
visit_issues
(
project
,
sort:
'id_asc'
)
end
it
'shows the sort order as oldest created'
do
expect
(
find
(
'.issues-other-filters'
)).
to
have_content
(
'Oldest created'
)
expect
(
first_issue
).
to
include
(
first_created_issuable
.
title
)
expect
(
last_issue
).
to
include
(
last_created_issuable
.
title
)
end
end
end
def
selected_sort_order
...
...
spec/features/issues/filtered_search/filter_issues_spec.rb
View file @
0d236638
...
...
@@ -405,20 +405,18 @@ describe 'Filter issues', js: true do
end
context
'sorting'
do
it
'sorts by
oldest updated
'
do
create
(
:issue
,
it
'sorts by
created date
'
do
new_issue
=
create
(
:issue
,
title:
'3 days ago'
,
project:
project
,
author:
user
,
created_at:
3
.
days
.
ago
,
updated_at:
3
.
days
.
ago
)
created_at:
3
.
days
.
ago
)
old_issue
=
create
(
:issue
,
create
(
:issue
,
title:
'5 days ago'
,
project:
project
,
author:
user
,
created_at:
5
.
days
.
ago
,
updated_at:
5
.
days
.
ago
)
created_at:
5
.
days
.
ago
)
input_filtered_search
(
'days ago'
)
...
...
@@ -427,10 +425,10 @@ describe 'Filter issues', js: true do
sort_toggle
=
find
(
'.filtered-search-wrapper .dropdown-toggle'
)
sort_toggle
.
click
find
(
'.filtered-search-wrapper .dropdown-menu li a'
,
text:
'
Oldest updated
'
).
click
find
(
'.filtered-search-wrapper .dropdown-menu li a'
,
text:
'
Created date
'
).
click
wait_for_requests
expect
(
find
(
'.issues-list .issue:first-of-type .issue-title-text a'
)).
to
have_content
(
old
_issue
.
title
)
expect
(
find
(
'.issues-list .issue:first-of-type .issue-title-text a'
)).
to
have_content
(
new
_issue
.
title
)
end
end
end
...
...
spec/features/issues_spec.rb
View file @
0d236638
...
...
@@ -190,19 +190,12 @@ describe 'Issues' do
let
(
:later_due_milestone
)
{
create
(
:milestone
,
due_date:
'2013-12-12'
)
}
it
'sorts by newest'
do
visit
project_issues_path
(
project
,
sort:
sort_value_
recently_created
)
visit
project_issues_path
(
project
,
sort:
sort_value_
created_date
)
expect
(
first_issue
).
to
include
(
'foo'
)
expect
(
last_issue
).
to
include
(
'baz'
)
end
it
'sorts by oldest'
do
visit
project_issues_path
(
project
,
sort:
sort_value_oldest_created
)
expect
(
first_issue
).
to
include
(
'baz'
)
expect
(
last_issue
).
to
include
(
'foo'
)
end
it
'sorts by most recently updated'
do
baz
.
updated_at
=
Time
.
now
+
100
baz
.
save
...
...
@@ -211,36 +204,22 @@ describe 'Issues' do
expect
(
first_issue
).
to
include
(
'baz'
)
end
it
'sorts by least recently updated'
do
baz
.
updated_at
=
Time
.
now
-
100
baz
.
save
visit
project_issues_path
(
project
,
sort:
sort_value_oldest_updated
)
expect
(
first_issue
).
to
include
(
'baz'
)
end
describe
'sorting by due date'
do
before
do
foo
.
update
(
due_date:
1
.
day
.
from_now
)
bar
.
update
(
due_date:
6
.
days
.
from_now
)
end
it
'sorts by
recently
due date'
do
visit
project_issues_path
(
project
,
sort:
sort_value_due_date
_soon
)
it
'sorts by due date'
do
visit
project_issues_path
(
project
,
sort:
sort_value_due_date
)
expect
(
first_issue
).
to
include
(
'foo'
)
end
it
'sorts by least recently due date'
do
visit
project_issues_path
(
project
,
sort:
sort_value_due_date_later
)
expect
(
first_issue
).
to
include
(
'bar'
)
end
it
'sorts by least recently due date by excluding nil due dates'
do
it
'sorts by due date by excluding nil due dates'
do
bar
.
update
(
due_date:
nil
)
visit
project_issues_path
(
project
,
sort:
sort_value_due_date
_later
)
visit
project_issues_path
(
project
,
sort:
sort_value_due_date
)
expect
(
first_issue
).
to
include
(
'foo'
)
end
...
...
@@ -339,19 +318,12 @@ describe 'Issues' do
bar
.
save
end
it
'sorts by
recently due
milestone'
do
visit
project_issues_path
(
project
,
sort:
sort_value_milestone
_soon
)
it
'sorts by milestone'
do
visit
project_issues_path
(
project
,
sort:
sort_value_milestone
)
expect
(
first_issue
).
to
include
(
'foo'
)
expect
(
last_issue
).
to
include
(
'baz'
)
end
it
'sorts by least recently due milestone'
do
visit
project_issues_path
(
project
,
sort:
sort_value_milestone_later
)
expect
(
first_issue
).
to
include
(
'bar'
)
expect
(
last_issue
).
to
include
(
'baz'
)
end
end
describe
'combine filter and sort'
do
...
...
@@ -365,13 +337,11 @@ describe 'Issues' do
end
it
'sorts with a filter applied'
do
visit
project_issues_path
(
project
,
sort:
sort_value_oldest_created
,
assignee_id:
user2
.
id
)
visit
project_issues_path
(
project
,
sort:
sort_value_created_date
,
assignee_id:
user2
.
id
)
expect
(
first_issue
).
to
include
(
'
bar
'
)
expect
(
last_issue
).
to
include
(
'
foo
'
)
expect
(
page
).
not_to
have_content
'baz'
expect
(
first_issue
).
to
include
(
'
foo
'
)
expect
(
last_issue
).
to
include
(
'
bar
'
)
expect
(
page
).
not_to
have_content
(
'baz'
)
end
end
end
...
...
spec/features/merge_requests/filter_merge_requests_spec.rb
View file @
0d236638
...
...
@@ -277,9 +277,9 @@ describe 'Filter merge requests' do
expect_mr_list_count
(
2
)
click_button
'
Last created
'
click_button
'
Created date
'
page
.
within
'.dropdown-menu-sort'
do
click_link
'
Oldest created
'
click_link
'
Priority
'
end
wait_for_requests
...
...
spec/features/merge_requests/user_lists_merge_requests_spec.rb
View file @
0d236638
...
...
@@ -52,21 +52,13 @@ describe 'Projects > Merge requests > User lists merge requests' do
end
it
'sorts by newest'
do
visit_merge_requests
(
project
,
sort:
sort_value_
recently_created
)
visit_merge_requests
(
project
,
sort:
sort_value_
created_date
)
expect
(
first_merge_request
).
to
include
(
'fix'
)
expect
(
last_merge_request
).
to
include
(
'merge-test'
)
expect
(
count_merge_requests
).
to
eq
(
3
)
end
it
'sorts by oldest'
do
visit_merge_requests
(
project
,
sort:
sort_value_oldest_created
)
expect
(
first_merge_request
).
to
include
(
'merge-test'
)
expect
(
last_merge_request
).
to
include
(
'fix'
)
expect
(
count_merge_requests
).
to
eq
(
3
)
end
it
'sorts by last updated'
do
visit_merge_requests
(
project
,
sort:
sort_value_recently_updated
)
...
...
@@ -74,33 +66,19 @@ describe 'Projects > Merge requests > User lists merge requests' do
expect
(
count_merge_requests
).
to
eq
(
3
)
end
it
'sorts by oldest updated'
do
visit_merge_requests
(
project
,
sort:
sort_value_oldest_updated
)
expect
(
first_merge_request
).
to
include
(
'markdown'
)
expect
(
count_merge_requests
).
to
eq
(
3
)
end
it
'sorts by milestone due soon'
do
visit_merge_requests
(
project
,
sort:
sort_value_milestone_soon
)
it
'sorts by milestone'
do
visit_merge_requests
(
project
,
sort:
sort_value_milestone
)
expect
(
first_merge_request
).
to
include
(
'fix'
)
expect
(
count_merge_requests
).
to
eq
(
3
)
end
it
'sorts by milestone due later'
do
visit_merge_requests
(
project
,
sort:
sort_value_milestone_later
)
expect
(
first_merge_request
).
to
include
(
'markdown'
)
expect
(
count_merge_requests
).
to
eq
(
3
)
end
it
'filters on one label and sorts by due soon'
do
it
'filters on one label and sorts by due date'
do
label
=
create
(
:label
,
project:
project
)
create
(
:label_link
,
label:
label
,
target:
@fix
)
visit_merge_requests
(
project
,
label_name:
[
label
.
name
],
sort:
sort_value_due_date
_soon
)
sort:
sort_value_due_date
)
expect
(
first_merge_request
).
to
include
(
'fix'
)
expect
(
count_merge_requests
).
to
eq
(
1
)
...
...
@@ -115,9 +93,9 @@ describe 'Projects > Merge requests > User lists merge requests' do
create
(
:label_link
,
label:
label2
,
target:
@fix
)
end
it
'sorts by due
soon
'
do
it
'sorts by due
date
'
do
visit_merge_requests
(
project
,
label_name:
[
label
.
name
,
label2
.
name
],
sort:
sort_value_due_date
_soon
)
sort:
sort_value_due_date
)
expect
(
first_merge_request
).
to
include
(
'fix'
)
expect
(
count_merge_requests
).
to
eq
(
1
)
...
...
@@ -127,7 +105,7 @@ describe 'Projects > Merge requests > User lists merge requests' do
it
'sorts by due soon'
do
visit_merge_requests
(
project
,
label_name:
[
label
.
name
,
label2
.
name
],
assignee_id:
user
.
id
,
sort:
sort_value_due_date
_soon
)
sort:
sort_value_due_date
)
expect
(
first_merge_request
).
to
include
(
'fix'
)
expect
(
count_merge_requests
).
to
eq
(
1
)
...
...
@@ -137,7 +115,7 @@ describe 'Projects > Merge requests > User lists merge requests' do
visit
project_merge_requests_path
(
project
,
label_name:
[
label
.
name
,
label2
.
name
],
assignee_id:
user
.
id
,
sort:
sort_value_milestone
_soon
)
sort:
sort_value_milestone
)
expect
(
first_merge_request
).
to
include
(
'fix'
)
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