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
iv
gitlab-ce
Commits
7022357c
Commit
7022357c
authored
Jun 16, 2016
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sorting dropdown to tag page
parent
d9812bae
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
4 deletions
+78
-4
CHANGELOG
CHANGELOG
+1
-0
app/controllers/projects/tags_controller.rb
app/controllers/projects/tags_controller.rb
+4
-2
app/models/repository.rb
app/models/repository.rb
+19
-0
app/views/projects/tags/index.html.haml
app/views/projects/tags/index.html.haml
+13
-2
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+41
-0
No files found.
CHANGELOG
View file @
7022357c
...
...
@@ -84,6 +84,7 @@ v 8.9.0 (unreleased)
- Show categorised search queries in the search autocomplete
- RepositoryCheck::SingleRepositoryWorker public and private methods are now instrumented
- Improve issuables APIs performance when accessing notes !4471
- Add sorting dropdown to tags page !4423
- External links now open in a new tab
- Prevent default actions of disabled buttons and links
- Markdown editor now correctly resets the input value on edit cancellation !4175
...
...
app/controllers/projects/tags_controller.rb
View file @
7022357c
...
...
@@ -6,8 +6,10 @@ class Projects::TagsController < Projects::ApplicationController
before_action
:authorize_admin_project!
,
only:
[
:destroy
]
def
index
sorted
=
VersionSorter
.
rsort
(
@repository
.
tag_names
)
@tags
=
Kaminari
.
paginate_array
(
sorted
).
page
(
params
[
:page
])
@sort
=
params
[
:sort
]
||
'name'
@tags
=
@repository
.
tags_sorted_by
(
@sort
)
@tags
=
Kaminari
.
paginate_array
(
@tags
).
page
(
params
[
:page
])
@releases
=
project
.
releases
.
where
(
tag:
@tags
)
end
...
...
app/models/repository.rb
View file @
7022357c
...
...
@@ -598,6 +598,21 @@ class Repository
end
end
def
tags_sorted_by
(
value
)
case
value
when
'name'
# Would be better to use `sort_by` but `version_sorter` only exposes
# `sort` and `rsort`
VersionSorter
.
rsort
(
tag_names
).
map
{
|
tag_name
|
find_tag
(
tag_name
)
}
when
'updated_desc'
tags_sorted_by_committed_date
.
reverse
when
'updated_asc'
tags_sorted_by_committed_date
else
tags
end
end
def
contributors
commits
=
self
.
commits
(
nil
,
limit:
2000
,
offset:
0
,
skip_merges:
true
)
...
...
@@ -995,4 +1010,8 @@ class Repository
def
file_on_head
(
regex
)
tree
(
:head
).
blobs
.
find
{
|
file
|
file
.
name
=~
regex
}
end
def
tags_sorted_by_committed_date
tags
.
sort_by
{
|
tag
|
commit
(
tag
.
target
).
committed_date
}
end
end
app/views/projects/tags/index.html.haml
View file @
7022357c
...
...
@@ -11,12 +11,23 @@
.nav-controls
=
link_to
new_namespace_project_tag_path
(
@project
.
namespace
,
@project
),
class:
'btn btn-create new-tag-btn'
do
New tag
.dropdown.inline
%button
.dropdown-toggle.btn
{
type:
'button'
,
data:
{
toggle:
'dropdown'
}
}
%span
.light
=
@sort
.
humanize
%b
.caret
%ul
.dropdown-menu.dropdown-menu-align-right
%li
=
link_to
namespace_project_tags_path
(
sort:
nil
)
do
Name
=
link_to
namespace_project_tags_path
(
sort:
sort_value_recently_updated
)
do
=
sort_title_recently_updated
=
link_to
namespace_project_tags_path
(
sort:
sort_value_oldest_updated
)
do
=
sort_title_oldest_updated
.tags
-
unless
@tags
.
empty?
%ul
.content-list
-
@tags
.
each
do
|
tag
|
=
render
'tag'
,
tag:
@repository
.
find_tag
(
tag
)
=
render
partial:
'tag'
,
collection:
@tags
=
paginate
@tags
,
theme:
'gitlab'
...
...
spec/models/repository_spec.rb
View file @
7022357c
...
...
@@ -31,6 +31,47 @@ describe Repository, models: true do
it
{
is_expected
.
not_to
include
(
'v1.0.0'
)
}
end
describe
'tags_sorted_by'
do
context
'name'
do
subject
{
repository
.
tags_sorted_by
(
'name'
).
map
(
&
:name
)
}
it
{
is_expected
.
to
eq
([
'v1.1.0'
,
'v1.0.0'
])
}
end
context
'updated'
do
let
(
:tag_a
)
{
repository
.
find_tag
(
'v1.0.0'
)
}
let
(
:tag_b
)
{
repository
.
find_tag
(
'v1.1.0'
)
}
context
'desc'
do
subject
{
repository
.
tags_sorted_by
(
'updated_desc'
).
map
(
&
:name
)
}
before
do
double_first
=
double
(
committed_date:
Time
.
now
)
double_last
=
double
(
committed_date:
Time
.
now
-
1
.
second
)
allow
(
repository
).
to
receive
(
:commit
).
with
(
tag_a
.
target
).
and_return
(
double_first
)
allow
(
repository
).
to
receive
(
:commit
).
with
(
tag_b
.
target
).
and_return
(
double_last
)
end
it
{
is_expected
.
to
eq
([
'v1.0.0'
,
'v1.1.0'
])
}
end
context
'asc'
do
subject
{
repository
.
tags_sorted_by
(
'updated_asc'
).
map
(
&
:name
)
}
before
do
double_first
=
double
(
committed_date:
Time
.
now
-
1
.
second
)
double_last
=
double
(
committed_date:
Time
.
now
)
allow
(
repository
).
to
receive
(
:commit
).
with
(
tag_a
.
target
).
and_return
(
double_last
)
allow
(
repository
).
to
receive
(
:commit
).
with
(
tag_b
.
target
).
and_return
(
double_first
)
end
it
{
is_expected
.
to
eq
([
'v1.1.0'
,
'v1.0.0'
])
}
end
end
end
describe
:last_commit_for_path
do
subject
{
repository
.
last_commit_for_path
(
sample_commit
.
id
,
'.gitignore'
).
id
}
...
...
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