Commit b11029a6 authored by Phil Hughes's avatar Phil Hughes

fixed up JS to use a js-* class

fixed up Ruby based on review
parent 18127685
export const addTooltipToEl = (el) => {
if (el.scrollWidth > el.offsetWidth) {
const textEl = el.querySelector('.js-breadcrumb-item-text');
if (textEl && textEl.scrollWidth > textEl.offsetWidth) {
el.setAttribute('title', el.textContent);
el.setAttribute('data-container', 'body');
el.classList.add('has-tooltip');
......@@ -7,10 +9,12 @@ export const addTooltipToEl = (el) => {
};
export default () => {
const breadcrumbs = document.querySelector('.breadcrumbs-list');
const breadcrumbs = document.querySelector('.js-breadcrumbs-list');
if (breadcrumbs) {
const topLevelLinks = breadcrumbs.querySelectorAll('.breadcrumbs-list > li > a');
const topLevelLinks = [...breadcrumbs.children].filter(el => !el.classList.contains('dropdown'))
.map(el => el.querySelector('a'))
.filter(el => el);
const $expander = $('.js-breadcrumbs-collapsed-expander');
topLevelLinks.forEach(el => addTooltipToEl(el));
......
......@@ -365,7 +365,7 @@ header.navbar-gitlab-new {
}
}
.breadcrumb-item-project-name {
.breadcrumb-item-text {
@include str-truncated(128px);
}
......
......@@ -25,15 +25,13 @@ module BreadcrumbsHelper
def breadcrumb_list_item(link)
content_tag "li" do
output = link
output << icon("angle-right", class: "breadcrumbs-list-angle")
output
link + icon("angle-right", class: "breadcrumbs-list-angle")
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] ||= []
@breadcrumb_dropdown_links[location] << link
end
end
......@@ -36,7 +36,7 @@ module GroupsHelper
else
group_title_link(group)
end
full_title += ' &middot; '.html_safe + link_to(simple_sanitize(name), url, class: 'group-path') if name
full_title += ' &middot; '.html_safe + link_to(simple_sanitize(name), url, class: 'group-path breadcrumb-item-text js-breadcrumb-item-text') if name
if show_new_nav?
full_title.html_safe
......@@ -90,7 +90,7 @@ module GroupsHelper
private
def group_title_link(group, hidable: false, show_avatar: false)
link_to(group_path(group), class: "group-path #{'hidable' if hidable}") do
link_to(group_path(group), class: "group-path breadcrumb-item-text js-breadcrumb-item-text #{'hidable' if hidable}") do
output =
if (group.try(:avatar_url) || show_avatar) && !Rails.env.test?
image_tag(group_icon(group), class: "avatar-tile", width: 15, height: 15)
......
......@@ -80,10 +80,12 @@ module PageLayoutHelper
@header_title = title
@header_title_url = title_url
else
return @header_title unless @header_title_url
if show_new_nav?
@header_title_url ? breadcrumb_list_item(link_to(@header_title, @header_title_url)) : @header_title
breadcrumb_list_item(link_to(@header_title, @header_title_url))
else
@header_title_url ? link_to(@header_title, @header_title_url) : @header_title
link_to(@header_title, @header_title_url)
end
end
end
......
......@@ -68,12 +68,12 @@ module ProjectsHelper
""
end
output << content_tag("span", simple_sanitize(project.name), class: "breadcrumb-item-project-name")
output << content_tag("span", simple_sanitize(project.name), class: "breadcrumb-item-text js-breadcrumb-item-text")
output.html_safe
end
if show_new_nav?
namespace_link = breadcrumb_list_item(namespace_link) if project.group.nil?
namespace_link = breadcrumb_list_item(namespace_link) unless project.group
project_link = breadcrumb_list_item project_link
end
......
......@@ -17,7 +17,7 @@ module WikiHelper
current_slug = ""
page_slug_split
.map do |dir_or_page|
current_slug = "#{current_slug}/#{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
......
......@@ -8,7 +8,7 @@
%span.sr-only Open sidebar
= icon ('bars')
.breadcrumbs-links.js-title-container
%ul.list-unstyled.breadcrumbs-list
%ul.list-unstyled.breadcrumbs-list.js-breadcrumbs-list
- unless hide_top_links
= header_title
- if @breadcrumbs_extra_links
......
......@@ -36,13 +36,13 @@ class Spinach::Features::ExploreProjects < Spinach::FeatureSteps
end
step 'I should see project "Community" home page' do
page.within '.breadcrumbs .breadcrumb-item-project-name' do
page.within '.breadcrumbs .breadcrumb-item-text' do
expect(page).to have_content 'Community'
end
end
step 'I should see project "Internal" home page' do
page.within '.breadcrumbs .breadcrumb-item-project-name' do
page.within '.breadcrumbs .breadcrumb-item-text' do
expect(page).to have_content 'Internal'
end
end
......
......@@ -18,7 +18,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
step 'I should see project "Community" home page' do
Gitlab.config.gitlab.should_receive(:host).and_return("www.example.com")
page.within '.breadcrumbs .breadcrumb-item-project-name' do
page.within '.breadcrumbs .breadcrumb-item-text' do
expect(page).to have_content 'Community'
end
end
......
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