Commit 29916662 authored by Coung Ngo's avatar Coung Ngo Committed by Mark Chao

Show origin path of labels on subgroup labels page

Show origin path so that users can see from where labels
were created on the subgroup labels page
parent 35032389
...@@ -264,6 +264,10 @@ module LabelsHelper ...@@ -264,6 +264,10 @@ module LabelsHelper
['issues', 'merge requests'] ['issues', 'merge requests']
end end
def show_labels_full_path?(project, group)
project || group&.subgroup?
end
private private
def render_label_link(label_html, link:, title:, dataset:) def render_label_link(label_html, link:, title:, dataset:)
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
.description-text.gl-flex-grow-1.gl-overflow-hidden .description-text.gl-flex-grow-1.gl-overflow-hidden
- if label.description.present? - if label.description.present?
= markdown_field(label, :description) = markdown_field(label, :description)
- elsif @project - elsif show_labels_full_path?(@project, @group)
= render 'shared/label_full_path', label: label = render 'shared/label_full_path', label: label
%ul.label-links.gl-m-0.gl-p-0.gl-white-space-nowrap %ul.label-links.gl-m-0.gl-p-0.gl-white-space-nowrap
- if show_label_issues_link - if show_label_issues_link
...@@ -25,6 +25,6 @@ ...@@ -25,6 +25,6 @@
· ·
%li.js-priority-badge.inline.gl-ml-3 %li.js-priority-badge.inline.gl-ml-3
.label-badge.gl-bg-blue-50= _('Prioritized label') .label-badge.gl-bg-blue-50= _('Prioritized label')
- if @project && label.description.present? - if label.description.present? && show_labels_full_path?(@project, @group)
.gl-mt-3 .gl-mt-3
= render 'shared/label_full_path', label: label = render 'shared/label_full_path', label: label
---
title: Show origin path of labels on subgroup labels page
merge_request: 45040
author:
type: added
...@@ -291,4 +291,34 @@ RSpec.describe LabelsHelper do ...@@ -291,4 +291,34 @@ RSpec.describe LabelsHelper do
expect(tooltip).to eq('This is an image') expect(tooltip).to eq('This is an image')
end end
end end
describe '#show_labels_full_path?' do
let_it_be(:group) { create(:group) }
let_it_be(:subgroup) { create(:group, parent: group) }
let_it_be(:project) { create(:project, group: group) }
context 'within a project' do
it 'returns truthy' do
expect(show_labels_full_path?(project, nil)).to be_truthy
end
end
context 'within a subgroup' do
it 'returns truthy' do
expect(show_labels_full_path?(nil, subgroup)).to be_truthy
end
end
context 'within a group' do
it 'returns falsey' do
expect(show_labels_full_path?(nil, group)).to be_falsey
end
end
context 'within the admin area' do
it 'returns falsey' do
expect(show_labels_full_path?(nil, nil)).to be_falsey
end
end
end
end end
...@@ -19,23 +19,58 @@ RSpec.describe 'shared/_label_row.html.haml' do ...@@ -19,23 +19,58 @@ RSpec.describe 'shared/_label_row.html.haml' do
render render
end end
it 'has label title' do
expect(rendered).to have_text(label.title)
end
it 'has a non-linked label title' do it 'has a non-linked label title' do
expect(rendered).not_to have_css('a', text: label.title) expect(rendered).not_to have_link(label.title)
end end
it "has Issues link" do it 'has Issues link' do
expect(rendered).to have_css('a', text: 'Issues') expect(rendered).to have_link('Issues')
end end
it "has Merge request link" do it 'has Merge request link' do
expect(rendered).to have_css('a', text: 'Merge requests') expect(rendered).to have_link('Merge requests')
end end
it "shows the path from where the label was created" do it 'shows the path from where the label was created' do
expect(rendered).to have_css('.label-badge', text: project.full_name) expect(rendered).to have_css('.label-badge', text: project.full_name)
end end
end end
context 'with a subgroup context' do
let_it_be(:subgroup) { create(:group, parent: group) }
let(:label) { build_stubbed(:group_label, group: subgroup).present(issuable_subject: subgroup) }
before do
assign(:group, label.group)
render
end
it 'has label title' do
expect(rendered).to have_text(label.title)
end
it 'has a non-linked label title' do
expect(rendered).not_to have_link(label.title)
end
it 'has Issues link' do
expect(rendered).to have_link('Issues')
end
it 'has Merge request link' do
expect(rendered).to have_link('Merge requests')
end
it 'shows the path from where the label was created' do
expect(rendered).to have_css('.label-badge', text: subgroup.full_name)
end
end
context 'with a group context' do context 'with a group context' do
before do before do
assign(:group, label.group) assign(:group, label.group)
...@@ -43,19 +78,23 @@ RSpec.describe 'shared/_label_row.html.haml' do ...@@ -43,19 +78,23 @@ RSpec.describe 'shared/_label_row.html.haml' do
render render
end end
it 'has label title' do
expect(rendered).to have_text(label.title)
end
it 'has a non-linked label title' do it 'has a non-linked label title' do
expect(rendered).not_to have_css('a', text: label.title) expect(rendered).not_to have_link(label.title)
end end
it "has Issues link" do it 'has Issues link' do
expect(rendered).to have_css('a', text: 'Issues') expect(rendered).to have_link('Issues')
end end
it "has Merge request link" do it 'has Merge request link' do
expect(rendered).to have_css('a', text: 'Merge requests') expect(rendered).to have_link('Merge requests')
end end
it "does not show a path from where the label was created" do it 'does not show a path from where the label was created' do
expect(rendered).not_to have_css('.label-badge') expect(rendered).not_to have_css('.label-badge')
end end
end end
...@@ -65,19 +104,23 @@ RSpec.describe 'shared/_label_row.html.haml' do ...@@ -65,19 +104,23 @@ RSpec.describe 'shared/_label_row.html.haml' do
render render
end end
it 'has label title' do
expect(rendered).to have_text(label.title)
end
it 'has a non-linked label title' do it 'has a non-linked label title' do
expect(rendered).not_to have_css('a', text: label.title) expect(rendered).not_to have_link(label.title)
end end
it "does not show Issues link" do it 'does not show Issues link' do
expect(rendered).not_to have_css('a', text: 'Issues') expect(rendered).not_to have_link('Issues')
end end
it "does not show Merge request link" do it 'does not show Merge request link' do
expect(rendered).not_to have_css('a', text: 'Merge requests') expect(rendered).not_to have_link('Merge requests')
end end
it "does not show a path from where the label was created" do it 'does not show a path from where the label was created' do
expect(rendered).not_to have_css('.label-badge') expect(rendered).not_to have_css('.label-badge')
end end
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