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
iv
gitlab-ce
Commits
bd1fbe18
Commit
bd1fbe18
authored
Mar 24, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use strings instead of constants
parent
ebd329fe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
31 deletions
+25
-31
app/helpers/search_helper.rb
app/helpers/search_helper.rb
+25
-31
No files found.
app/helpers/search_helper.rb
View file @
bd1fbe18
module
SearchHelper
module
SearchHelper
CAT_SETTINGS
=
'Settings'
CAT_HELP
=
'Help'
CAT_CURR_PROJECT
=
'Current Project'
CAT_GROUPS
=
'Groups'
CAT_PROJECTS
=
'Projects'
def
search_autocomplete_opts
(
term
)
def
search_autocomplete_opts
(
term
)
return
unless
current_user
return
unless
current_user
...
@@ -30,25 +24,25 @@ module SearchHelper
...
@@ -30,25 +24,25 @@ module SearchHelper
# Autocomplete results for various settings pages
# Autocomplete results for various settings pages
def
default_autocomplete
def
default_autocomplete
[
[
{
category:
CAT_SETTINGS
,
label:
"Profile settings"
,
url:
profile_path
},
{
category:
"Settings"
,
label:
"Profile settings"
,
url:
profile_path
},
{
category:
CAT_SETTINGS
,
label:
"SSH Keys"
,
url:
profile_keys_path
},
{
category:
"Settings"
,
label:
"SSH Keys"
,
url:
profile_keys_path
},
{
category:
CAT_SETTINGS
,
label:
"Dashboard"
,
url:
root_path
},
{
category:
"Settings"
,
label:
"Dashboard"
,
url:
root_path
},
{
category:
CAT_SETTINGS
,
label:
"Admin Section"
,
url:
admin_root_path
},
{
category:
"Settings"
,
label:
"Admin Section"
,
url:
admin_root_path
},
]
]
end
end
# Autocomplete results for internal help pages
# Autocomplete results for internal help pages
def
help_autocomplete
def
help_autocomplete
[
[
{
category:
CAT_HELP
,
label:
"API Help"
,
url:
help_page_path
(
"api"
,
"README"
)
},
{
category:
"Help"
,
label:
"API Help"
,
url:
help_page_path
(
"api"
,
"README"
)
},
{
category:
CAT_HELP
,
label:
"Markdown Help"
,
url:
help_page_path
(
"markdown"
,
"markdown"
)
},
{
category:
"Help"
,
label:
"Markdown Help"
,
url:
help_page_path
(
"markdown"
,
"markdown"
)
},
{
category:
CAT_HELP
,
label:
"Permissions Help"
,
url:
help_page_path
(
"permissions"
,
"permissions"
)
},
{
category:
"Help"
,
label:
"Permissions Help"
,
url:
help_page_path
(
"permissions"
,
"permissions"
)
},
{
category:
CAT_HELP
,
label:
"Public Access Help"
,
url:
help_page_path
(
"public_access"
,
"public_access"
)
},
{
category:
"Help"
,
label:
"Public Access Help"
,
url:
help_page_path
(
"public_access"
,
"public_access"
)
},
{
category:
CAT_HELP
,
label:
"Rake Tasks Help"
,
url:
help_page_path
(
"raketasks"
,
"README"
)
},
{
category:
"Help"
,
label:
"Rake Tasks Help"
,
url:
help_page_path
(
"raketasks"
,
"README"
)
},
{
category:
CAT_HELP
,
label:
"SSH Keys Help"
,
url:
help_page_path
(
"ssh"
,
"README"
)
},
{
category:
"Help"
,
label:
"SSH Keys Help"
,
url:
help_page_path
(
"ssh"
,
"README"
)
},
{
category:
CAT_HELP
,
label:
"System Hooks Help"
,
url:
help_page_path
(
"system_hooks"
,
"system_hooks"
)
},
{
category:
"Help"
,
label:
"System Hooks Help"
,
url:
help_page_path
(
"system_hooks"
,
"system_hooks"
)
},
{
category:
CAT_HELP
,
label:
"Webhooks Help"
,
url:
help_page_path
(
"web_hooks"
,
"web_hooks"
)
},
{
category:
"Help"
,
label:
"Webhooks Help"
,
url:
help_page_path
(
"web_hooks"
,
"web_hooks"
)
},
{
category:
CAT_HELP
,
label:
"Workflow Help"
,
url:
help_page_path
(
"workflow"
,
"README"
)
},
{
category:
"Help"
,
label:
"Workflow Help"
,
url:
help_page_path
(
"workflow"
,
"README"
)
},
]
]
end
end
...
@@ -58,16 +52,16 @@ module SearchHelper
...
@@ -58,16 +52,16 @@ module SearchHelper
ref
=
@ref
||
@project
.
repository
.
root_ref
ref
=
@ref
||
@project
.
repository
.
root_ref
[
[
{
category:
CAT_CURR_PROJECT
,
label:
"Files"
,
url:
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
ref
)
},
{
category:
"Current Project"
,
label:
"Files"
,
url:
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
ref
)
},
{
category:
CAT_CURR_PROJECT
,
label:
"Commits"
,
url:
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
ref
)
},
{
category:
"Current Project"
,
label:
"Commits"
,
url:
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
ref
)
},
{
category:
CAT_CURR_PROJECT
,
label:
"Network"
,
url:
namespace_project_network_path
(
@project
.
namespace
,
@project
,
ref
)
},
{
category:
"Current Project"
,
label:
"Network"
,
url:
namespace_project_network_path
(
@project
.
namespace
,
@project
,
ref
)
},
{
category:
CAT_CURR_PROJECT
,
label:
"Graph"
,
url:
namespace_project_graph_path
(
@project
.
namespace
,
@project
,
ref
)
},
{
category:
"Current Project"
,
label:
"Graph"
,
url:
namespace_project_graph_path
(
@project
.
namespace
,
@project
,
ref
)
},
{
category:
CAT_CURR_PROJECT
,
label:
"Issues"
,
url:
namespace_project_issues_path
(
@project
.
namespace
,
@project
)
},
{
category:
"Current Project"
,
label:
"Issues"
,
url:
namespace_project_issues_path
(
@project
.
namespace
,
@project
)
},
{
category:
CAT_CURR_PROJECT
,
label:
"Merge Requests"
,
url:
namespace_project_merge_requests_path
(
@project
.
namespace
,
@project
)
},
{
category:
"Current Project"
,
label:
"Merge Requests"
,
url:
namespace_project_merge_requests_path
(
@project
.
namespace
,
@project
)
},
{
category:
CAT_CURR_PROJECT
,
label:
"Milestones"
,
url:
namespace_project_milestones_path
(
@project
.
namespace
,
@project
)
},
{
category:
"Current Project"
,
label:
"Milestones"
,
url:
namespace_project_milestones_path
(
@project
.
namespace
,
@project
)
},
{
category:
CAT_CURR_PROJECT
,
label:
"Snippets"
,
url:
namespace_project_snippets_path
(
@project
.
namespace
,
@project
)
},
{
category:
"Current Project"
,
label:
"Snippets"
,
url:
namespace_project_snippets_path
(
@project
.
namespace
,
@project
)
},
{
category:
CAT_CURR_PROJECT
,
label:
"Members"
,
url:
namespace_project_project_members_path
(
@project
.
namespace
,
@project
)
},
{
category:
"Current Project"
,
label:
"Members"
,
url:
namespace_project_project_members_path
(
@project
.
namespace
,
@project
)
},
{
category:
CAT_CURR_PROJECT
,
label:
"Wiki"
,
url:
namespace_project_wikis_path
(
@project
.
namespace
,
@project
)
},
{
category:
"Current Project"
,
label:
"Wiki"
,
url:
namespace_project_wikis_path
(
@project
.
namespace
,
@project
)
},
]
]
else
else
[]
[]
...
@@ -78,7 +72,7 @@ module SearchHelper
...
@@ -78,7 +72,7 @@ module SearchHelper
def
groups_autocomplete
(
term
,
limit
=
5
)
def
groups_autocomplete
(
term
,
limit
=
5
)
current_user
.
authorized_groups
.
search
(
term
).
limit
(
limit
).
map
do
|
group
|
current_user
.
authorized_groups
.
search
(
term
).
limit
(
limit
).
map
do
|
group
|
{
{
category:
CAT_GROUPS
,
category:
"Groups"
,
id:
group
.
id
,
id:
group
.
id
,
label:
"
#{
search_result_sanitize
(
group
.
name
)
}
"
,
label:
"
#{
search_result_sanitize
(
group
.
name
)
}
"
,
url:
group_path
(
group
)
url:
group_path
(
group
)
...
@@ -91,7 +85,7 @@ module SearchHelper
...
@@ -91,7 +85,7 @@ module SearchHelper
current_user
.
authorized_projects
.
search_by_title
(
term
).
current_user
.
authorized_projects
.
search_by_title
(
term
).
sorted_by_stars
.
non_archived
.
limit
(
limit
).
map
do
|
p
|
sorted_by_stars
.
non_archived
.
limit
(
limit
).
map
do
|
p
|
{
{
category:
CAT_PROJECTS
,
category:
"Projects"
,
id:
p
.
id
,
id:
p
.
id
,
value:
"
#{
search_result_sanitize
(
p
.
name
)
}
"
,
value:
"
#{
search_result_sanitize
(
p
.
name
)
}
"
,
label:
"
#{
search_result_sanitize
(
p
.
name_with_namespace
)
}
"
,
label:
"
#{
search_result_sanitize
(
p
.
name_with_namespace
)
}
"
,
...
...
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