Commit de69f0ca authored by Ash McKenzie's avatar Ash McKenzie

Merge branch '241990-show-full-path-where-labels-come-from' into 'master'

Show labels origin path on project labels page

See merge request gitlab-org/gitlab!43858
parents 016e6c98 ac6ec268
......@@ -247,6 +247,7 @@
.label-badge {
color: $gray-900;
display: inline-block;
font-weight: $gl-font-weight-normal;
padding: $gl-padding-4 $gl-padding-8;
border-radius: $border-radius-default;
......
......@@ -2,6 +2,7 @@
class LabelPresenter < Gitlab::View::Presenter::Delegated
presents :label
delegate :name, :full_name, to: :label_subject, prefix: :subject
def edit_path
case label
......@@ -39,8 +40,8 @@ class LabelPresenter < Gitlab::View::Presenter::Delegated
label.is_a?(ProjectLabel)
end
def subject_name
label.subject.name
def label_subject
@label_subject ||= label.subject
end
private
......
......@@ -9,9 +9,6 @@
%li.label-list-item{ id: label_css_id, data: { id: label.id } }
= render "shared/label_row", label: label, force_priority: force_priority
%ul.label-actions-list
- if @project
%li.inline
.label-badge.gl-bg-gray-50= label.model_name.human.capitalize
- if can?(current_user, :admin_label, @project)
%li.inline.js-toggle-priority{ data: { url: remove_priority_project_label_path(@project, label),
dom_id: dom_id(label), type: label.type } }
......
- full_path = label.subject_full_name
.label-badge.gl-bg-gray-50.gl-max-w-full.gl-text-truncate{ title: full_path }
= full_path
......@@ -3,22 +3,28 @@
- show_label_issues_link = subject_or_group_defined && show_label_issuables_link?(label, :issues)
- show_label_merge_requests_link = subject_or_group_defined && show_label_issuables_link?(label, :merge_requests)
.label-name.gl-flex-shrink-0.gl-mr-3
.label-name.gl-flex-shrink-0.gl-mt-2.gl-mr-3
= render_label(label, tooltip: false)
.label-description.gl-flex-grow-1.gl-mr-3.gl-w-full
.label-description.gl-flex-grow-1.gl-overflow-hidden
.gl-display-flex.gl-align-items-center.gl-flex-wrap.gl-mt-2
.description-text.gl-flex-grow-1.gl-overflow-hidden
- if label.description.present?
.description-text.gl-mb-3
= markdown_field(label, :description)
- elsif @project
= render 'shared/label_full_path', label: label
%ul.label-links.gl-m-0.gl-p-0.gl-white-space-nowrap
- if show_label_issues_link
%li.inline.gl-text-blue-600
%li.inline
= link_to_label(label, css_class: 'gl-text-blue-600!') { _('Issues') }
- if show_label_merge_requests_link
&middot;
%li.inline.gl-text-blue-600
%li.inline
= link_to_label(label, type: :merge_request, css_class: 'gl-text-blue-600!') { _('Merge requests') }
= render_if_exists 'shared/label_row_epics_link', label: label
- if force_priority
&middot;
%li.js-priority-badge.inline.gl-ml-3
.label-badge.gl-bg-blue-50= _('Prioritized label')
- if @project && label.description.present?
.gl-mt-3
= render 'shared/label_full_path', label: label
---
title: Show labels origin path on project labels page
merge_request: 43858
author:
type: added
......@@ -52,8 +52,9 @@ and edit labels.
View the project labels list by going to the project and clicking **Issues > Labels**.
The list includes all labels that are defined at the project level, as well as all
labels inherited from the immediate parent group. You can filter the list by entering a search
query at the top and clicking search (**{search}**).
labels inherited from the immediate parent group.
For each label, you can see the project or group path from where it was created.
You can filter the list by entering a search query at the top and clicking search (**{search}**).
To create a new project label:
......
......@@ -91,4 +91,18 @@ RSpec.describe LabelPresenter do
it { is_expected.to eq(label.project.name) }
end
end
describe '#subject_full_name' do
context 'with group label' do
subject { group_label.subject_full_name }
it { is_expected.to eq(group_label.group.full_name) }
end
context 'with project label' do
subject { label.subject_full_name }
it { is_expected.to eq(label.project.full_name) }
end
end
end
......@@ -2,43 +2,83 @@
require 'spec_helper'
RSpec.describe 'shared/_label_row.html.haml' do
label_types = {
'project label': :label,
'group label': :group_label
}
let_it_be(:group) { create(:group) }
let(:label) { build_stubbed(:group_label, group: group).present(issuable_subject: group) }
label_types.each do |label_type, label_factory|
let!(:label) do
label_record = create(label_factory) # rubocop: disable Rails/SaveBang
label_record.present(issuable_subject: label_record.subject)
before do
allow(view).to receive(:label) { label }
end
context "for a #{label_type}" do
context 'with a project context' do
let_it_be(:project) { create(:project, group: group) }
let(:label) { build_stubbed(:label, project: project).present(issuable_subject: project) }
before do
if label.project_label?
@project = label.project
else
@group = label.group
end
assign(:project, label.project)
render
end
it 'has a non-linked label title' do
render 'shared/label_row', label: label
expect(rendered).not_to have_css('a', text: label.title)
end
it "has Issues link for #{label_type}" do
render 'shared/label_row', label: label
it "has Issues link" do
expect(rendered).to have_css('a', text: 'Issues')
end
it "has Merge request link for #{label_type}" do
render 'shared/label_row', label: label
it "has Merge request link" do
expect(rendered).to have_css('a', text: 'Merge requests')
end
it "shows the path from where the label was created" do
expect(rendered).to have_css('.label-badge', text: project.full_name)
end
end
context 'with a group context' do
before do
assign(:group, label.group)
render
end
it 'has a non-linked label title' do
expect(rendered).not_to have_css('a', text: label.title)
end
it "has Issues link" do
expect(rendered).to have_css('a', text: 'Issues')
end
it "has Merge request link" do
expect(rendered).to have_css('a', text: 'Merge requests')
end
it "does not show a path from where the label was created" do
expect(rendered).not_to have_css('.label-badge')
end
end
context 'with an admin context' do
before do
render
end
it 'has a non-linked label title' do
expect(rendered).not_to have_css('a', text: label.title)
end
it "does not show Issues link" do
expect(rendered).not_to have_css('a', text: 'Issues')
end
it "does not show Merge request link" do
expect(rendered).not_to have_css('a', text: 'Merge requests')
end
it "does not show a path from where the label was created" do
expect(rendered).not_to have_css('.label-badge')
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