Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
1f555edc0960
Commit
1f555edc
authored
Aug 11, 2017
by
Mehdi Lahmam
Browse files
Add an option to list only archived projects
Closes #35994
parent
d4b3f2fbf9c8
Changes
9
Hide whitespace changes
Inline
Side-by-side
app/finders/admin/projects_finder.rb
View file @
1f555edc
...
...
@@ -43,7 +43,13 @@
end
def
by_archived
(
items
)
items
.
non_archived
unless
params
[
:archived
].
present?
if
params
[
:archived
]
==
'only'
items
.
archived
elsif
params
[
:archived
].
blank?
items
.
non_archived
else
items
end
end
def
by_personal
(
items
)
...
...
app/finders/projects_finder.rb
View file @
1f555edc
...
...
@@ -125,9 +125,18 @@
end
def
by_archived
(
projects
)
# Back-compatibility with the places where `params[:archived]` can be set explicitly to `false`
params
[
:non_archived
]
=
!
Gitlab
::
Utils
.
to_boolean
(
params
[
:archived
])
if
params
.
key?
(
:archived
)
params
[
:non_archived
]
?
projects
.
non_archived
:
projects
if
params
[
:non_archived
]
projects
.
non_archived
elsif
params
.
key?
(
:archived
)
# Back-compatibility with the places where `params[:archived]` can be set explicitly to `false`
if
params
[
:archived
]
==
'only'
projects
.
archived
elsif
Gitlab
::
Utils
.
to_boolean
(
params
[
:archived
])
projects
else
projects
.
non_archived
end
else
projects
end
end
end
app/models/project.rb
View file @
1f555edc
...
...
@@ -247,6 +247,7 @@
scope
:joined
,
->
(
user
)
{
where
(
'namespace_id != ?'
,
user
.
namespace_id
)
}
scope
:starred_by
,
->
(
user
)
{
joins
(
:users_star_projects
).
where
(
'users_star_projects.user_id'
:
user
.
id
)
}
scope
:visible_to_user
,
->
(
user
)
{
where
(
id:
user
.
authorized_projects
.
select
(
:id
).
reorder
(
nil
))
}
scope
:archived
,
->
{
where
(
archived:
true
)
}
scope
:non_archived
,
->
{
where
(
archived:
false
)
}
scope
:for_milestones
,
->
(
ids
)
{
joins
(
:milestones
).
where
(
'milestones.id'
=>
ids
).
distinct
}
scope
:with_push
,
->
{
joins
(
:events
).
where
(
'events.action = ?'
,
Event
::
PUSHED
)
}
...
...
app/views/shared/projects/_dropdown.html.haml
View file @
1f555edc
...
...
@@ -15,5 +15,5 @@
=
link_to
filter_projects_path
(
archived:
nil
),
class:
(
"is-active"
unless
params
[
:archived
].
present?
)
do
Hide archived projects
%li
=
link_to
filter_projects_path
(
archived:
true
),
class:
(
"is-active"
if
params
[
:archived
]
.
present?
)
do
=
link_to
filter_projects_path
(
archived:
true
),
class:
(
"is-active"
if
Gitlab
::
Utils
.
to_boolean
(
params
[
:archived
]
)
)
do
Show archived projects
...
...
@@ -19,4 +19,7 @@
Show archived projects
%li
=
link_to
filter_projects_path
(
archived:
'only'
),
class:
(
"is-active"
if
params
[
:archived
]
==
'only'
)
do
Show archived projects only
-
if
current_user
%li
.divider
%li
...
...
changelogs/unreleased/35994-archived-projects-only.yml
0 → 100644
View file @
1f555edc
---
title
:
Add an option to list only archived projects
merge_request
:
13492
author
:
Mehdi Lahmam (@mehlah)
type
:
added
spec/features/admin/admin_projects_spec.rb
View file @
1f555edc
...
...
@@ -36,6 +36,14 @@
expect
(
page
).
to
have_content
(
archived_project
.
name
)
expect
(
page
).
to
have_xpath
(
"//span[@class='label label-warning']"
,
text:
'archived'
)
end
it
'renders only archived projects'
,
js:
true
do
find
(
:css
,
'#sort-projects-dropdown'
).
click
click_link
'Show archived projects only'
expect
(
page
).
to
have_content
(
archived_project
.
name
)
expect
(
page
).
not_to
have_content
(
project
.
name
)
end
end
describe
"GET /admin/projects/:namespace_id/:id"
do
...
...
spec/features/dashboard/archived_projects_spec.rb
View file @
1f555edc
...
...
@@ -26,6 +26,13 @@
expect
(
page
).
to
have_link
(
archived_project
.
name
)
end
it
'renders only archived projects'
do
click_link
'Show archived projects only'
expect
(
page
).
to
have_content
(
archived_project
.
name
)
expect
(
page
).
not_to
have_content
(
project
.
name
)
end
it
'searchs archived projects'
,
:js
do
click_button
'Last updated'
click_link
'Show archived projects'
...
...
spec/finders/admin/projects_finder_spec.rb
View file @
1f555edc
...
...
@@ -118,6 +118,12 @@
it
{
is_expected
.
to
match_array
([
archived_project
,
shared_project
,
public_project
,
internal_project
,
private_project
])
}
end
context
'archived=only'
do
let
(
:params
)
{
{
archived:
'only'
}
}
it
{
is_expected
.
to
eq
([
archived_project
])
}
end
end
context
'filter by personal'
do
...
...
spec/finders/projects_finder_spec.rb
View file @
1f555edc
...
...
@@ -123,6 +123,12 @@
it
{
is_expected
.
to
match_array
([
public_project
,
internal_project
,
archived_project
])
}
end
describe
'filter by archived only'
do
let
(
:params
)
{
{
archived:
'only'
}
}
it
{
is_expected
.
to
eq
([
archived_project
])
}
end
describe
'filter by archived for backward compatibility'
do
let
(
:params
)
{
{
archived:
false
}
}
...
...
Write
Preview
Supports
Markdown
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