Commit 83db6c76 authored by Coung Ngo's avatar Coung Ngo Committed by Savas Vedova

Add label `x` to remove labels in iteration report

In the iteration report when grouping by labels, make
it easier to remove labels. Also update the empty state text
for clarity.
parent b5273c01
...@@ -242,8 +242,10 @@ export default { ...@@ -242,8 +242,10 @@ export default {
:background-color="label.color" :background-color="label.color"
:description="label.description" :description="label.description"
:scoped="shouldShowScopedLabel(label)" :scoped="shouldShowScopedLabel(label)"
show-close-button
:target="null" :target="null"
:title="label.title" :title="label.title"
@close="$emit('removeLabel', label.id)"
/> />
<gl-badge class="gl-ml-2" size="sm" variant="muted" :aria-label="badgeAriaLabel"> <gl-badge class="gl-ml-2" size="sm" variant="muted" :aria-label="badgeAriaLabel">
{{ issues.count }} {{ issues.count }}
......
...@@ -10,6 +10,10 @@ import { GroupBy, Namespace } from '../constants'; ...@@ -10,6 +10,10 @@ import { GroupBy, Namespace } from '../constants';
import IterationReportIssues from './iteration_report_issues.vue'; import IterationReportIssues from './iteration_report_issues.vue';
export default { export default {
i18n: {
emptyStateDescription: __('Try grouping with different labels'),
emptyStateTitle: __('There are no issues with the selected labels'),
},
selectOptions: [ selectOptions: [
{ {
value: GroupBy.None, value: GroupBy.None,
...@@ -99,6 +103,10 @@ export default { ...@@ -99,6 +103,10 @@ export default {
Vue.set(this.selectedLabels, index, label); Vue.set(this.selectedLabels, index, label);
} }
}, },
handleRemoveLabel(labelId) {
const index = this.selectedLabels.findIndex((l) => l.id === labelId);
this.selectedLabels.splice(index, 1);
},
handleSelectChange() { handleSelectChange() {
if (this.groupBySelection === GroupBy.None) { if (this.groupBySelection === GroupBy.None) {
this.selectedLabels = []; this.selectedLabels = [];
...@@ -177,8 +185,9 @@ export default { ...@@ -177,8 +185,9 @@ export default {
<gl-empty-state <gl-empty-state
v-if="showEmptyState" v-if="showEmptyState"
:description="$options.i18n.emptyStateDescription"
:svg-path="svgPath" :svg-path="svgPath"
:title="__('No issues found for the selected labels')" :title="$options.i18n.emptyStateTitle"
/> />
<iteration-report-issues <iteration-report-issues
...@@ -190,6 +199,7 @@ export default { ...@@ -190,6 +199,7 @@ export default {
:iteration-id="iterationId" :iteration-id="iterationId"
:label="label" :label="label"
:namespace-type="namespaceType" :namespace-type="namespaceType"
@removeLabel="handleRemoveLabel"
@issuesUpdate="handleIssuesUpdate" @issuesUpdate="handleIssuesUpdate"
/> />
......
---
title: Add label `x` to remove labels in iteration report
merge_request: 54708
author:
type: added
...@@ -189,13 +189,11 @@ describe('Iterations report issues', () => { ...@@ -189,13 +189,11 @@ describe('Iterations report issues', () => {
it('passes prev, next, and current page props', () => { it('passes prev, next, and current page props', () => {
expect(findPagination().exists()).toBe(true); expect(findPagination().exists()).toBe(true);
expect(findPagination().props()).toEqual( expect(findPagination().props()).toMatchObject({
expect.objectContaining({ value: wrapper.vm.pagination.currentPage,
value: wrapper.vm.pagination.currentPage, prevPage: wrapper.vm.prevPage,
prevPage: wrapper.vm.prevPage, nextPage: wrapper.vm.nextPage,
nextPage: wrapper.vm.nextPage, });
}),
);
}); });
it('updates query variables when going to previous page', () => { it('updates query variables when going to previous page', () => {
...@@ -287,14 +285,19 @@ describe('Iterations report issues', () => { ...@@ -287,14 +285,19 @@ describe('Iterations report issues', () => {
}); });
it('shows label with the label title', () => { it('shows label with the label title', () => {
expect(findGlLabel().props()).toEqual( expect(findGlLabel().props()).toMatchObject({
expect.objectContaining({ backgroundColor: label.color,
backgroundColor: label.color, description: label.description,
description: label.description, showCloseButton: true,
target: null, target: null,
title: label.title, title: label.title,
}), });
); });
it('emits removeLabel event when label `x` is clicked', () => {
findGlLabel().vm.$emit('close');
expect(wrapper.emitted('removeLabel')).toEqual([[label.id]]);
}); });
it('shows badge with issue count', () => { it('shows badge with issue count', () => {
......
...@@ -167,22 +167,26 @@ describe('Iterations report tabs', () => { ...@@ -167,22 +167,26 @@ describe('Iterations report tabs', () => {
}); });
it('shows issues for `Security` label', () => { it('shows issues for `Security` label', () => {
expect(findIterationReportIssuesAt(0).props()).toMatchObject({ expect(findIterationReportIssuesAt(0).props()).toMatchObject({ label: selectedLabels[0] });
...defaultProps,
label: selectedLabels[0],
});
}); });
it('shows issues for `Tooling` label', () => { it('shows issues for `Tooling` label', () => {
expect(findIterationReportIssuesAt(1).props()).toMatchObject({ expect(findIterationReportIssuesAt(1).props()).toMatchObject({ label: selectedLabels[1] });
...defaultProps,
label: selectedLabels[1],
});
}); });
it('hides issues for the ungrouped issues list', () => { it('hides issues for the ungrouped issues list', () => {
expect(findIterationReportIssuesAt(2).isVisible()).toBe(false); expect(findIterationReportIssuesAt(2).isVisible()).toBe(false);
}); });
it('hides label issues when the label is removed', async () => {
expect(findAllIterationReportIssues()).toHaveLength(3);
await findIterationReportIssues().vm.$emit('removeLabel', selectedLabels[0].id);
expect(findAllIterationReportIssues()).toHaveLength(2);
expect(findIterationReportIssuesAt(0).props()).toMatchObject({ label: selectedLabels[1] });
expect(findIterationReportIssuesAt(1).isVisible()).toBe(false);
});
}); });
describe('when labels with issues and no issues are selected', () => { describe('when labels with issues and no issues are selected', () => {
...@@ -223,10 +227,7 @@ describe('Iterations report tabs', () => { ...@@ -223,10 +227,7 @@ describe('Iterations report tabs', () => {
}); });
it('shows issues for `Security` label', () => { it('shows issues for `Security` label', () => {
expect(findIterationReportIssuesAt(0).props()).toMatchObject({ expect(findIterationReportIssuesAt(0).props()).toMatchObject({ label: selectedLabels[0] });
...defaultProps,
label: selectedLabels[0],
});
}); });
it('hides issues for the ungrouped issues list', () => { it('hides issues for the ungrouped issues list', () => {
...@@ -262,7 +263,10 @@ describe('Iterations report tabs', () => { ...@@ -262,7 +263,10 @@ describe('Iterations report tabs', () => {
}); });
it('shows empty state', () => { it('shows empty state', () => {
expect(findEmptyState().props('title')).toBe('No issues found for the selected labels'); expect(findEmptyState().props()).toMatchObject({
description: 'Try grouping with different labels',
title: 'There are no issues with the selected labels',
});
}); });
it('shows 1 IterationReportIssues block (one for the hidden ungrouped list)', () => { it('shows 1 IterationReportIssues block (one for the hidden ungrouped list)', () => {
......
...@@ -33,4 +33,19 @@ RSpec.shared_examples 'iteration report group by label' do ...@@ -33,4 +33,19 @@ RSpec.shared_examples 'iteration report group by label' do
expect(page).to have_content(closed_issue.title) expect(page).to have_content(closed_issue.title)
expect(page).to have_no_content(other_iteration_issue.title) expect(page).to have_no_content(other_iteration_issue.title)
end end
it 'shows ungrouped issues when label `x` is clicked to remove it', :aggregate_failures do
within "section[aria-label=\"Issues with label #{label1.title}\"]" do
click_button 'Remove label'
end
expect(page).to have_no_button('Collapse issues')
expect(page).to have_no_css('.gl-label', text: label1.title)
expect(page).to have_no_css('.gl-badge', text: 2)
expect(page).to have_content(issue.title)
expect(page).to have_content(assigned_issue.title)
expect(page).to have_content(closed_issue.title)
expect(page).to have_no_content(other_iteration_issue.title)
end
end end
...@@ -20339,9 +20339,6 @@ msgstr "" ...@@ -20339,9 +20339,6 @@ msgstr ""
msgid "No issues found" msgid "No issues found"
msgstr "" msgstr ""
msgid "No issues found for the selected labels"
msgstr ""
msgid "No iteration" msgid "No iteration"
msgstr "" msgstr ""
...@@ -29817,6 +29814,9 @@ msgstr "" ...@@ -29817,6 +29814,9 @@ msgstr ""
msgid "There are no issues to show." msgid "There are no issues to show."
msgstr "" msgstr ""
msgid "There are no issues with the selected labels"
msgstr ""
msgid "There are no labels yet" msgid "There are no labels yet"
msgstr "" msgstr ""
...@@ -31485,6 +31485,9 @@ msgstr "" ...@@ -31485,6 +31485,9 @@ msgstr ""
msgid "Try changing or removing filters." msgid "Try changing or removing filters."
msgstr "" msgstr ""
msgid "Try grouping with different labels"
msgstr ""
msgid "Try to fork again" msgid "Try to fork again"
msgstr "" msgstr ""
......
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