Commit d3d6d043 authored by Florie Guibert's avatar Florie Guibert Committed by Heinrich Lee Yu

Update labels to use gitlab-ui css in haml

- Refactor render_label helper
- Support for scoped labels
- Support for small labels
- Impacts issue sidebar, issues list, labels list, epic, milestones
- Move tooltip from span to link
parent 023c978d
import $ from 'jquery'; import $ from 'jquery';
import Sortable from 'sortablejs'; import Sortable from 'sortablejs';
import Vue from 'vue'; import Vue from 'vue';
import { GlButtonGroup, GlButton, GlTooltip } from '@gitlab/ui'; import { GlButtonGroup, GlButton, GlLabel, GlTooltip } from '@gitlab/ui';
import isWipLimitsOn from 'ee_else_ce/boards/mixins/is_wip_limits'; import isWipLimitsOn from 'ee_else_ce/boards/mixins/is_wip_limits';
import { s__, __, sprintf } from '~/locale'; import { s__, __, sprintf } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
...@@ -14,6 +14,7 @@ import IssueCount from './issue_count.vue'; ...@@ -14,6 +14,7 @@ import IssueCount from './issue_count.vue';
import boardsStore from '../stores/boards_store'; import boardsStore from '../stores/boards_store';
import { getBoardSortableDefaultOptions, sortableEnd } from '../mixins/sortable_default_options'; import { getBoardSortableDefaultOptions, sortableEnd } from '../mixins/sortable_default_options';
import { ListType } from '../constants'; import { ListType } from '../constants';
import { isScopedLabel } from '~/lib/utils/common_utils';
export default Vue.extend({ export default Vue.extend({
components: { components: {
...@@ -24,6 +25,7 @@ export default Vue.extend({ ...@@ -24,6 +25,7 @@ export default Vue.extend({
GlButtonGroup, GlButtonGroup,
IssueCount, IssueCount,
GlButton, GlButton,
GlLabel,
GlTooltip, GlTooltip,
}, },
directives: { directives: {
...@@ -95,6 +97,9 @@ export default Vue.extend({ ...@@ -95,6 +97,9 @@ export default Vue.extend({
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings // eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
return `boards.${this.boardId}.${this.list.type}.${this.list.id}`; return `boards.${this.boardId}.${this.list.type}.${this.list.id}`;
}, },
helpLink() {
return boardsStore.scopedLabels.helpLink;
},
}, },
watch: { watch: {
filter: { filter: {
...@@ -145,6 +150,10 @@ export default Vue.extend({ ...@@ -145,6 +150,10 @@ export default Vue.extend({
} }
}, },
methods: { methods: {
showScopedLabels(label) {
return boardsStore.scopedLabels.enabled && isScopedLabel(label);
},
showNewIssueForm() { showNewIssueForm() {
this.$refs['board-list'].showIssueForm = !this.$refs['board-list'].showIssueForm; this.$refs['board-list'].showIssueForm = !this.$refs['board-list'].showIssueForm;
}, },
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import $ from 'jquery'; import $ from 'jquery';
import Vue from 'vue'; import Vue from 'vue';
import { GlLabel } from '@gitlab/ui';
import Flash from '~/flash'; import Flash from '~/flash';
import { sprintf, __ } from '~/locale'; import { sprintf, __ } from '~/locale';
import Sidebar from '~/right_sidebar'; import Sidebar from '~/right_sidebar';
...@@ -22,6 +23,7 @@ export default Vue.extend({ ...@@ -22,6 +23,7 @@ export default Vue.extend({
components: { components: {
AssigneeTitle, AssigneeTitle,
Assignees, Assignees,
GlLabel,
SidebarEpicsSelect: () => SidebarEpicsSelect: () =>
import('ee_component/sidebar/components/sidebar_item_epics_select.vue'), import('ee_component/sidebar/components/sidebar_item_epics_select.vue'),
RemoveBtn, RemoveBtn,
...@@ -67,6 +69,9 @@ export default Vue.extend({ ...@@ -67,6 +69,9 @@ export default Vue.extend({
selectedLabels() { selectedLabels() {
return this.hasLabels ? this.issue.labels.map(l => l.title).join(',') : ''; return this.hasLabels ? this.issue.labels.map(l => l.title).join(',') : '';
}, },
helpLink() {
return boardsStore.scopedLabels.helpLink;
},
}, },
watch: { watch: {
detail: { detail: {
...@@ -147,19 +152,5 @@ export default Vue.extend({ ...@@ -147,19 +152,5 @@ export default Vue.extend({
showScopedLabels(label) { showScopedLabels(label) {
return boardsStore.scopedLabels.enabled && isScopedLabel(label); return boardsStore.scopedLabels.enabled && isScopedLabel(label);
}, },
splitScopedLabel(label) {
return label.title.split('::');
},
scopedLabelScope(label) {
const splitLabel = this.splitScopedLabel(label)
return splitLabel[0];
},
scopedValue(label) {
const splitLabel = this.splitScopedLabel(label)
return splitLabel[1];
},
helpLink() {
return boardsStore.scopedLabels.helpLink;
},
}, },
}); });
...@@ -18,10 +18,9 @@ ...@@ -18,10 +18,9 @@
display: inline-block; display: inline-block;
} }
.color-label { .gl-label {
font-size: $gl-font-size; vertical-align: top;
padding: $gl-vert-padding $label-padding-modal; line-height: 16px;
vertical-align: middle;
} }
} }
......
...@@ -86,17 +86,6 @@ ...@@ -86,17 +86,6 @@
} }
.issuable-show-labels { .issuable-show-labels {
.gl-label-scoped {
border-style: solid;
border-width: 2px;
&.gl-label-sm {
border-width: 1px;
}
.gl-label-text:last-child {
padding-right: 22px;
}
}
.gl-label { .gl-label {
margin-bottom: 5px; margin-bottom: 5px;
margin-right: 5px; margin-right: 5px;
...@@ -134,7 +123,8 @@ ...@@ -134,7 +123,8 @@
padding-right: $gl-padding-24; padding-right: $gl-padding-24;
} }
.scoped-label { .scoped-label,
.gl-label-icon {
right: 12px; right: 12px;
} }
} }
...@@ -173,9 +163,17 @@ ...@@ -173,9 +163,17 @@
.avatar { .avatar {
border-color: rgba($gray-normal, 0.2); border-color: rgba($gray-normal, 0.2);
} }
} }
}
.gl-label .gl-label-link:hover,
.gl-label + .gl-label-icon:hover {
text-decoration: none;
color: inherit;
.gl-label-text:last-of-type {
text-decoration: underline;
}
} }
.btn-link { .btn-link {
...@@ -814,9 +812,17 @@ ...@@ -814,9 +812,17 @@
a { a {
color: $gl-text-color; color: $gl-text-color;
}
.fa { .gl-label-link {
color: $gl-text-color-secondary; color: inherit;
&:hover {
text-decoration: none;
.gl-label-text:last-of-type {
text-decoration: underline;
}
} }
} }
} }
......
...@@ -127,6 +127,11 @@ ...@@ -127,6 +127,11 @@
.color-label { .color-label {
padding: $gl-padding-4 $grid-size; padding: $gl-padding-4 $grid-size;
} }
.prepend-description-left {
vertical-align: top;
line-height: 24px;
}
} }
.prioritized-labels { .prioritized-labels {
...@@ -305,10 +310,15 @@ ...@@ -305,10 +310,15 @@
width: 150px; width: 150px;
flex-shrink: 0; flex-shrink: 0;
.badge { .gl-label {
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%; max-width: 100%;
.gl-label-text {
text-overflow: ellipsis;
max-width: 100%;
overflow: hidden;
white-space: nowrap;
}
} }
} }
...@@ -414,6 +424,14 @@ ...@@ -414,6 +424,14 @@
.scoped-label-wrapper { .scoped-label-wrapper {
max-width: 100%; max-width: 100%;
vertical-align: top; vertical-align: top;
line-height: 16px;
.gl-link.gl-label-icon {
color: $gray-500;
display: inline-flex;
align-items: center;
margin-left: 0.25rem;
}
.badge { .badge {
text-overflow: ellipsis; text-overflow: ellipsis;
...@@ -431,13 +449,17 @@ ...@@ -431,13 +449,17 @@
.scoped-label { .scoped-label {
position: absolute; position: absolute;
top: 4px; top: 6px;
right: 8px; right: 8px;
padding: 0; padding: 0;
margin: 0; margin: 0;
line-height: $gl-line-height; line-height: $gl-line-height;
} }
.gl-label-scoped-text {
padding-right: 22px;
}
&.board-label { &.board-label {
.scoped-label { .scoped-label {
top: 1px; top: 1px;
...@@ -445,10 +467,23 @@ ...@@ -445,10 +467,23 @@
} }
} }
.gl-label-sm + .scoped-label {
top: 2px;
}
.gl-label-scoped {
box-shadow: 0 0 0 2px currentColor inset;
&.gl-label-sm {
box-shadow: 0 0 0 1px inset;
}
}
// Label inside title of Delete Label Modal // Label inside title of Delete Label Modal
.modal-header .page-title { .modal-header .page-title {
.scoped-label-wrapper { .scoped-label-wrapper {
.scoped-label { .scoped-label,
.gl-label-icon {
line-height: 20px; line-height: 20px;
} }
......
...@@ -283,7 +283,7 @@ $note-form-margin-left: 72px; ...@@ -283,7 +283,7 @@ $note-form-margin-left: 72px;
text-transform: lowercase; text-transform: lowercase;
} }
a { a:not(.gl-link) {
color: $blue-600; color: $blue-600;
} }
...@@ -671,6 +671,16 @@ $note-form-margin-left: 72px; ...@@ -671,6 +671,16 @@ $note-form-margin-left: 72px;
a:hover { a:hover {
text-decoration: underline; text-decoration: underline;
} }
.gl-label-link:hover,
.gl-label-icon:hover {
text-decoration: none;
color: inherit;
.gl-label-text:last-of-type {
text-decoration: underline;
}
}
} }
/** /**
......
...@@ -36,35 +36,53 @@ module LabelsHelper ...@@ -36,35 +36,53 @@ module LabelsHelper
# link_to_label(label) { "My Custom Label Text" } # link_to_label(label) { "My Custom Label Text" }
# #
# Returns a String # Returns a String
def link_to_label(label, type: :issue, tooltip: true, css_class: nil, &block) def link_to_label(label, type: :issue, tooltip: true, small: false, &block)
link = label.filter_path(type: type) link = label.filter_path(type: type)
if block_given? if block_given?
link_to link, class: css_class, &block link_to link, class: 'gl-link gl-label-link', &block
else else
render_label(label, tooltip: tooltip, link: link, css: css_class) render_label(label, tooltip: tooltip, link: link, small: small)
end end
end end
def render_label(label, tooltip: true, link: nil, css: nil, dataset: nil) def render_label(label, tooltip: true, link: nil, dataset: nil, small: false)
# if scoped label is used then EE wraps label tag with scoped label # if scoped label is used then EE wraps label tag with scoped label
# doc link # doc link
html = render_colored_label(label, tooltip: tooltip) html = render_colored_label(label)
html = link_to(html, link, class: css, data: dataset) if link
if link
html = link_to(
html,
link,
class: label_css_classes(tooltip),
data: label_dataset(label, dataset, tooltip)
)
end
wrapper_class = "gl-label"
wrapper_class += " gl-label-sm" if small
html content_tag(:span, html.html_safe, class: wrapper_class)
end end
def render_colored_label(label, label_suffix: '', tooltip: true, title: nil) def render_colored_label(label, label_suffix: '')
text_color = text_color_for_bg(label.color) render_partial_label(
title ||= tooltip ? label_tooltip_title(label) : label.name label,
label_suffix: label_suffix,
label_name: label.name,
css_class: text_color_class_for_bg(label.color),
bg_color: label.color
)
end
def render_partial_label(label, label_suffix: '', label_name: nil, css_class: nil, bg_color: nil)
# Intentionally not using content_tag here so that this method can be called # Intentionally not using content_tag here so that this method can be called
# by LabelReferenceFilter # by LabelReferenceFilter
span = %(<span class="badge color-label #{"has-tooltip" if tooltip}" ) + span = %(<span class="gl-label-text #{css_class}" ) +
%(data-html="true" style="background-color: #{label.color}; color: #{text_color}" ) + %(data-html="true" #{"style=\"background-color: #{bg_color}\"" if bg_color} ) +
%(title="#{ERB::Util.html_escape_once(title)}" data-container="body">) + %(data-container="body">) +
%(#{ERB::Util.html_escape_once(label.name)}#{label_suffix}</span>) %(#{ERB::Util.html_escape_once(label_name)}#{label_suffix}</span>)
span.html_safe span.html_safe
end end
...@@ -109,6 +127,20 @@ module LabelsHelper ...@@ -109,6 +127,20 @@ module LabelsHelper
end end
end end
def text_color_class_for_bg(bg_color)
if bg_color.length == 4
r, g, b = bg_color[1, 4].scan(/./).map { |v| (v * 2).hex }
else
r, g, b = bg_color[1, 7].scan(/.{2}/).map(&:hex)
end
if (r + g + b) > 500
'gl-label-text-black'
else
'gl-label-text-light'
end
end
def text_color_for_bg(bg_color) def text_color_for_bg(bg_color)
if bg_color.length == 4 if bg_color.length == 4
r, g, b = bg_color[1, 4].scan(/./).map { |v| (v * 2).hex } r, g, b = bg_color[1, 4].scan(/./).map { |v| (v * 2).hex }
...@@ -246,6 +278,21 @@ module LabelsHelper ...@@ -246,6 +278,21 @@ module LabelsHelper
def issuable_types def issuable_types
['issues', 'merge requests'] ['issues', 'merge requests']
end end
private
def label_dataset(label, dataset, tooltip)
dataset ||= {}
dataset.merge!(html: true, title: label_tooltip_title(label)) if tooltip
end
def label_css_classes(tooltip)
css = 'gl-link gl-label-link'
tooltip ? "#{css} has-tooltip" : css
end
# Required for Banzai::Filter::LabelReferenceFilter
module_function :render_colored_label, :text_color_for_bg, :escape_once, :label_tooltip_title
end end
LabelsHelper.prepend_if_ee('EE::LabelsHelper') LabelsHelper.prepend_if_ee('EE::LabelsHelper')
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
- if issue.labels.any? - if issue.labels.any?
&nbsp; &nbsp;
- presented_labels_sorted_by_title(issue.labels, issue.project).each do |label| - presented_labels_sorted_by_title(issue.labels, issue.project).each do |label|
= link_to_label(label, css_class: 'label-link') = link_to_label(label, small: true)
= render_if_exists "projects/issues/issue_weight", issue: issue = render_if_exists "projects/issues/issue_weight", issue: issue
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
- if merge_request.labels.any? - if merge_request.labels.any?
&nbsp; &nbsp;
- presented_labels_sorted_by_title(merge_request.labels, merge_request.project).each do |label| - presented_labels_sorted_by_title(merge_request.labels, merge_request.project).each do |label|
= link_to_label(label, type: :merge_request, css_class: 'label-link') = link_to_label(label, type: :merge_request, small: true)
.issuable-meta .issuable-meta
%ul.controls.d-flex.align-items-end %ul.controls.d-flex.align-items-end
......
...@@ -29,11 +29,15 @@ ...@@ -29,11 +29,15 @@
":title" => '(list.assignee && list.assignee.username || "")' } ":title" => '(list.assignee && list.assignee.username || "")' }
@{{ list.assignee.username }} @{{ list.assignee.username }}
%span.has-tooltip.badge.color-label.title.d-inline-block.mw-100.text-truncate.align-middle{ "v-if": "list.type === \"label\"", %gl-label{ "v-if" => " list.type === \"label\"",
":title" => '(list.label ? list.label.description : "")', ":id" => "list.label.id",
data: { container: "body", placement: "bottom" }, ":background-color" => "list.label.color",
":style" => "{ backgroundColor: (list.label && list.label.color ? list.label.color : null), color: (list.label && list.label.textColor ? list.label.textColor : \"#2e2e2e\") }" } ":title" => "list.label.title",
{{ list.title }} ":description" => "list.label.description",
"tooltipPlacement" => "bottom",
":size" => '(!list.isExpanded ? "sm" : "")',
":scoped" => "showScopedLabels(list.label)",
":scoped-labels-documentation-link" => "helpLink" }
- if can?(current_user, :admin_list, current_board_parent) - if can?(current_user, :admin_list, current_board_parent)
%board-delete{ "inline-template" => true, %board-delete{ "inline-template" => true,
......
...@@ -8,19 +8,13 @@ ...@@ -8,19 +8,13 @@
%span.no-value{ "v-if" => "issue.labels && issue.labels.length === 0" } %span.no-value{ "v-if" => "issue.labels && issue.labels.length === 0" }
= _("None") = _("None")
%span{ "v-for" => "label in issue.labels" } %span{ "v-for" => "label in issue.labels" }
%span.d-inline-block.position-relative.scoped-label-wrapper{ "v-if" => "showScopedLabels(label)" } %gl-label{ ":id" => "label.id",
%span.gl-label.gl-label-scoped{ ":style" => "{ borderColor: label.color }" } ":key" => "label.id",
%a.gl-link.gl-label-link{ href: '#' } ":background-color" => "label.color",
%span.gl-label-text{ ":style" => "{ backgroundColor: label.color, color: label.textColor }" } ":title" => "label.title",
{{ scopedLabelScope(label) }} ":description" => "label.description",
%span.gl-label-text{ ":style" => "{ backgroundColor: label.textColor, color: label.Color }" } ":scoped" => "showScopedLabels(label)",
{{ scopedValue(label) }} ":scoped-labels-documentation-link" => "helpLink" }
%a.label.scoped-label.gl-link.gl-label-icon{ ":href" => "helpLink()" }
%i.fa.fa-question-circle
%span.gl-label{ "v-else" => true }
%a.gl-link.gl-label-link{ href: "#" }
%span.gl-label-text{ ":style" => "{ backgroundColor: label.color, color: label.textColor }" }
{{ label.title }}
- if can_admin_issue? - if can_admin_issue?
.selectbox .selectbox
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
%span.issuable-number= issuable.to_reference %span.issuable-number= issuable.to_reference
- labels.each do |label| - labels.each do |label|
= render_label(label.present(issuable_subject: project), link: polymorphic_path(issuable_type_args, { milestone_title: @milestone.title, label_name: label.title, state: 'all' })) = render_label(label.present(issuable_subject: project), link: polymorphic_path(issuable_type_args, { milestone_title: @milestone.title, label_name: label.title, state: 'all' }), small: true)
%span.assignee-icon %span.assignee-icon
- assignees.each do |assignee| - assignees.each do |assignee|
......
...@@ -3,11 +3,9 @@ ...@@ -3,11 +3,9 @@
- options = { milestone_title: @milestone.title, label_name: label.title } - options = { milestone_title: @milestone.title, label_name: label.title }
%li.no-border %li.no-border
%span.label-row = render_label(label, tooltip: false, link: milestones_label_path(options))
%span.label-name %span.prepend-description-left
= render_label(label, tooltip: false, link: milestones_label_path(options)) = markdown_field(label, :description)
%span.prepend-description-left
= markdown_field(label, :description)
.float-right.d-none.d-lg-block.d-xl-block .float-right.d-none.d-lg-block.d-xl-block
= link_to milestones_label_path(options.merge(state: 'opened')), class: 'btn btn-transparent btn-action' do = link_to milestones_label_path(options.merge(state: 'opened')), class: 'btn btn-transparent btn-action' do
......
---
title: New styles for scoped labels
merge_request: 21377
author:
type: changed
...@@ -8,17 +8,63 @@ module EE ...@@ -8,17 +8,63 @@ module EE
singleton_class.prepend self singleton_class.prepend self
end end
def render_label(label, tooltip: true, link: nil, css: nil, dataset: nil) def render_label(label, tooltip: true, link: nil, dataset: nil, small: false)
content = super if label.scoped_label?
content = scoped_label_wrapper(content, label) if label.scoped_label? render_scoped_label(
label,
link: link,
css: label_css_classes(tooltip),
dataset: label_dataset(label, dataset, tooltip),
small: small
)
else
super
end
end
def render_scoped_label(label, link: nil, css: nil, dataset: nil, small: false)
# if scoped label is used then EE wraps label tag with scoped label
# doc link
size_class = small ? "gl-label-sm" : ""
html = render_colored_scoped_label(label)
html = link_to(html, link, class: css, data: dataset) if link
html = %(<span class="gl-label gl-label-scoped #{size_class}" style="color: #{label.color}">#{html}</span>)
wrapped_html = scoped_label_wrapper(html, label)
content wrapped_html.html_safe
end
def render_colored_scoped_label(label, label_suffix: '')
text_color_class = ::LabelsHelper.text_color_class_for_bg(label.color)
scope_name, label_name = label.name.split(Label::SCOPED_LABEL_SEPARATOR)
# Intentionally not using content_tag here so that this method can be called
# by LabelReferenceFilter
# Tooltip is omitted as it's attached to the link containing label title on scoped labels
::LabelsHelper.render_partial_label(
label, label_suffix: label_suffix,
label_name: scope_name,
css_class: text_color_class,
bg_color: label.color
) + ::LabelsHelper.render_partial_label(
label, label_suffix: label_suffix,
label_name: label_name,
css_class: 'gl-label-scoped-text'
)
end end
def scoped_label_wrapper(link, label) def scoped_label_wrapper(link, label)
%(<span class="d-inline-block position-relative scoped-label-wrapper">#{link}#{scoped_labels_doc_link(label)}</span>).html_safe %(<span class="d-inline-block position-relative scoped-label-wrapper">#{link}#{scoped_labels_doc_link(label)}</span>).html_safe
end end
def scoped_labels_doc_link(label)
content = %(<i class="fa fa-question-circle"></i>)
help_url = ::Gitlab::Routing.url_helpers.help_page_url('user/project/labels.md', anchor: 'scoped-labels')
%(<a href="#{help_url}" class="label scoped-label gl-link gl-label-icon" target="_blank" rel="noopener">#{content}</a>)
end
def label_tooltip_title(label) def label_tooltip_title(label)
tooltip = super tooltip = super
tooltip = %(<span class='font-weight-bold scoped-label-tooltip-title'>Scoped label</span><br />#{tooltip}) if label.scoped_label? tooltip = %(<span class='font-weight-bold scoped-label-tooltip-title'>Scoped label</span><br />#{tooltip}) if label.scoped_label?
...@@ -55,8 +101,6 @@ module EE ...@@ -55,8 +101,6 @@ module EE
super + ['epics'] super + ['epics']
end end
private
def scoped_labels_doc_link(label) def scoped_labels_doc_link(label)
text_color = text_color_for_bg(label.color) text_color = text_color_for_bg(label.color)
content = %(<i class="fa fa-question-circle" style="background-color: #{label.color}; color: #{text_color}"></i>) content = %(<i class="fa fa-question-circle" style="background-color: #{label.color}; color: #{text_color}"></i>)
...@@ -64,5 +108,7 @@ module EE ...@@ -64,5 +108,7 @@ module EE
%(<a href="#{help_url}" class="label scoped-label" target="_blank" rel="noopener">#{content}</a>) %(<a href="#{help_url}" class="label scoped-label" target="_blank" rel="noopener">#{content}</a>)
end end
module_function :render_colored_scoped_label, :scoped_label_wrapper, :scoped_labels_doc_link, :label_tooltip_title
end end
end end
...@@ -4,7 +4,8 @@ module EE ...@@ -4,7 +4,8 @@ module EE
module Label module Label
extend ActiveSupport::Concern extend ActiveSupport::Concern
SCOPED_LABEL_PATTERN = /^.*::/.freeze SCOPED_LABEL_SEPARATOR = '::'
SCOPED_LABEL_PATTERN = /^.*#{SCOPED_LABEL_SEPARATOR}/.freeze
def scoped_label? def scoped_label?
SCOPED_LABEL_PATTERN.match?(name) SCOPED_LABEL_PATTERN.match?(name)
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
- if epic.labels.any? - if epic.labels.any?
&nbsp; &nbsp;
- epic.labels.each do |label| - epic.labels.each do |label|
= render_label(label.present(issuable_subject: @group), tooltip: true, link: group_epics_path(@group, label_name:[label.name]), css: 'label-link') = render_label(label.present(issuable_subject: @group), tooltip: true, link: group_epics_path(@group, label_name:[label.name]), small: true)
.issuable-meta .issuable-meta
%ul.controls %ul.controls
......
...@@ -6,6 +6,20 @@ module EE ...@@ -6,6 +6,20 @@ module EE
module LabelReferenceFilter module LabelReferenceFilter
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
override :object_link_text
def object_link_text(object, matches)
presenter = label_link_text(object, matches)
label_suffix = label_link_suffix(object, matches)
content = if object.scoped_label?
::EE::LabelsHelper.render_colored_scoped_label(presenter, label_suffix: label_suffix)
else
::LabelsHelper.render_colored_label(presenter, label_suffix: label_suffix)
end
content
end
override :wrap_link override :wrap_link
def wrap_link(link, label) def wrap_link(link, label)
content = super content = super
...@@ -13,7 +27,8 @@ module EE ...@@ -13,7 +27,8 @@ module EE
if label.scoped_label? && parent && parent.feature_available?(:scoped_labels) if label.scoped_label? && parent && parent.feature_available?(:scoped_labels)
presenter = label.present(issuable_parent: parent) presenter = label.present(issuable_parent: parent)
content = ::LabelsHelper.scoped_label_wrapper(content, presenter) content = %(<span class="gl-label gl-label-scoped gl-label-sm" style="color: #{label.color}">#{link}</span>)
content = ::EE::LabelsHelper.scoped_label_wrapper(content, presenter)
end end
content content
...@@ -22,6 +37,10 @@ module EE ...@@ -22,6 +37,10 @@ module EE
def tooltip_title(label) def tooltip_title(label)
::LabelsHelper.label_tooltip_title(label) ::LabelsHelper.label_tooltip_title(label)
end end
def object_link_title(object, matches)
::EE::LabelsHelper.label_tooltip_title(object)
end
end end
end end
end end
......
...@@ -263,6 +263,9 @@ describe 'Issue Boards', :js do ...@@ -263,6 +263,9 @@ describe 'Issue Boards', :js do
end end
it 'removes existing scoped label' do it 'removes existing scoped label' do
scoped1 = scoped_label_1.title.split('::')
scoped2 = scoped_label_2.title.split('::')
click_card(card1) click_card(card1)
page.within('.labels') do page.within('.labels') do
...@@ -281,9 +284,10 @@ describe 'Issue Boards', :js do ...@@ -281,9 +284,10 @@ describe 'Issue Boards', :js do
find('.dropdown-menu-close-icon').click find('.dropdown-menu-close-icon').click
page.within('.value') do page.within('.value') do
expect(page).to have_selector('.scoped-label-wrapper', count: 1) expect(page).to have_selector('.gl-label-scoped', count: 1)
expect(page).not_to have_content(scoped_label_1.title) expect(page).not_to have_content(scoped1.last)
expect(page).to have_content(scoped_label_2.title) expect(page).to have_content(scoped2.first)
expect(page).to have_content(scoped2.last)
end end
end end
......
...@@ -14,11 +14,12 @@ describe LabelsHelper do ...@@ -14,11 +14,12 @@ describe LabelsHelper do
end end
it 'includes link to scoped labels documentation' do it 'includes link to scoped labels documentation' do
expect(render_label(scoped_label)).to match(%r(<span.+>#{scoped_label.name}</span><a.+>.*question-circle.*</a>)) scoped = scoped_label.title.split('::')
expect(render_label(scoped_label)).to match(%r(<span.+><span.+><span.+>#{scoped.first}</span><span.+>#{scoped.last}</span></span><a.+>.*question-circle.*</a></span>$))
end end
it 'does not include link to scoped label documentation for common labels' do it 'does not include link to scoped label documentation for common labels' do
expect(render_label(label)).to match(%r(<span.+>#{label.name}</span>$)) expect(render_label(label)).to match(%r(<span.+><span.+>#{label.name}</span></span>$))
end end
end end
...@@ -28,7 +29,7 @@ describe LabelsHelper do ...@@ -28,7 +29,7 @@ describe LabelsHelper do
end end
it 'does not include link to scoped documentation' do it 'does not include link to scoped documentation' do
expect(render_label(scoped_label)).to match(%r(<span.+>#{scoped_label.name}</span>$)) expect(render_label(scoped_label)).to match(%r(<span.+><span.+>#{scoped_label.name}</span></span>$))
end end
end end
end end
......
...@@ -16,14 +16,15 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -16,14 +16,15 @@ describe Banzai::Filter::LabelReferenceFilter do
it 'includes link to scoped documentation' do it 'includes link to scoped documentation' do
doc = reference_filter("See #{scoped_label.to_reference}") doc = reference_filter("See #{scoped_label.to_reference}")
scoped = scoped_label.name.split('::')
expect(doc.to_html).to match(%r(<a.+><span.+>#{scoped_label.name}</span></a><a.+>.*question-circle.*</a>)) expect(doc.to_html).to match(%r(<span.+><a.+><span.+>#{scoped.first}</span><span.+>#{scoped.last}</span></a></span><a.+>.*question-circle.*</a>))
end end
it 'does not include link to scoped documentation for common labels' do it 'does not include link to scoped documentation for common labels' do
doc = reference_filter("See #{label.to_reference}") doc = reference_filter("See #{label.to_reference}")
expect(doc.to_html).to match(%r(<a.+><span.+>#{label.name}</span></a>$)) expect(doc.to_html).to match(%r(<span.+><a.+><span.+>#{label.name}</span></a></span>$))
end end
end end
...@@ -34,8 +35,9 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -34,8 +35,9 @@ describe Banzai::Filter::LabelReferenceFilter do
it 'does not include link to scoped labels documentation' do it 'does not include link to scoped labels documentation' do
doc = reference_filter("See #{scoped_label.to_reference}") doc = reference_filter("See #{scoped_label.to_reference}")
scoped = scoped_label.name.split('::')
expect(doc.to_html).to match(%r(<a.+><span.+>#{scoped_label.name}</span></a>$)) expect(doc.to_html).to match(%r(<span.+><a.+><span.+>#{scoped.first}</span><span.+>#{scoped.last}</span></a></span>$))
end end
end end
end end
...@@ -80,7 +80,15 @@ module Banzai ...@@ -80,7 +80,15 @@ module Banzai
end end
end end
def object_link_text(object, matches) def label_link_text(object, matches)
parent = project || group
presenter = object.present(issuable_subject: parent)
presenter
end
def label_link_suffix(object, matches)
label_suffix = '' label_suffix = ''
parent = project || group parent = project || group
...@@ -92,8 +100,20 @@ module Banzai ...@@ -92,8 +100,20 @@ module Banzai
label_suffix = " <i>in #{ERB::Util.html_escape(reference)}</i>" if reference.present? label_suffix = " <i>in #{ERB::Util.html_escape(reference)}</i>" if reference.present?
end end
presenter = object.present(issuable_subject: parent) label_suffix
LabelsHelper.render_colored_label(presenter, label_suffix: label_suffix, title: tooltip_title(presenter)) end
def object_link_text(object, matches)
presenter = label_link_text(object, matches)
label_suffix = label_link_suffix(object, matches)
LabelsHelper.render_colored_label(presenter, label_suffix: label_suffix)
end
def wrap_link(link, label)
content = super
content = %(<span class="gl-label gl-label-sm">#{content}</span>)
content
end end
def tooltip_title(label) def tooltip_title(label)
...@@ -104,9 +124,12 @@ module Banzai ...@@ -104,9 +124,12 @@ module Banzai
matches[:namespace] && matches[:project] matches[:namespace] && matches[:project]
end end
def reference_class(type, tooltip: true)
super + ' gl-link gl-label-link'
end
def object_link_title(object, matches) def object_link_title(object, matches)
# use title of wrapped element instead LabelsHelper.label_tooltip_title(object)
nil
end end
end end
end end
......
...@@ -37,7 +37,8 @@ module Banzai ...@@ -37,7 +37,8 @@ module Banzai
attributes[:reference_type] ||= self.class.reference_type attributes[:reference_type] ||= self.class.reference_type
attributes[:container] ||= 'body' attributes[:container] ||= 'body'
attributes[:placement] ||= 'bottom' attributes[:placement] ||= 'top'
attributes[:html] ||= 'true'
attributes.delete(:original) if context[:no_original_data] attributes.delete(:original) if context[:no_original_data]
attributes.map do |key, value| attributes.map do |key, value|
%Q(data-#{key.to_s.dasherize}="#{escape_once(value)}") %Q(data-#{key.to_s.dasherize}="#{escape_once(value)}")
......
...@@ -277,7 +277,7 @@ describe 'Issue Boards', :js do ...@@ -277,7 +277,7 @@ describe 'Issue Boards', :js do
wait_for_requests wait_for_requests
page.within('.value') do page.within('.value') do
expect(page).to have_selector('.badge', count: 2) expect(page).to have_selector('.gl-label-text', count: 2)
expect(page).to have_content(development.title) expect(page).to have_content(development.title)
expect(page).to have_content(stretch.title) expect(page).to have_content(stretch.title)
end end
...@@ -299,7 +299,7 @@ describe 'Issue Boards', :js do ...@@ -299,7 +299,7 @@ describe 'Issue Boards', :js do
find('.dropdown-menu-close-icon').click find('.dropdown-menu-close-icon').click
page.within('.value') do page.within('.value') do
expect(page).to have_selector('.badge', count: 3) expect(page).to have_selector('.gl-label-text', count: 3)
expect(page).to have_content(bug.title) expect(page).to have_content(bug.title)
end end
end end
...@@ -328,7 +328,7 @@ describe 'Issue Boards', :js do ...@@ -328,7 +328,7 @@ describe 'Issue Boards', :js do
find('.dropdown-menu-close-icon').click find('.dropdown-menu-close-icon').click
page.within('.value') do page.within('.value') do
expect(page).to have_selector('.badge', count: 4) expect(page).to have_selector('.gl-label-text', count: 4)
expect(page).to have_content(bug.title) expect(page).to have_content(bug.title)
expect(page).to have_content(regression.title) expect(page).to have_content(regression.title)
end end
...@@ -357,13 +357,13 @@ describe 'Issue Boards', :js do ...@@ -357,13 +357,13 @@ describe 'Issue Boards', :js do
find('.dropdown-menu-close-icon').click find('.dropdown-menu-close-icon').click
page.within('.value') do page.within('.value') do
expect(page).to have_selector('.badge', count: 1) expect(page).to have_selector('.gl-label-text', count: 1)
expect(page).not_to have_content(stretch.title) expect(page).not_to have_content(stretch.title)
end end
end end
# 'Development' label does not show since the card is in a 'Development' list label # 'Development' label does not show since the card is in a 'Development' list label
expect(card).to have_selector('.badge', count: 0) expect(card).to have_selector('.gl-label-text', count: 0)
expect(card).not_to have_content(stretch.title) expect(card).not_to have_content(stretch.title)
end end
......
...@@ -41,10 +41,10 @@ describe 'issuable list' do ...@@ -41,10 +41,10 @@ describe 'issuable list' do
visit_issuable_list(issuable_type) visit_issuable_list(issuable_type)
expect(all('.label-link')[0].text).to have_content('B') expect(all('.gl-label-text')[0].text).to have_content('B')
expect(all('.label-link')[1].text).to have_content('X') expect(all('.gl-label-text')[1].text).to have_content('X')
expect(all('.label-link')[2].text).to have_content('a') expect(all('.gl-label-text')[2].text).to have_content('a')
expect(all('.label-link')[3].text).to have_content('z') expect(all('.gl-label-text')[3].text).to have_content('z')
end end
end end
......
...@@ -332,7 +332,7 @@ describe 'Filter issues', :js do ...@@ -332,7 +332,7 @@ describe 'Filter issues', :js do
context 'issue label clicked' do context 'issue label clicked' do
it 'filters and displays in search bar' do it 'filters and displays in search bar' do
find('.issues-list .issue .issuable-main-info .issuable-info a .badge', text: multiple_words_label.title).click find('.issues-list .issue .issuable-main-info .issuable-info a .gl-label-text', text: multiple_words_label.title).click
expect_issues_list_count(1) expect_issues_list_count(1)
expect_tokens([label_token("\"#{multiple_words_label.title}\"")]) expect_tokens([label_token("\"#{multiple_words_label.title}\"")])
......
...@@ -161,9 +161,9 @@ describe 'Labels Hierarchy', :js do ...@@ -161,9 +161,9 @@ describe 'Labels Hierarchy', :js do
find('.btn-success').click find('.btn-success').click
expect(page.find('.issue-details h2.title')).to have_content('new created issue') expect(page.find('.issue-details h2.title')).to have_content('new created issue')
expect(page).to have_selector('span.badge', text: grandparent_group_label.title) expect(page).to have_selector('span.gl-label-text', text: grandparent_group_label.title)
expect(page).to have_selector('span.badge', text: parent_group_label.title) expect(page).to have_selector('span.gl-label-text', text: parent_group_label.title)
expect(page).to have_selector('span.badge', text: project_label_1.title) expect(page).to have_selector('span.gl-label-text', text: project_label_1.title)
end end
end end
......
...@@ -56,7 +56,7 @@ describe LabelsHelper do ...@@ -56,7 +56,7 @@ describe LabelsHelper do
context 'without subject' do context 'without subject' do
it "uses the label's project" do it "uses the label's project" do
expect(link_to_label(label_presenter)).to match %r{<a href="/#{label.project.full_path}/issues\?label_name%5B%5D=#{label.name}">.*</a>} expect(link_to_label(label_presenter)).to match %r{<a.*href="/#{label.project.full_path}/issues\?label_name%5B%5D=#{label.name}".*>.*</a>}
end end
end end
...@@ -65,7 +65,7 @@ describe LabelsHelper do ...@@ -65,7 +65,7 @@ describe LabelsHelper do
let(:subject) { build(:project, namespace: namespace, name: 'bar3') } let(:subject) { build(:project, namespace: namespace, name: 'bar3') }
it 'links to project issues page' do it 'links to project issues page' do
expect(link_to_label(label_presenter)).to match %r{<a href="/foo3/bar3/issues\?label_name%5B%5D=#{label.name}">.*</a>} expect(link_to_label(label_presenter)).to match %r{<a.*href="/foo3/bar3/issues\?label_name%5B%5D=#{label.name}".*>.*</a>}
end end
end end
...@@ -73,7 +73,7 @@ describe LabelsHelper do ...@@ -73,7 +73,7 @@ describe LabelsHelper do
let(:subject) { build(:group, name: 'bar') } let(:subject) { build(:group, name: 'bar') }
it 'links to group issues page' do it 'links to group issues page' do
expect(link_to_label(label_presenter)).to match %r{<a href="/groups/bar/-/issues\?label_name%5B%5D=#{label.name}">.*</a>} expect(link_to_label(label_presenter)).to match %r{<a.*href="/groups/bar/-/issues\?label_name%5B%5D=#{label.name}".*>.*</a>}
end end
end end
...@@ -81,7 +81,7 @@ describe LabelsHelper do ...@@ -81,7 +81,7 @@ describe LabelsHelper do
['issue', :issue].each do |type| ['issue', :issue].each do |type|
context "set to #{type}" do context "set to #{type}" do
it 'links to correct page' do it 'links to correct page' do
expect(link_to_label(label_presenter, type: type)).to match %r{<a href="/#{label.project.full_path}/#{type.to_s.pluralize}\?label_name%5B%5D=#{label.name}">.*</a>} expect(link_to_label(label_presenter, type: type)).to match %r{<a.*href="/#{label.project.full_path}/#{type.to_s.pluralize}\?label_name%5B%5D=#{label.name}".*>.*</a>}
end end
end end
end end
...@@ -89,7 +89,7 @@ describe LabelsHelper do ...@@ -89,7 +89,7 @@ describe LabelsHelper do
['merge_request', :merge_request].each do |type| ['merge_request', :merge_request].each do |type|
context "set to #{type}" do context "set to #{type}" do
it 'links to correct page' do it 'links to correct page' do
expect(link_to_label(label_presenter, type: type)).to match %r{<a href="/#{label.project.full_path}/-/#{type.to_s.pluralize}\?label_name%5B%5D=#{label.name}">.*</a>} expect(link_to_label(label_presenter, type: type)).to match %r{<a.*href="/#{label.project.full_path}/-/#{type.to_s.pluralize}\?label_name%5B%5D=#{label.name}".*>.*</a>}
end end
end end
end end
...@@ -113,7 +113,7 @@ describe LabelsHelper do ...@@ -113,7 +113,7 @@ describe LabelsHelper do
context 'without block' do context 'without block' do
it 'uses render_colored_label as the link content' do it 'uses render_colored_label as the link content' do
expect(self).to receive(:render_colored_label) expect(self).to receive(:render_colored_label)
.with(label_presenter, tooltip: true).and_return('Foo') .with(label_presenter).and_return('Foo')
expect(link_to_label(label_presenter)).to match('Foo') expect(link_to_label(label_presenter)).to match('Foo')
end end
end end
......
...@@ -537,8 +537,10 @@ describe MarkupHelper do ...@@ -537,8 +537,10 @@ describe MarkupHelper do
it 'does not style a label that can not be accessed by current_user' do it 'does not style a label that can not be accessed by current_user' do
project = create(:project, :private) project = create(:project, :private)
label = create_and_format_label(project)
expect(create_and_format_label(project)).to eq("<p>#{label_title}</p>") expect(label).to include("~label_1")
expect(label).not_to match(/span class=.*style=.*/)
end end
end end
......
...@@ -28,7 +28,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -28,7 +28,7 @@ describe Banzai::Filter::LabelReferenceFilter do
it 'includes default classes' do it 'includes default classes' do
doc = reference_filter("Label #{reference}") doc = reference_filter("Label #{reference}")
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-label has-tooltip' expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-label has-tooltip gl-link gl-label-link'
end end
it 'includes a data-project attribute' do it 'includes a data-project attribute' do
...@@ -66,12 +66,12 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -66,12 +66,12 @@ describe Banzai::Filter::LabelReferenceFilter do
describe 'label span element' do describe 'label span element' do
it 'includes default classes' do it 'includes default classes' do
doc = reference_filter("Label #{reference}") doc = reference_filter("Label #{reference}")
expect(doc.css('a span').first.attr('class')).to eq 'badge color-label has-tooltip' expect(doc.css('a span').first.attr('class')).to include 'gl-label-text'
end end
it 'includes a style attribute' do it 'includes a style attribute' do
doc = reference_filter("Label #{reference}") doc = reference_filter("Label #{reference}")
expect(doc.css('a span').first.attr('style')).to match(/\Abackground-color: #\h{6}; color: #\h{6}\z/) expect(doc.css('a span').first.attr('style')).to match(/\Abackground-color: #\h{6}\z/)
end end
end end
...@@ -85,7 +85,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -85,7 +85,7 @@ describe Banzai::Filter::LabelReferenceFilter do
it 'links with adjacent text' do it 'links with adjacent text' do
doc = reference_filter("Label (#{reference}.)") doc = reference_filter("Label (#{reference}.)")
expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\.\))) expect(doc.to_html).to match(%r(\(<span.+><a.+><span.+>#{label.name}</span></a></span>\.\)))
end end
it 'ignores invalid label IDs' do it 'ignores invalid label IDs' do
...@@ -109,7 +109,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -109,7 +109,7 @@ describe Banzai::Filter::LabelReferenceFilter do
it 'links with adjacent text' do it 'links with adjacent text' do
doc = reference_filter("Label (#{reference}).") doc = reference_filter("Label (#{reference}).")
expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\)\.)) expect(doc.to_html).to match(%r(\(<span.+><a.+><span.+>#{label.name}</span></a></span>\)\.))
end end
it 'ignores invalid label names' do it 'ignores invalid label names' do
...@@ -133,7 +133,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -133,7 +133,7 @@ describe Banzai::Filter::LabelReferenceFilter do
it 'links with adjacent text' do it 'links with adjacent text' do
doc = reference_filter("Label (#{reference}).") doc = reference_filter("Label (#{reference}).")
expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\)\.)) expect(doc.to_html).to match(%r(\(<span.+><a.+><span.+>#{label.name}</span></a></span>\)\.))
end end
it 'ignores invalid label names' do it 'ignores invalid label names' do
...@@ -158,7 +158,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -158,7 +158,7 @@ describe Banzai::Filter::LabelReferenceFilter do
it 'does not include trailing punctuation', :aggregate_failures do it 'does not include trailing punctuation', :aggregate_failures do
['.', ', ok?', '...', '?', '!', ': is that ok?'].each do |trailing_punctuation| ['.', ', ok?', '...', '?', '!', ': is that ok?'].each do |trailing_punctuation|
doc = filter("Label #{reference}#{trailing_punctuation}") doc = filter("Label #{reference}#{trailing_punctuation}")
expect(doc.to_html).to match(%r(<a.+><span.+>\?g\.fm&amp;</span></a>#{Regexp.escape(trailing_punctuation)})) expect(doc.to_html).to match(%r(<span.+><a.+><span.+>\?g\.fm&amp;</span></a></span>#{Regexp.escape(trailing_punctuation)}))
end end
end end
...@@ -184,7 +184,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -184,7 +184,7 @@ describe Banzai::Filter::LabelReferenceFilter do
it 'links with adjacent text' do it 'links with adjacent text' do
doc = reference_filter("Label (#{reference}.)") doc = reference_filter("Label (#{reference}.)")
expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\.\))) expect(doc.to_html).to match(%r(\(<span.+><a.+><span.+>#{label.name}</span></a></span>\.\)))
end end
it 'ignores invalid label names' do it 'ignores invalid label names' do
...@@ -208,7 +208,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -208,7 +208,7 @@ describe Banzai::Filter::LabelReferenceFilter do
it 'links with adjacent text' do it 'links with adjacent text' do
doc = reference_filter("Label (#{reference}.)") doc = reference_filter("Label (#{reference}.)")
expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\.\))) expect(doc.to_html).to match(%r(\(<span.+><a.+><span.+>#{label.name}</span></a></span>\.\)))
end end
it 'ignores invalid label names' do it 'ignores invalid label names' do
...@@ -232,7 +232,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -232,7 +232,7 @@ describe Banzai::Filter::LabelReferenceFilter do
it 'links with adjacent text' do it 'links with adjacent text' do
doc = reference_filter("Label (#{reference}.)") doc = reference_filter("Label (#{reference}.)")
expect(doc.to_html).to match(%r(\(<a.+><span.+>g\.fm &amp; references\?</span></a>\.\))) expect(doc.to_html).to match(%r(\(<span.+><a.+><span.+>g\.fm &amp; references\?</span></a></span>\.\)))
end end
it 'ignores invalid label names' do it 'ignores invalid label names' do
...@@ -320,7 +320,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -320,7 +320,7 @@ describe Banzai::Filter::LabelReferenceFilter do
it 'links with adjacent text' do it 'links with adjacent text' do
doc = reference_filter("Label (#{reference}.)") doc = reference_filter("Label (#{reference}.)")
expect(doc.to_html).to match(%r(\(<a.+>Label</a>\.\))) expect(doc.to_html).to match(%r(\(<span.+><a.+>Label</a></span>\.\)))
end end
it 'includes a data-project attribute' do it 'includes a data-project attribute' do
...@@ -358,7 +358,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -358,7 +358,7 @@ describe Banzai::Filter::LabelReferenceFilter do
it 'links with adjacent text' do it 'links with adjacent text' do
doc = reference_filter("Label (#{reference}.)") doc = reference_filter("Label (#{reference}.)")
expect(doc.to_html).to match(%r(\(<a.+><span.+>#{group_label.name}</span></a>\.\))) expect(doc.to_html).to match(%r(\(<span.+><a.+><span.+>#{group_label.name}</span></a></span>\.\)))
end end
it 'ignores invalid label names' do it 'ignores invalid label names' do
...@@ -381,7 +381,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -381,7 +381,7 @@ describe Banzai::Filter::LabelReferenceFilter do
it 'links with adjacent text' do it 'links with adjacent text' do
doc = reference_filter("Label (#{reference}.)") doc = reference_filter("Label (#{reference}.)")
expect(doc.to_html).to match(%r(\(<a.+><span.+>#{group_label.name}</span></a>\.\))) expect(doc.to_html).to match(%r(\(<span.+><a.+><span.+>#{group_label.name}</span></a></span>\.\)))
end end
it 'ignores invalid label names' do it 'ignores invalid label names' do
......
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