Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
38282685
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,发现更多精彩内容 >>
未验证
提交
38282685
编写于
1月 27, 2019
作者:
C
Camil Staps
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add "Starred projects" tab to user overview
上级
936d4e80
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
68 addition
and
3 deletion
+68
-3
app/assets/javascripts/pages/users/user_tabs.js
app/assets/javascripts/pages/users/user_tabs.js
+1
-1
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+24
-1
app/finders/starred_projects_finder.rb
app/finders/starred_projects_finder.rb
+33
-0
app/helpers/users_helper.rb
app/helpers/users_helper.rb
+1
-1
app/views/users/show.html.haml
app/views/users/show.html.haml
+8
-0
config/routes/user.rb
config/routes/user.rb
+1
-0
未找到文件。
app/assets/javascripts/pages/users/user_tabs.js
浏览文件 @
38282685
...
...
@@ -143,7 +143,7 @@ export default class UserTabs {
this
.
loadOverviewTab
();
}
const
loadableActions
=
[
'
groups
'
,
'
contributed
'
,
'
projects
'
,
'
snippets
'
];
const
loadableActions
=
[
'
groups
'
,
'
contributed
'
,
'
projects
'
,
'
s
tarred
'
,
'
s
nippets
'
];
if
(
loadableActions
.
indexOf
(
action
)
>
-
1
)
{
this
.
loadTab
(
action
,
endpoint
);
}
...
...
app/controllers/users_controller.rb
浏览文件 @
38282685
...
...
@@ -17,7 +17,7 @@ class UsersController < ApplicationController
prepend_before_action
(
only:
[
:show
])
{
authenticate_sessionless_user!
(
:rss
)
}
before_action
:user
,
except:
[
:exists
]
before_action
:authorize_read_user_profile!
,
only:
[
:calendar
,
:calendar_activities
,
:groups
,
:projects
,
:contributed_projects
,
:snippets
]
only:
[
:calendar
,
:calendar_activities
,
:groups
,
:projects
,
:contributed_projects
,
:s
tarred_projects
,
:s
nippets
]
def
show
respond_to
do
|
format
|
...
...
@@ -82,6 +82,19 @@ class UsersController < ApplicationController
end
end
def
starred
load_starred_projects
respond_to
do
|
format
|
format
.
html
{
render
'show'
}
format
.
json
do
render
json:
{
html:
view_to_html_string
(
"shared/projects/_list"
,
projects:
@starred_projects
)
}
end
end
end
def
snippets
load_snippets
...
...
@@ -120,6 +133,10 @@ class UsersController < ApplicationController
ContributedProjectsFinder
.
new
(
user
).
execute
(
current_user
)
end
def
starred_projects
StarredProjectsFinder
.
new
(
user
).
execute
(
current_user
)
end
def
contributions_calendar
@contributions_calendar
||=
Gitlab
::
ContributionsCalendar
.
new
(
user
,
current_user
)
end
...
...
@@ -145,6 +162,12 @@ class UsersController < ApplicationController
prepare_projects_for_rendering
(
@contributed_projects
)
end
def
load_starred_projects
@starred_projects
=
starred_projects
.
joined
(
user
)
prepare_projects_for_rendering
(
@starred_projects
)
end
def
load_groups
@groups
=
JoinedGroupsFinder
.
new
(
user
).
execute
(
current_user
)
...
...
app/finders/starred_projects_finder.rb
0 → 100644
浏览文件 @
38282685
# frozen_string_literal: true
class
StarredProjectsFinder
<
UnionFinder
def
initialize
(
user
)
@user
=
user
end
# Finds the projects "@user" starred, limited to either public projects or
# projects visible to the given user.
#
# current_user - When given the list of the projects is limited to those only
# visible by this user.
#
# Returns an ActiveRecord::Relation.
# rubocop: disable CodeReuse/ActiveRecord
def
execute
(
current_user
=
nil
)
segments
=
all_projects
(
current_user
)
find_union
(
segments
,
Project
).
includes
(
:namespace
).
order_id_desc
end
# rubocop: enable CodeReuse/ActiveRecord
private
def
all_projects
(
current_user
)
projects
=
[]
projects
<<
@user
.
starred_projects
.
visible_to_user
(
current_user
)
if
current_user
projects
<<
@user
.
starred_projects
.
public_to_user
(
current_user
)
projects
end
end
app/helpers/users_helper.rb
浏览文件 @
38282685
...
...
@@ -89,7 +89,7 @@ module UsersHelper
tabs
=
[]
if
can?
(
current_user
,
:read_user_profile
,
@user
)
tabs
+=
[
:overview
,
:activity
,
:groups
,
:contributed
,
:projects
,
:snippets
]
tabs
+=
[
:overview
,
:activity
,
:groups
,
:contributed
,
:projects
,
:s
tarred
,
:s
nippets
]
end
tabs
...
...
app/views/users/show.html.haml
浏览文件 @
38282685
...
...
@@ -111,6 +111,10 @@
%li
.js-projects-tab
=
link_to
user_projects_path
,
data:
{
target:
'div#projects'
,
action:
'projects'
,
toggle:
'tab'
,
endpoint:
user_projects_path
(
format: :json
)
}
do
=
s_
(
'UserProfile|Personal projects'
)
-
if
profile_tab?
(
:starred
)
%li
.js-starred-tab
=
link_to
user_starred_projects_path
,
data:
{
target:
'div#starred'
,
action:
'starred'
,
toggle:
'tab'
,
endpoint:
user_starred_projects_path
(
format: :json
)
}
do
=
s_
(
'UserProfile|Starred projects'
)
-
if
profile_tab?
(
:snippets
)
%li
.js-snippets-tab
=
link_to
user_snippets_path
,
data:
{
target:
'div#snippets'
,
action:
'snippets'
,
toggle:
'tab'
,
endpoint:
user_snippets_path
(
format: :json
)
}
do
...
...
@@ -142,6 +146,10 @@
#projects
.tab-pane
-# This tab is always loaded via AJAX
-
if
profile_tab?
(
:starred
)
#starred
.tab-pane
-# This tab is always loaded via AJAX
-
if
profile_tab?
(
:snippets
)
#snippets
.tab-pane
-# This tab is always loaded via AJAX
...
...
config/routes/user.rb
浏览文件 @
38282685
...
...
@@ -59,6 +59,7 @@ scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) d
get
:groups
get
:projects
get
:contributed
,
as: :contributed_projects
get
:starred
,
as: :starred_projects
get
:snippets
get
:exists
get
:activity
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录