Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
2ed08871
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,发现更多精彩内容 >>
提交
2ed08871
编写于
12月 29, 2013
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/dash_projects_sort' of /home/git/repositories/gitlab/gitlabhq
上级
231b91d0
611c5f1d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
65 addition
and
21 deletion
+65
-21
app/controllers/dashboard_controller.rb
app/controllers/dashboard_controller.rb
+4
-4
app/controllers/public/projects_controller.rb
app/controllers/public/projects_controller.rb
+1
-8
app/helpers/dashboard_helper.rb
app/helpers/dashboard_helper.rb
+14
-0
app/helpers/tab_helper.rb
app/helpers/tab_helper.rb
+6
-1
app/models/project.rb
app/models/project.rb
+10
-0
app/views/dashboard/projects.html.haml
app/views/dashboard/projects.html.haml
+30
-8
未找到文件。
app/controllers/dashboard_controller.rb
浏览文件 @
2ed08871
...
...
@@ -41,13 +41,13 @@ class DashboardController < ApplicationController
@projects
=
@projects
.
where
(
namespace_id:
Group
.
find_by_name
(
params
[
:group
]))
if
params
[
:group
].
present?
@projects
=
@projects
.
where
(
visibility_level:
params
[
:visibility_level
])
if
params
[
:visibility_level
].
present?
@projects
=
@projects
.
includes
(
:namespace
).
sorted_by_activity
@projects
=
@projects
.
includes
(
:namespace
)
@projects
=
@projects
.
tagged_with
(
params
[
:label
])
if
params
[
:label
].
present?
@projects
=
@projects
.
sort
(
@sort
=
params
[
:sort
])
@projects
=
@projects
.
page
(
params
[
:page
]).
per
(
30
)
@labels
=
current_user
.
authorized_projects
.
tags_on
(
:labels
)
@groups
=
current_user
.
authorized_groups
@projects
=
@projects
.
tagged_with
(
params
[
:label
])
if
params
[
:label
].
present?
@projects
=
@projects
.
page
(
params
[
:page
]).
per
(
30
)
end
def
merge_requests
...
...
app/controllers/public/projects_controller.rb
浏览文件 @
2ed08871
...
...
@@ -8,14 +8,7 @@ class Public::ProjectsController < ApplicationController
def
index
@projects
=
Project
.
public_or_internal_only
(
current_user
)
@projects
=
@projects
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
@sort
=
params
[
:sort
]
@projects
=
case
@sort
when
'newest'
then
@projects
.
order
(
'created_at DESC'
)
when
'oldest'
then
@projects
.
order
(
'created_at ASC'
)
when
'recently_updated'
then
@projects
.
order
(
'updated_at DESC'
)
when
'last_updated'
then
@projects
.
order
(
'updated_at ASC'
)
else
@projects
.
order
(
"namespaces.path, projects.name ASC"
)
end
@projects
=
@projects
.
sort
(
@sort
=
params
[
:sort
])
@projects
=
@projects
.
includes
(
:namespace
).
page
(
params
[
:page
]).
per
(
20
)
end
end
app/helpers/dashboard_helper.rb
浏览文件 @
2ed08871
...
...
@@ -21,4 +21,18 @@ module DashboardHelper
[]
end
.
count
end
def
projects_dashboard_filter_path
(
options
=
{})
exist_opts
=
{
sort:
params
[
:sort
],
scope:
params
[
:scope
],
group:
params
[
:group
],
}
options
=
exist_opts
.
merge
(
options
)
path
=
request
.
path
path
<<
"?
#{
options
.
to_param
}
"
path
end
end
app/helpers/tab_helper.rb
浏览文件 @
2ed08871
...
...
@@ -92,7 +92,12 @@ module TabHelper
def
nav_tab
key
,
value
,
&
block
o
=
{}
o
[
:class
]
=
""
o
[
:class
]
<<
" active"
if
params
[
key
]
==
value
if
value
.
nil?
o
[
:class
]
<<
" active"
if
params
[
key
].
blank?
else
o
[
:class
]
<<
" active"
if
params
[
key
]
==
value
end
if
block_given?
content_tag
(
:li
,
capture
(
&
block
),
o
)
...
...
app/models/project.rb
浏览文件 @
2ed08871
...
...
@@ -153,6 +153,16 @@ class Project < ActiveRecord::Base
def
visibility_levels
Gitlab
::
VisibilityLevel
.
options
end
def
sort
(
method
)
case
method
.
to_s
when
'newest'
then
reorder
(
'projects.created_at DESC'
)
when
'oldest'
then
reorder
(
'projects.created_at ASC'
)
when
'recently_updated'
then
reorder
(
'projects.updated_at DESC'
)
when
'last_updated'
then
reorder
(
'projects.updated_at ASC'
)
else
reorder
(
"namespaces.path, projects.name ASC"
)
end
end
end
def
team
...
...
app/views/dashboard/projects.html.haml
浏览文件 @
2ed08871
%h3
.page-title
My Projects
%h3
.page-title
My Projects
.pull-right
.dropdown.inline
%a
.dropdown-toggle.btn.btn-small
{
href:
'#'
,
"data-toggle"
=>
"dropdown"
}
%span
.light
sort:
-
if
@sort
.
present?
=
@sort
.
humanize
-
else
Name
%b
.caret
%ul
.dropdown-menu
%li
=
link_to
projects_dashboard_filter_path
(
sort:
nil
)
do
Name
=
link_to
projects_dashboard_filter_path
(
sort:
'newest'
)
do
Newest
=
link_to
projects_dashboard_filter_path
(
sort:
'oldest'
)
do
Oldest
=
link_to
projects_dashboard_filter_path
(
sort:
'recently_updated'
)
do
Recently updated
=
link_to
projects_dashboard_filter_path
(
sort:
'last_updated'
)
do
Last updated
%p
.light
All projects you have access to are listed here. Public projects are not included here unless you are a member
%hr
...
...
@@ -6,22 +28,22 @@
.span3
%ul
.nav.nav-pills.nav-stacked
=
nav_tab
:scope
,
nil
do
=
link_to
projects_dashboard_
path
do
=
link_to
projects_dashboard_
filter_path
(
scope:
nil
)
do
All
%span
.pull-right
=
current_user
.
authorized_projects
.
count
=
nav_tab
:scope
,
'personal'
do
=
link_to
projects_dashboard_path
(
scope:
'personal'
)
do
=
link_to
projects_dashboard_
filter_
path
(
scope:
'personal'
)
do
Personal
%span
.pull-right
=
current_user
.
personal_projects
.
count
=
nav_tab
:scope
,
'joined'
do
=
link_to
projects_dashboard_path
(
scope:
'joined'
)
do
=
link_to
projects_dashboard_
filter_
path
(
scope:
'joined'
)
do
Joined
%span
.pull-right
=
current_user
.
authorized_projects
.
joined
(
current_user
).
count
=
nav_tab
:scope
,
'owned'
do
=
link_to
projects_dashboard_path
(
scope:
'owned'
)
do
=
link_to
projects_dashboard_
filter_
path
(
scope:
'owned'
)
do
Owned
%span
.pull-right
=
current_user
.
owned_projects
.
count
...
...
@@ -31,7 +53,7 @@
%ul
.bordered-list.visibility-filter
-
Gitlab
::
VisibilityLevel
.
values
.
each
do
|
level
|
%li
{
class:
(
level
.
to_s
==
params
[
:visibility_level
])
?
'active'
:
'light'
}
=
link_to
projects_dashboard_path
(
visibility_level:
level
)
do
=
link_to
projects_dashboard_
filter_
path
(
visibility_level:
level
)
do
=
visibility_level_icon
(
level
)
=
visibility_level_label
(
level
)
...
...
@@ -41,7 +63,7 @@
%ul
.bordered-list
-
@groups
.
each
do
|
group
|
%li
{
class:
(
group
.
name
==
params
[
:group
])
?
'active'
:
'light'
}
=
link_to
projects_dashboard_path
(
group:
group
.
name
)
do
=
link_to
projects_dashboard_
filter_
path
(
group:
group
.
name
)
do
%i
.icon-folder-close-alt
=
group
.
name
%small
.pull-right
...
...
@@ -55,7 +77,7 @@
%ul
.bordered-list
-
@labels
.
each
do
|
label
|
%li
{
class:
(
label
.
name
==
params
[
:label
])
?
'active'
:
'light'
}
=
link_to
projects_dashboard_path
(
scope:
params
[
:scope
],
label:
label
.
name
)
do
=
link_to
projects_dashboard_
filter_
path
(
scope:
params
[
:scope
],
label:
label
.
name
)
do
%i
.icon-tag
=
label
.
name
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录