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