Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
be9ffbaf
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,体验更适合开发者的 AI 搜索 >>
提交
be9ffbaf
编写于
5月 29, 2017
作者:
V
Valery Sizov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create a separate helper to check if we show particular tab on a search page
上级
1a424a9b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
21 deletion
+32
-21
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+25
-8
app/helpers/search_helper.rb
app/helpers/search_helper.rb
+0
-6
app/views/search/_category.html.haml
app/views/search/_category.html.haml
+7
-7
未找到文件。
app/helpers/projects_helper.rb
浏览文件 @
be9ffbaf
...
...
@@ -85,6 +85,12 @@ module ProjectsHelper
@nav_tabs
||=
get_project_nav_tabs
(
@project
,
current_user
)
end
def
project_search_tabs?
(
tab
)
abilities
=
Array
(
search_tab_ability_map
[
tab
])
abilities
.
any?
{
|
ability
|
can?
(
current_user
,
ability
,
@project
)
}
end
def
project_nav_tab?
(
name
)
project_nav_tabs
.
include?
name
end
...
...
@@ -203,7 +209,17 @@ module ProjectsHelper
nav_tabs
<<
:container_registry
end
tab_ability_map
=
{
tab_ability_map
.
each
do
|
tab
,
ability
|
if
can?
(
current_user
,
ability
,
project
)
nav_tabs
<<
tab
end
end
nav_tabs
.
flatten
end
def
tab_ability_map
{
environments: :read_environment
,
milestones: :read_milestone
,
pipelines: :read_pipeline
,
...
...
@@ -215,14 +231,15 @@ module ProjectsHelper
team: :read_project_member
,
wiki: :read_wiki
}
end
tab_ability_map
.
each
do
|
tab
,
ability
|
if
can?
(
current_user
,
ability
,
project
)
nav_tabs
<<
tab
end
end
nav_tabs
.
flatten
def
search_tab_ability_map
@search_tab_ability_map
||=
tab_ability_map
.
merge
(
blobs: :download_code
,
commits: :download_code
,
merge_requests: :read_merge_request
,
notes:
[
:read_merge_request
,
:download_code
,
:read_issue
,
:read_project_snippet
]
)
end
def
project_lfs_status
(
project
)
...
...
app/helpers/search_helper.rb
浏览文件 @
be9ffbaf
...
...
@@ -33,12 +33,6 @@ module SearchHelper
def
parse_search_result
(
result
)
Gitlab
::
ProjectSearchResults
.
parse_search_result
(
result
)
end
def
show_notes_tab?
[
:read_merge_request
,
:download_code
,
:read_issue
,
:read_project_snippet
].
all?
do
|
ability
|
can?
(
current_user
,
:read_merge_request
,
@project
)
end
end
private
...
...
app/views/search/_category.html.haml
浏览文件 @
be9ffbaf
...
...
@@ -3,43 +3,43 @@
.fade-right
=
icon
(
'angle-right'
)
%ul
.nav-links.search-filter.scrolling-tabs
-
if
@project
-
if
can?
(
current_user
,
:download_code
,
@project
)
-
if
project_search_tabs?
(
:blobs
)
%li
{
class:
active_when
(
@scope
==
'blobs'
)
}
=
link_to
search_filter_path
(
scope:
'blobs'
)
do
Code
%span
.badge
=
@search_results
.
blobs_count
-
if
can?
(
current_user
,
:read_issue
,
@project
)
-
if
project_search_tabs?
(
:issues
)
%li
{
class:
active_when
(
@scope
==
'issues'
)
}
=
link_to
search_filter_path
(
scope:
'issues'
)
do
Issues
%span
.badge
=
@search_results
.
issues_count
-
if
can?
(
current_user
,
:read_merge_request
,
@project
)
-
if
project_search_tabs?
(
:merge_requests
)
%li
{
class:
active_when
(
@scope
==
'merge_requests'
)
}
=
link_to
search_filter_path
(
scope:
'merge_requests'
)
do
Merge requests
%span
.badge
=
@search_results
.
merge_requests_count
-
if
can?
(
current_user
,
:read_milestone
,
@project
)
-
if
project_search_tabs?
(
:milestones
)
%li
{
class:
active_when
(
@scope
==
'milestones'
)
}
=
link_to
search_filter_path
(
scope:
'milestones'
)
do
Milestones
%span
.badge
=
@search_results
.
milestones_count
-
if
show_notes_tab?
-
if
project_search_tabs?
(
:notes
)
%li
{
class:
active_when
(
@scope
==
'notes'
)
}
=
link_to
search_filter_path
(
scope:
'notes'
)
do
Comments
%span
.badge
=
@search_results
.
notes_count
-
if
can?
(
current_user
,
:read_wiki
,
@project
)
-
if
project_search_tabs?
(
:wiki
)
%li
{
class:
active_when
(
@scope
==
'wiki_blobs'
)
}
=
link_to
search_filter_path
(
scope:
'wiki_blobs'
)
do
Wiki
%span
.badge
=
@search_results
.
wiki_blobs_count
-
if
can?
(
current_user
,
:download_code
,
@project
)
-
if
project_search_tabs?
(
:commits
)
%li
{
class:
active_when
(
@scope
==
'commits'
)
}
=
link_to
search_filter_path
(
scope:
'commits'
)
do
Commits
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录