Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
55f4ddad
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
55f4ddad
编写于
8月 11, 2017
作者:
M
Mehdi Lahmam
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add an option to list only archived projects
Closes #35994
上级
d184f27e
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
57 addition
and
6 deletion
+57
-6
app/finders/admin/projects_finder.rb
app/finders/admin/projects_finder.rb
+7
-1
app/finders/projects_finder.rb
app/finders/projects_finder.rb
+13
-4
app/models/project.rb
app/models/project.rb
+1
-0
app/views/shared/projects/_dropdown.html.haml
app/views/shared/projects/_dropdown.html.haml
+4
-1
changelogs/unreleased/35994-archived-projects-only.yml
changelogs/unreleased/35994-archived-projects-only.yml
+5
-0
spec/features/admin/admin_projects_spec.rb
spec/features/admin/admin_projects_spec.rb
+8
-0
spec/features/dashboard/archived_projects_spec.rb
spec/features/dashboard/archived_projects_spec.rb
+7
-0
spec/finders/admin/projects_finder_spec.rb
spec/finders/admin/projects_finder_spec.rb
+6
-0
spec/finders/projects_finder_spec.rb
spec/finders/projects_finder_spec.rb
+6
-0
未找到文件。
app/finders/admin/projects_finder.rb
浏览文件 @
55f4ddad
...
@@ -43,7 +43,13 @@ class Admin::ProjectsFinder
...
@@ -43,7 +43,13 @@ class Admin::ProjectsFinder
end
end
def
by_archived
(
items
)
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
end
def
by_personal
(
items
)
def
by_personal
(
items
)
...
...
app/finders/projects_finder.rb
浏览文件 @
55f4ddad
...
@@ -125,9 +125,18 @@ class ProjectsFinder < UnionFinder
...
@@ -125,9 +125,18 @@ class ProjectsFinder < UnionFinder
end
end
def
by_archived
(
projects
)
def
by_archived
(
projects
)
# Back-compatibility with the places where `params[:archived]` can be set explicitly to `false`
if
params
[
:non_archived
]
params
[
:non_archived
]
=
!
Gitlab
::
Utils
.
to_boolean
(
params
[
:archived
])
if
params
.
key?
(
:archived
)
projects
.
non_archived
elsif
params
.
key?
(
:archived
)
# Back-compatibility with the places where `params[:archived]` can be set explicitly to `false`
params
[
:non_archived
]
?
projects
.
non_archived
:
projects
if
params
[
:archived
]
==
'only'
projects
.
archived
elsif
Gitlab
::
Utils
.
to_boolean
(
params
[
:archived
])
projects
else
projects
.
non_archived
end
else
projects
end
end
end
end
end
app/models/project.rb
浏览文件 @
55f4ddad
...
@@ -247,6 +247,7 @@ class Project < ActiveRecord::Base
...
@@ -247,6 +247,7 @@ class Project < ActiveRecord::Base
scope
:joined
,
->
(
user
)
{
where
(
'namespace_id != ?'
,
user
.
namespace_id
)
}
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
: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
: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
:non_archived
,
->
{
where
(
archived:
false
)
}
scope
:for_milestones
,
->
(
ids
)
{
joins
(
:milestones
).
where
(
'milestones.id'
=>
ids
).
distinct
}
scope
:for_milestones
,
->
(
ids
)
{
joins
(
:milestones
).
where
(
'milestones.id'
=>
ids
).
distinct
}
scope
:with_push
,
->
{
joins
(
:events
).
where
(
'events.action = ?'
,
Event
::
PUSHED
)
}
scope
:with_push
,
->
{
joins
(
:events
).
where
(
'events.action = ?'
,
Event
::
PUSHED
)
}
...
...
app/views/shared/projects/_dropdown.html.haml
浏览文件 @
55f4ddad
...
@@ -15,8 +15,11 @@
...
@@ -15,8 +15,11 @@
=
link_to
filter_projects_path
(
archived:
nil
),
class:
(
"is-active"
unless
params
[
:archived
].
present?
)
do
=
link_to
filter_projects_path
(
archived:
nil
),
class:
(
"is-active"
unless
params
[
:archived
].
present?
)
do
Hide archived projects
Hide archived projects
%li
%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
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
-
if
current_user
%li
.divider
%li
.divider
%li
%li
...
...
changelogs/unreleased/35994-archived-projects-only.yml
0 → 100644
浏览文件 @
55f4ddad
---
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
浏览文件 @
55f4ddad
...
@@ -36,6 +36,14 @@ describe "Admin::Projects" do
...
@@ -36,6 +36,14 @@ describe "Admin::Projects" do
expect
(
page
).
to
have_content
(
archived_project
.
name
)
expect
(
page
).
to
have_content
(
archived_project
.
name
)
expect
(
page
).
to
have_xpath
(
"//span[@class='label label-warning']"
,
text:
'archived'
)
expect
(
page
).
to
have_xpath
(
"//span[@class='label label-warning']"
,
text:
'archived'
)
end
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
end
describe
"GET /admin/projects/:namespace_id/:id"
do
describe
"GET /admin/projects/:namespace_id/:id"
do
...
...
spec/features/dashboard/archived_projects_spec.rb
浏览文件 @
55f4ddad
...
@@ -26,6 +26,13 @@ RSpec.describe 'Dashboard Archived Project' do
...
@@ -26,6 +26,13 @@ RSpec.describe 'Dashboard Archived Project' do
expect
(
page
).
to
have_link
(
archived_project
.
name
)
expect
(
page
).
to
have_link
(
archived_project
.
name
)
end
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
it
'searchs archived projects'
,
:js
do
click_button
'Last updated'
click_button
'Last updated'
click_link
'Show archived projects'
click_link
'Show archived projects'
...
...
spec/finders/admin/projects_finder_spec.rb
浏览文件 @
55f4ddad
...
@@ -118,6 +118,12 @@ describe Admin::ProjectsFinder do
...
@@ -118,6 +118,12 @@ describe Admin::ProjectsFinder do
it
{
is_expected
.
to
match_array
([
archived_project
,
shared_project
,
public_project
,
internal_project
,
private_project
])
}
it
{
is_expected
.
to
match_array
([
archived_project
,
shared_project
,
public_project
,
internal_project
,
private_project
])
}
end
end
context
'archived=only'
do
let
(
:params
)
{
{
archived:
'only'
}
}
it
{
is_expected
.
to
eq
([
archived_project
])
}
end
end
end
context
'filter by personal'
do
context
'filter by personal'
do
...
...
spec/finders/projects_finder_spec.rb
浏览文件 @
55f4ddad
...
@@ -123,6 +123,12 @@ describe ProjectsFinder do
...
@@ -123,6 +123,12 @@ describe ProjectsFinder do
it
{
is_expected
.
to
match_array
([
public_project
,
internal_project
,
archived_project
])
}
it
{
is_expected
.
to
match_array
([
public_project
,
internal_project
,
archived_project
])
}
end
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
describe
'filter by archived for backward compatibility'
do
let
(
:params
)
{
{
archived:
false
}
}
let
(
:params
)
{
{
archived:
false
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录