diff options
author | Phil Hughes <me@iamphill.com> | 2016-01-14 19:16:50 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-01-30 16:01:48 +0000 |
commit | 9040010481e6ab9b1d9ee2d0699dc99d1109f2f2 (patch) | |
tree | 1abb64382c34388d399fcd393b413e88c02cb336 /app/helpers/projects_helper.rb | |
parent | d240876abaf800c1878102201b7ee18569ac1708 (diff) | |
download | gitlab-ce-9040010481e6ab9b1d9ee2d0699dc99d1109f2f2.tar.gz |
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
Diffstat (limited to 'app/helpers/projects_helper.rb')
-rw-r--r-- | app/helpers/projects_helper.rb | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 8c8b355028c..5afbdb332cc 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -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) |