Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
be9ffbaf
Commit
be9ffbaf
authored
May 29, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a separate helper to check if we show particular tab on a search page
parent
1a424a9b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
21 deletions
+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
No files found.
app/helpers/projects_helper.rb
View file @
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
}
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
View file @
be9ffbaf
...
...
@@ -34,12 +34,6 @@ module SearchHelper
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
# Autocomplete results for various settings pages
...
...
app/views/search/_category.html.haml
View file @
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
...
...
Write
Preview
Markdown
is supported
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