summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-01-14 19:16:50 +0000
committerPhil Hughes <me@iamphill.com>2016-01-30 16:01:48 +0000
commit9040010481e6ab9b1d9ee2d0699dc99d1109f2f2 (patch)
tree1abb64382c34388d399fcd393b413e88c02cb336
parentd240876abaf800c1878102201b7ee18569ac1708 (diff)
downloadgitlab-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
-rw-r--r--app/assets/stylesheets/framework/header.scss22
-rw-r--r--app/helpers/projects_helper.rb29
2 files changed, 46 insertions, 5 deletions
diff --git a/app/assets/stylesheets/framework/header.scss b/app/assets/stylesheets/framework/header.scss
index f875b1460e7..0789d8133f9 100644
--- a/app/assets/stylesheets/framework/header.scss
+++ b/app/assets/stylesheets/framework/header.scss
@@ -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 {
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 += ' &middot; '.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)