Commit 90400104 authored by Phil Hughes's avatar Phil Hughes

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
......@@ -73,7 +73,6 @@ header {
.title {
margin: 0;
overflow: hidden;
font-size: 19px;
line-height: $header-height;
font-weight: normal;
......@@ -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 {
......
......@@ -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))
......@@ -53,14 +54,34 @@ 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
full_title
end
def remove_project_message(project)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment