Commit a10cc220 authored by Phil Hughes's avatar Phil Hughes

added collapsible sub-groups & wiki pages

[ci skip]
parent 85b272b2
export const addTooltipToEl = (el) => {
if (el.scrollWidth > el.offsetWidth) {
el.setAttribute('title', el.textContent);
el.setAttribute('data-container', 'body');
el.classList.add('has-tooltip');
}
};
export default () => {
const breadcrumbs = document.querySelector('.breadcrumbs-list');
const topLevelLinks = breadcrumbs.querySelectorAll('.breadcrumbs-list > li > a');
const $expander = $('.js-breadcrumbs-collapsed-expander');
topLevelLinks.forEach(el => addTooltipToEl(el));
$expander.closest('.dropdown')
.on('show.bs.dropdown hide.bs.dropdown', () => {
$expander.toggleClass('open');
});
};
...@@ -142,6 +142,7 @@ import './smart_interval'; ...@@ -142,6 +142,7 @@ import './smart_interval';
import './star'; import './star';
import './subscription'; import './subscription';
import './subscription_select'; import './subscription_select';
import initBreadcrumbs from './breadcrumb';
import './dispatcher'; import './dispatcher';
...@@ -179,6 +180,8 @@ $(function () { ...@@ -179,6 +180,8 @@ $(function () {
var bootstrapBreakpoint = bp.getBreakpointSize(); var bootstrapBreakpoint = bp.getBreakpointSize();
var fitSidebarForSize; var fitSidebarForSize;
initBreadcrumbs();
// Set the default path for all cookies to GitLab's root directory // Set the default path for all cookies to GitLab's root directory
Cookies.defaults.path = gon.relative_url_root || '/'; Cookies.defaults.path = gon.relative_url_root || '/';
......
...@@ -782,3 +782,7 @@ ...@@ -782,3 +782,7 @@
margin-top: 2px; margin-top: 2px;
} }
} }
.breadcrumbs-list {
@include new-style-dropdown;
}
...@@ -315,19 +315,11 @@ header.navbar-gitlab-new { ...@@ -315,19 +315,11 @@ header.navbar-gitlab-new {
border: 1px solid $border-color; border: 1px solid $border-color;
border-radius: 50%; border-radius: 50%;
vertical-align: sub; vertical-align: sub;
&.identicon {
float: left;
width: 16px;
height: 16px;
margin-top: 2px;
font-size: 10px;
}
} }
.text-expander { .text-expander {
margin-left: 4px; margin-left: 0;
margin-right: 4px; margin-right: 2px;
> i { > i {
position: relative; position: relative;
...@@ -352,11 +344,11 @@ header.navbar-gitlab-new { ...@@ -352,11 +344,11 @@ header.navbar-gitlab-new {
&:not(:first-child) { &:not(:first-child) {
margin-left: 10px; margin-left: 10px;
} }
}
a { > a {
@include str-truncated(128px); @include str-truncated(128px);
color: currentColor; color: currentColor;
}
} }
} }
......
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
outline: none; outline: none;
&.open { &.open {
background: $gray-light; background-color: darken($gray-light, 10%);
box-shadow: inset 0 0 2px rgba($black, 0.2); box-shadow: inset 0 0 2px rgba($black, 0.2);
} }
......
...@@ -30,4 +30,10 @@ module BreadcrumbsHelper ...@@ -30,4 +30,10 @@ module BreadcrumbsHelper
output output
end end
end end
def add_to_breadcrumb_dropdown(link, location: :before)
@breadcrumb_dropdown_links ||= {}
@breadcrumb_dropdown_links[location] = [] unless @breadcrumb_dropdown_links[location]
@breadcrumb_dropdown_links[location] << link
end
end end
...@@ -16,11 +16,19 @@ module GroupsHelper ...@@ -16,11 +16,19 @@ module GroupsHelper
full_title = '' full_title = ''
group.ancestors.reverse.each_with_index do |parent, index| group.ancestors.reverse.each_with_index do |parent, index|
full_title += if show_new_nav? if show_new_nav? && index > 0
breadcrumb_list_item group_title_link(parent, hidable: index > 0) add_to_breadcrumb_dropdown(group_title_link(parent, hidable: false), location: :before)
else else
group_title_link(parent, hidable: true) full_title += if show_new_nav?
end breadcrumb_list_item group_title_link(parent, hidable: false)
else
group_title_link(parent, hidable: true)
end
end
end
if show_new_nav?
full_title += render "layouts/nav/breadcrumbs/collapsed_dropdown", location: :before, title: _("Show parent subgroups")
end end
full_title += if show_new_nav? full_title += if show_new_nav?
...@@ -78,7 +86,7 @@ module GroupsHelper ...@@ -78,7 +86,7 @@ module GroupsHelper
def group_title_link(group, hidable: false) def group_title_link(group, hidable: false)
link_to(group_path(group), class: "group-path #{'hidable' if hidable}") do link_to(group_path(group), class: "group-path #{'hidable' if hidable}") do
output = output =
if show_new_nav? if show_new_nav? && group.try(:avatar_url)
image_tag(group_icon(group), class: "avatar-tile", width: 16, height: 16) image_tag(group_icon(group), class: "avatar-tile", width: 16, height: 16)
else else
"" ""
......
...@@ -60,7 +60,7 @@ module ProjectsHelper ...@@ -60,7 +60,7 @@ module ProjectsHelper
project_link = link_to project_path(project), { class: ("project-item-select-holder" unless show_new_nav?) } do project_link = link_to project_path(project), { class: ("project-item-select-holder" unless show_new_nav?) } do
output = output =
if show_new_nav? if show_new_nav? && project.avatar_url
project_icon(project, alt: project.name, class: 'avatar-tile', width: 16, height: 16) project_icon(project, alt: project.name, class: 'avatar-tile', width: 16, height: 16)
else else
"" ""
......
...@@ -10,4 +10,15 @@ module WikiHelper ...@@ -10,4 +10,15 @@ module WikiHelper
.map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize } .map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize }
.join(' / ') .join(' / ')
end end
def wiki_breadcrumb_dropdown_links(page_slug)
page_slug_split = page_slug.split('/')
page_slug_split.pop(1)
current_slug = ""
page_slug_split
.map do |dir_or_page|
current_slug = "#{current_slug}/#{dir_or_page}"
add_to_breadcrumb_dropdown link_to(WikiPage.unhyphenize(dir_or_page).capitalize, project_wiki_path(@project, current_slug)), location: :after
end
end
end end
...@@ -10,14 +10,13 @@ ...@@ -10,14 +10,13 @@
.breadcrumbs-links.js-title-container .breadcrumbs-links.js-title-container
%ul.list-unstyled.breadcrumbs-list %ul.list-unstyled.breadcrumbs-list
- unless hide_top_links - unless hide_top_links
- if content_for?(:header_title_before)
%li= yield :header_title_before
= header_title = header_title
- if @breadcrumbs_extra_links - if @breadcrumbs_extra_links
- @breadcrumbs_extra_links.each do |extra| - @breadcrumbs_extra_links.each do |extra|
%li= link_to extra[:text], extra[:link] = breadcrumb_list_item link_to(extra[:text], extra[:link])
= render "layouts/nav/breadcrumbs/collapsed_dropdown", location: :after
%li %li
%h2.breadcrumbs-sub-title= link_to @breadcrumb_title, breadcrumb_link %h2.breadcrumbs-sub-title= @breadcrumb_title
- if content_for?(:breadcrumbs_extra) - if content_for?(:breadcrumbs_extra)
.breadcrumbs-extra.hidden-xs= yield :breadcrumbs_extra .breadcrumbs-extra.hidden-xs= yield :breadcrumbs_extra
= yield :header_content = yield :header_content
- dropdown_location = local_assigns.fetch(:location, nil)
- button_tooltip = local_assigns.fetch(:title, _("Show parent pages"))
- if defined?(@breadcrumb_dropdown_links) && @breadcrumb_dropdown_links.key?(dropdown_location)
%li.dropdown
%button.text-expander.has-tooltip.js-breadcrumbs-collapsed-expander{ type: "button", data: { toggle: "dropdown", container: "body" }, "aria-label": button_tooltip, title: button_tooltip }
= icon("ellipsis-h")
= icon("angle-right", class: "breadcrumbs-list-angle")
.dropdown-menu
%ul
- @breadcrumb_dropdown_links[dropdown_location].each_with_index do |link, index|
%li{ style: "text-indent: #{[index * 15, 60].min}px;"}= link
- @content_class = "limit-container-width limit-container-width-sm" unless fluid_layout - @content_class = "limit-container-width limit-container-width-sm" unless fluid_layout
- breadcrumb_title "Wiki" - breadcrumb_title @page.title.capitalize
- wiki_breadcrumb_dropdown_links(@page.slug)
- page_title @page.title.capitalize, "Wiki" - page_title @page.title.capitalize, "Wiki"
- if show_new_nav?
- add_to_breadcrumbs "Wiki", get_project_wiki_path(@project)
.wiki-page-header.has-sidebar-toggle .wiki-page-header.has-sidebar-toggle
%button.btn.btn-default.sidebar-toggle.js-sidebar-wiki-toggle{ role: "button", type: "button" } %button.btn.btn-default.sidebar-toggle.js-sidebar-wiki-toggle{ role: "button", type: "button" }
= icon('angle-double-left') = icon('angle-double-left')
.wiki-breadcrumb - unless show_new_nav?
%span= breadcrumb(@page.slug) .wiki-breadcrumb
%span= breadcrumb(@page.slug)
.nav-text .nav-text
%h2.wiki-page-title= @page.title.capitalize %h2.wiki-page-title= @page.title.capitalize
......
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