Commit 6cbb2502 authored by Mike Greiling's avatar Mike Greiling

Merge branch '10893-hide-redundant-labels-in-issue-boards' into 'master'

Resolve "Hide redundant labels in issue boards"

See merge request gitlab-org/gitlab!17937
parents 5c08f3fa ebdfadf7
...@@ -99,7 +99,10 @@ export default { ...@@ -99,7 +99,10 @@ export default {
return !groupId ? referencePath.split('#')[0] : null; return !groupId ? referencePath.split('#')[0] : null;
}, },
orderedLabels() { orderedLabels() {
return _.sortBy(this.issue.labels, 'title'); return _.chain(this.issue.labels)
.filter(this.isNonListLabel)
.sortBy('title')
.value();
}, },
helpLink() { helpLink() {
return boardsStore.scopedLabels.helpLink; return boardsStore.scopedLabels.helpLink;
...@@ -130,6 +133,9 @@ export default { ...@@ -130,6 +133,9 @@ export default {
if (!label.id) return false; if (!label.id) return false;
return true; return true;
}, },
isNonListLabel(label) {
return label.id && !(this.list.type === 'label' && this.list.title === label.title);
},
filterByLabel(label) { filterByLabel(label) {
if (!this.updateFilters) return; if (!this.updateFilters) return;
const labelTitle = encodeURIComponent(label.title); const labelTitle = encodeURIComponent(label.title);
...@@ -167,7 +173,7 @@ export default { ...@@ -167,7 +173,7 @@ export default {
</h4> </h4>
</div> </div>
<div v-if="showLabelFooter" class="board-card-labels prepend-top-4 d-flex flex-wrap"> <div v-if="showLabelFooter" class="board-card-labels prepend-top-4 d-flex flex-wrap">
<template v-for="label in orderedLabels" v-if="showLabel(label)"> <template v-for="label in orderedLabels">
<issue-card-inner-scoped-label <issue-card-inner-scoped-label
v-if="showScopedLabel(label)" v-if="showScopedLabel(label)"
:key="label.id" :key="label.id"
......
---
title: Hide redundant labels in issue boards
merge_request: 17937
author:
type: fixed
...@@ -251,7 +251,7 @@ describe 'Issue Boards', :js do ...@@ -251,7 +251,7 @@ describe 'Issue Boards', :js do
expect(page).to have_selector(selector, text: development.title, count: 1) expect(page).to have_selector(selector, text: development.title, count: 1)
end end
it 'issue moves between lists' do it 'issue moves between lists and does not show the "Development" label since the card is in the "Development" list label' do
drag(list_from_index: 1, from_index: 1, list_to_index: 2) drag(list_from_index: 1, from_index: 1, list_to_index: 2)
wait_for_board_cards(2, 7) wait_for_board_cards(2, 7)
...@@ -259,10 +259,10 @@ describe 'Issue Boards', :js do ...@@ -259,10 +259,10 @@ describe 'Issue Boards', :js do
wait_for_board_cards(4, 1) wait_for_board_cards(4, 1)
expect(find('.board:nth-child(3)')).to have_content(issue6.title) expect(find('.board:nth-child(3)')).to have_content(issue6.title)
expect(find('.board:nth-child(3)').all('.board-card').last).to have_content(development.title) expect(find('.board:nth-child(3)').all('.board-card').last).not_to have_content(development.title)
end end
it 'issue moves between lists' do it 'issue moves between lists and does not show the "Planning" label since the card is in the "Planning" list label' do
drag(list_from_index: 2, list_to_index: 1) drag(list_from_index: 2, list_to_index: 1)
wait_for_board_cards(2, 9) wait_for_board_cards(2, 9)
...@@ -270,7 +270,7 @@ describe 'Issue Boards', :js do ...@@ -270,7 +270,7 @@ describe 'Issue Boards', :js do
wait_for_board_cards(4, 1) wait_for_board_cards(4, 1)
expect(find('.board:nth-child(2)')).to have_content(issue7.title) expect(find('.board:nth-child(2)')).to have_content(issue7.title)
expect(find('.board:nth-child(2)').all('.board-card').first).to have_content(planning.title) expect(find('.board:nth-child(2)').all('.board-card').first).not_to have_content(planning.title)
end end
it 'issue moves from closed' do it 'issue moves from closed' do
......
...@@ -304,7 +304,8 @@ describe 'Issue Boards', :js do ...@@ -304,7 +304,8 @@ describe 'Issue Boards', :js do
end end
end end
expect(card).to have_selector('.badge', count: 3) # 'Development' label does not show since the card is in a 'Development' list label
expect(card).to have_selector('.badge', count: 2)
expect(card).to have_content(bug.title) expect(card).to have_content(bug.title)
end end
...@@ -330,7 +331,8 @@ describe 'Issue Boards', :js do ...@@ -330,7 +331,8 @@ describe 'Issue Boards', :js do
end end
end end
expect(card).to have_selector('.badge', count: 4) # 'Development' label does not show since the card is in a 'Development' list label
expect(card).to have_selector('.badge', count: 3)
expect(card).to have_content(bug.title) expect(card).to have_content(bug.title)
expect(card).to have_content(regression.title) expect(card).to have_content(regression.title)
end end
...@@ -357,7 +359,8 @@ describe 'Issue Boards', :js do ...@@ -357,7 +359,8 @@ describe 'Issue Boards', :js do
end end
end end
expect(card).to have_selector('.badge', count: 1) # 'Development' label does not show since the card is in a 'Development' list label
expect(card).to have_selector('.badge', count: 0)
expect(card).not_to have_content(stretch.title) expect(card).not_to have_content(stretch.title)
end end
......
...@@ -32,7 +32,10 @@ describe('Issue card component', () => { ...@@ -32,7 +32,10 @@ describe('Issue card component', () => {
beforeEach(() => { beforeEach(() => {
setFixtures('<div class="test-container"></div>'); setFixtures('<div class="test-container"></div>');
list = listObj; list = {
...listObj,
type: 'label',
};
issue = new ListIssue({ issue = new ListIssue({
title: 'Testing', title: 'Testing',
id: 1, id: 1,
...@@ -241,8 +244,8 @@ describe('Issue card component', () => { ...@@ -241,8 +244,8 @@ describe('Issue card component', () => {
Vue.nextTick(() => done()); Vue.nextTick(() => done());
}); });
it('renders list label', () => { it('does not render list label but renders all other labels', () => {
expect(component.$el.querySelectorAll('.badge').length).toBe(2); expect(component.$el.querySelectorAll('.badge').length).toBe(1);
}); });
it('renders label', () => { it('renders label', () => {
...@@ -278,7 +281,7 @@ describe('Issue card component', () => { ...@@ -278,7 +281,7 @@ describe('Issue card component', () => {
Vue.nextTick() Vue.nextTick()
.then(() => { .then(() => {
expect(component.$el.querySelectorAll('.badge').length).toBe(2); expect(component.$el.querySelectorAll('.badge').length).toBe(1);
expect(component.$el.textContent).not.toContain('closed'); expect(component.$el.textContent).not.toContain('closed');
done(); done();
......
...@@ -15,7 +15,7 @@ export const listObj = { ...@@ -15,7 +15,7 @@ export const listObj = {
weight: 3, weight: 3,
label: { label: {
id: 5000, id: 5000,
title: 'Testing', title: 'Test',
color: 'red', color: 'red',
description: 'testing;', description: 'testing;',
textColor: 'white', textColor: 'white',
...@@ -30,7 +30,7 @@ export const listObjDuplicate = { ...@@ -30,7 +30,7 @@ export const listObjDuplicate = {
weight: 3, weight: 3,
label: { label: {
id: listObj.label.id, id: listObj.label.id,
title: 'Testing', title: 'Test',
color: 'red', color: 'red',
description: 'testing;', description: 'testing;',
}, },
......
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