Fix scoped_labels feature check
Check this feature per project/group instead of globally. Also do not show tooltip if it's disabled.
This commit is contained in:
parent
fec2e27f1d
commit
f88607923a
4 changed files with 29 additions and 5 deletions
|
@ -89,7 +89,7 @@ module LabelsHelper
|
|||
|
||||
def render_colored_label(label, label_suffix: '', tooltip: true, title: nil)
|
||||
text_color = text_color_for_bg(label.color)
|
||||
title ||= label_tooltip_title(label)
|
||||
title ||= tooltip ? label_tooltip_title(label) : ''
|
||||
|
||||
# Intentionally not using content_tag here so that this method can be called
|
||||
# by LabelReferenceFilter
|
||||
|
@ -270,6 +270,12 @@ module LabelsHelper
|
|||
})
|
||||
end
|
||||
|
||||
def label_from_hash(hash)
|
||||
klass = hash[:group_id] ? GroupLabel : ProjectLabel
|
||||
|
||||
klass.new(hash.slice(:color, :description, :title, :group_id, :project_id))
|
||||
end
|
||||
|
||||
# Required for Banzai::Filter::LabelReferenceFilter
|
||||
module_function :render_colored_label, :text_color_for_bg, :escape_once, :label_tooltip_title
|
||||
end
|
||||
|
|
|
@ -106,8 +106,7 @@
|
|||
.value.issuable-show-labels.dont-hide.hide-collapsed.qa-labels-block{ class: ("has-labels" if selected_labels.any?) }
|
||||
- if selected_labels.any?
|
||||
- selected_labels.each do |label_hash|
|
||||
- label = Label.new(label_hash.slice(:color, :description, :title))
|
||||
= render_label(label, link: sidebar_label_filter_path(issuable_sidebar[:project_issuables_path], label[:title]))
|
||||
= render_label(label_from_hash(label_hash), link: sidebar_label_filter_path(issuable_sidebar[:project_issuables_path], label_hash[:title]))
|
||||
- else
|
||||
%span.no-value
|
||||
= _('None')
|
||||
|
|
|
@ -51,6 +51,5 @@
|
|||
"toggle_subscription_path": { "type": "string" },
|
||||
"move_issue_path": { "type": "string" },
|
||||
"projects_autocomplete_path": { "type": "string" }
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,4 +249,24 @@ describe LabelsHelper do
|
|||
.to match_array([label2, label4, label1, label3])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'label_from_hash' do
|
||||
it 'builds a group label with whitelisted attributes' do
|
||||
label = label_from_hash({ title: 'foo', color: 'bar', id: 1, group_id: 1 })
|
||||
|
||||
expect(label).to be_a(GroupLabel)
|
||||
expect(label.id).to be_nil
|
||||
expect(label.title).to eq('foo')
|
||||
expect(label.color).to eq('bar')
|
||||
end
|
||||
|
||||
it 'builds a project label with whitelisted attributes' do
|
||||
label = label_from_hash({ title: 'foo', color: 'bar', id: 1, project_id: 1 })
|
||||
|
||||
expect(label).to be_a(ProjectLabel)
|
||||
expect(label.id).to be_nil
|
||||
expect(label.title).to eq('foo')
|
||||
expect(label.color).to eq('bar')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue