Skip to content
Snippets Groups Projects
Commit 90400104 authored by Phil Hughes's avatar Phil Hughes
Browse files

Added dropdown to list all projects on project header

When clicking the current project name, it shows a dropdown menu with a list of all projects for that group or user
parent d240876a
No related branches found
No related tags found
1 merge request!2438Added dropdown to list all projects on project header
Loading
Loading
@@ -73,7 +73,6 @@ header {
 
.title {
margin: 0;
overflow: hidden;
font-size: 19px;
line-height: $header-height;
font-weight: normal;
Loading
Loading
@@ -88,6 +87,27 @@ header {
text-decoration: underline;
}
}
.dropdown {
display: inline-block;
}
.dropdown-toggle-caret {
margin-left: 5px;
}
.dropdown-item {
&.active {
.dropdown-link {
color: #fff;
}
}
.dropdown-link:hover {
color: #fff;
text-decoration: none;
}
}
}
 
.navbar-collapse {
Loading
Loading
Loading
Loading
@@ -45,6 +45,7 @@ module ProjectsHelper
end
 
def project_title(project, name = nil, url = nil)
project_id = project.id
namespace_link =
if project.group
link_to(simple_sanitize(project.group.name), group_path(project.group))
Loading
Loading
@@ -53,15 +54,35 @@ module ProjectsHelper
link_to(simple_sanitize(owner.name), user_path(owner))
end
 
project_link = link_to(simple_sanitize(project.name), project_path(project))
all_projects =
if project.group
project.group.projects
else
PersonalProjectsFinder.new(project.namespace.owner).execute(current_user)
end
project_link = content_tag :div, {class: "dropdown"} do
output = content_tag :a, {class: "dropdown-toggle", href: "#", data: {toggle: "dropdown"}} do
btnOutput = simple_sanitize(project.name)
btnOutput += content_tag :span, nil, {class: "caret dropdown-toggle-caret"}
end
list = all_projects.map do |project|
content_tag :li, {class: "dropdown-item #{"active" if project_id == project.id}"} do
link_to(simple_sanitize(project.name), project_path(project), {class: "dropdown-link"})
end
end
output += content_tag :ul, {class: "dropdown-menu"} do
list.join.html_safe
end
end
 
full_title = namespace_link + ' / ' + project_link
full_title += ' · '.html_safe + link_to(simple_sanitize(name), url) if name
 
content_tag :span do
full_title
end
end
 
def remove_project_message(project)
"You are going to remove #{project.name_with_namespace}.\n Removed project CANNOT be restored!\n Are you ABSOLUTELY sure?"
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment