Commit 15d25bd8 authored by Florie Guibert's avatar Florie Guibert Committed by Kushal Pandya

Epic Boards - Fix mentions of issues to epics

Rename IssueCount component to ItemCount
Make boards more agnostic about its issuableType
parent 22a117e6
<script> <script>
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import Draggable from 'vuedraggable'; import Draggable from 'vuedraggable';
import { mapActions, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import { sortableStart, sortableEnd } from '~/boards/mixins/sortable_default_options'; import { sortableStart, sortableEnd } from '~/boards/mixins/sortable_default_options';
import { sprintf, __ } from '~/locale'; import { sprintf, __ } from '~/locale';
import defaultSortableConfig from '~/sortable/sortable_config'; import defaultSortableConfig from '~/sortable/sortable_config';
...@@ -15,6 +15,7 @@ export default { ...@@ -15,6 +15,7 @@ export default {
loading: __('Loading'), loading: __('Loading'),
loadingMoreboardItems: __('Loading more'), loadingMoreboardItems: __('Loading more'),
showingAllIssues: __('Showing all issues'), showingAllIssues: __('Showing all issues'),
showingAllEpics: __('Showing all epics'),
}, },
components: { components: {
BoardCard, BoardCard,
...@@ -49,14 +50,19 @@ export default { ...@@ -49,14 +50,19 @@ export default {
}, },
computed: { computed: {
...mapState(['pageInfoByListId', 'listsFlags']), ...mapState(['pageInfoByListId', 'listsFlags']),
...mapGetters(['isEpicBoard']),
listItemsCount() {
return this.isEpicBoard ? this.list.epicsCount : this.list.issuesCount;
},
paginatedIssueText() { paginatedIssueText() {
return sprintf(__('Showing %{pageSize} of %{total} issues'), { return sprintf(__('Showing %{pageSize} of %{total} %{issuableType}'), {
pageSize: this.boardItems.length, pageSize: this.boardItems.length,
total: this.list.issuesCount, total: this.listItemsCount,
issuableType: this.isEpicBoard ? 'epics' : 'issues',
}); });
}, },
boardItemsSizeExceedsMax() { boardItemsSizeExceedsMax() {
return this.list.maxIssueCount > 0 && this.list.issuesCount > this.list.maxIssueCount; return this.list.maxIssueCount > 0 && this.listItemsCount > this.list.maxIssueCount;
}, },
hasNextPage() { hasNextPage() {
return this.pageInfoByListId[this.list.id].hasNextPage; return this.pageInfoByListId[this.list.id].hasNextPage;
...@@ -71,8 +77,13 @@ export default { ...@@ -71,8 +77,13 @@ export default {
// When list is draggable, the reference to the list needs to be accessed differently // When list is draggable, the reference to the list needs to be accessed differently
return this.canAdminList ? this.$refs.list.$el : this.$refs.list; return this.canAdminList ? this.$refs.list.$el : this.$refs.list;
}, },
showingAllIssues() { showingAllItems() {
return this.boardItems.length === this.list.issuesCount; return this.boardItems.length === this.listItemsCount;
},
showingAllItemsText() {
return this.isEpicBoard
? this.$options.i18n.showingAllEpics
: this.$options.i18n.showingAllIssues;
}, },
treeRootWrapper() { treeRootWrapper() {
return this.canAdminList ? Draggable : 'ul'; return this.canAdminList ? Draggable : 'ul';
...@@ -235,7 +246,7 @@ export default { ...@@ -235,7 +246,7 @@ export default {
:label="$options.i18n.loadingMoreboardItems" :label="$options.i18n.loadingMoreboardItems"
data-testid="count-loading-icon" data-testid="count-loading-icon"
/> />
<span v-if="showingAllIssues">{{ $options.i18n.showingAllIssues }}</span> <span v-if="showingAllItems">{{ showingAllItemsText }}</span>
<span v-else>{{ paginatedIssueText }}</span> <span v-else>{{ paginatedIssueText }}</span>
</li> </li>
</component> </component>
......
...@@ -17,7 +17,7 @@ import sidebarEventHub from '~/sidebar/event_hub'; ...@@ -17,7 +17,7 @@ import sidebarEventHub from '~/sidebar/event_hub';
import AccessorUtilities from '../../lib/utils/accessor'; import AccessorUtilities from '../../lib/utils/accessor';
import { inactiveId, LIST, ListType } from '../constants'; import { inactiveId, LIST, ListType } from '../constants';
import eventHub from '../eventhub'; import eventHub from '../eventhub';
import IssueCount from './issue_count.vue'; import ItemCount from './item_count.vue';
export default { export default {
i18n: { i18n: {
...@@ -33,7 +33,7 @@ export default { ...@@ -33,7 +33,7 @@ export default {
GlTooltip, GlTooltip,
GlIcon, GlIcon,
GlSprintf, GlSprintf,
IssueCount, ItemCount,
}, },
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
...@@ -337,7 +337,7 @@ export default { ...@@ -337,7 +337,7 @@ export default {
<gl-tooltip :target="() => $refs.itemCount" :title="itemsTooltipLabel" /> <gl-tooltip :target="() => $refs.itemCount" :title="itemsTooltipLabel" />
<span ref="itemCount" class="issue-count-badge-count"> <span ref="itemCount" class="issue-count-badge-count">
<gl-icon class="gl-mr-2" :name="countIcon" /> <gl-icon class="gl-mr-2" :name="countIcon" />
<issue-count :issues-size="itemsCount" :max-issue-count="list.maxIssueCount" /> <item-count :items-size="itemsCount" :max-issue-count="list.maxIssueCount" />
</span> </span>
<!-- EE start --> <!-- EE start -->
<template v-if="weightFeatureAvailable && !isEpicBoard"> <template v-if="weightFeatureAvailable && !isEpicBoard">
......
...@@ -17,7 +17,7 @@ import AccessorUtilities from '../../lib/utils/accessor'; ...@@ -17,7 +17,7 @@ import AccessorUtilities from '../../lib/utils/accessor';
import { inactiveId, LIST, ListType } from '../constants'; import { inactiveId, LIST, ListType } from '../constants';
import eventHub from '../eventhub'; import eventHub from '../eventhub';
import boardsStore from '../stores/boards_store'; import boardsStore from '../stores/boards_store';
import IssueCount from './issue_count.vue'; import IssueCount from './item_count.vue';
// This component is being replaced in favor of './board_list_header.vue' for GraphQL boards // This component is being replaced in favor of './board_list_header.vue' for GraphQL boards
...@@ -308,7 +308,7 @@ export default { ...@@ -308,7 +308,7 @@ export default {
<gl-tooltip :target="() => $refs.issueCount" :title="issuesTooltipLabel" /> <gl-tooltip :target="() => $refs.issueCount" :title="issuesTooltipLabel" />
<span ref="issueCount" class="issue-count-badge-count"> <span ref="issueCount" class="issue-count-badge-count">
<gl-icon class="gl-mr-2" name="issues" /> <gl-icon class="gl-mr-2" name="issues" />
<issue-count :issues-size="issuesCount" :max-issue-count="list.maxIssueCount" /> <issue-count :items-size="issuesCount" :max-issue-count="list.maxIssueCount" />
</span> </span>
<!-- The following is only true in EE. --> <!-- The following is only true in EE. -->
<template v-if="weightFeatureAvailable"> <template v-if="weightFeatureAvailable">
......
...@@ -7,7 +7,7 @@ export default { ...@@ -7,7 +7,7 @@ export default {
required: false, required: false,
default: 0, default: 0,
}, },
issuesSize: { itemsSize: {
type: Number, type: Number,
required: false, required: false,
default: 0, default: 0,
...@@ -18,16 +18,16 @@ export default { ...@@ -18,16 +18,16 @@ export default {
return this.maxIssueCount !== 0; return this.maxIssueCount !== 0;
}, },
issuesExceedMax() { issuesExceedMax() {
return this.isMaxLimitSet && this.issuesSize > this.maxIssueCount; return this.isMaxLimitSet && this.itemsSize > this.maxIssueCount;
}, },
}, },
}; };
</script> </script>
<template> <template>
<div class="issue-count text-nowrap"> <div class="item-count text-nowrap">
<span class="js-issue-size" :class="{ 'text-danger': issuesExceedMax }"> <span :class="{ 'text-danger': issuesExceedMax }" data-testid="board-items-count">
{{ issuesSize }} {{ itemsSize }}
</span> </span>
<span v-if="isMaxLimitSet" class="js-max-issue-size"> <span v-if="isMaxLimitSet" class="js-max-issue-size">
{{ maxIssueCount }} {{ maxIssueCount }}
......
...@@ -36,8 +36,7 @@ export function formatListEpics(listEpics) { ...@@ -36,8 +36,7 @@ export function formatListEpics(listEpics) {
let listItemsCount; let listItemsCount;
const listData = listEpics.nodes.reduce((map, list) => { const listData = listEpics.nodes.reduce((map, list) => {
// TODO update when list.epics.count is available: https://gitlab.com/gitlab-org/gitlab/-/issues/301017 listItemsCount = list.epicsCount;
listItemsCount = list.epics.edges.length;
let sortedEpics = list.epics.edges.map((epicNode) => ({ let sortedEpics = list.epics.edges.map((epicNode) => ({
...epicNode.node, ...epicNode.node,
})); }));
......
...@@ -201,7 +201,7 @@ RSpec.describe 'issue boards', :js do ...@@ -201,7 +201,7 @@ RSpec.describe 'issue boards', :js do
it 'displays issue and max issue size' do it 'displays issue and max issue size' do
page.within(find(".board:nth-child(2)")) do page.within(find(".board:nth-child(2)")) do
expect(page.find('.js-issue-size')).to have_text(total_development_issues) expect(page.find('[data-testid="board-items-count"]')).to have_text(total_development_issues)
expect(page.find('.js-max-issue-size')).to have_text(max_issue_count) expect(page.find('.js-max-issue-size')).to have_text(max_issue_count)
end end
end end
......
...@@ -13,6 +13,7 @@ describe('formatListEpics', () => { ...@@ -13,6 +13,7 @@ describe('formatListEpics', () => {
nodes: [ nodes: [
{ {
id: 'gid://gitlab/Boards::EpicList/3', id: 'gid://gitlab/Boards::EpicList/3',
epicsCount: 1,
epics: { epics: {
edges: [ edges: [
{ {
......
...@@ -27845,9 +27845,15 @@ msgstr[1] "" ...@@ -27845,9 +27845,15 @@ msgstr[1] ""
msgid "Showing %{limit} of %{total_count} issues. " msgid "Showing %{limit} of %{total_count} issues. "
msgstr "" msgstr ""
msgid "Showing %{pageSize} of %{total} %{issuableType}"
msgstr ""
msgid "Showing %{pageSize} of %{total} issues" msgid "Showing %{pageSize} of %{total} issues"
msgstr "" msgstr ""
msgid "Showing all epics"
msgstr ""
msgid "Showing all issues" msgid "Showing all issues"
msgstr "" msgstr ""
......
...@@ -298,7 +298,7 @@ RSpec.describe 'Issue Boards', :js do ...@@ -298,7 +298,7 @@ RSpec.describe 'Issue Boards', :js do
it 'shows issue count on the list' do it 'shows issue count on the list' do
page.within(find(".board:nth-child(2)")) do page.within(find(".board:nth-child(2)")) do
expect(page.find('.js-issue-size')).to have_text(total_planning_issues) expect(page.find('[data-testid="board-items-count"]')).to have_text(total_planning_issues)
expect(page).not_to have_selector('.js-max-issue-size') expect(page).not_to have_selector('.js-max-issue-size')
end end
end end
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import IssueCount from '~/boards/components/issue_count.vue'; import IssueCount from '~/boards/components/item_count.vue';
describe('IssueCount', () => { describe('IssueCount', () => {
let vm; let vm;
let maxIssueCount; let maxIssueCount;
let issuesSize; let itemsSize;
const createComponent = (props) => { const createComponent = (props) => {
vm = shallowMount(IssueCount, { propsData: props }); vm = shallowMount(IssueCount, { propsData: props });
...@@ -12,20 +12,20 @@ describe('IssueCount', () => { ...@@ -12,20 +12,20 @@ describe('IssueCount', () => {
afterEach(() => { afterEach(() => {
maxIssueCount = 0; maxIssueCount = 0;
issuesSize = 0; itemsSize = 0;
if (vm) vm.destroy(); if (vm) vm.destroy();
}); });
describe('when maxIssueCount is zero', () => { describe('when maxIssueCount is zero', () => {
beforeEach(() => { beforeEach(() => {
issuesSize = 3; itemsSize = 3;
createComponent({ maxIssueCount: 0, issuesSize }); createComponent({ maxIssueCount: 0, itemsSize });
}); });
it('contains issueSize in the template', () => { it('contains issueSize in the template', () => {
expect(vm.find('.js-issue-size').text()).toEqual(String(issuesSize)); expect(vm.find('[data-testid="board-items-count"]').text()).toEqual(String(itemsSize));
}); });
it('does not contains maxIssueCount in the template', () => { it('does not contains maxIssueCount in the template', () => {
...@@ -36,9 +36,9 @@ describe('IssueCount', () => { ...@@ -36,9 +36,9 @@ describe('IssueCount', () => {
describe('when maxIssueCount is greater than zero', () => { describe('when maxIssueCount is greater than zero', () => {
beforeEach(() => { beforeEach(() => {
maxIssueCount = 2; maxIssueCount = 2;
issuesSize = 1; itemsSize = 1;
createComponent({ maxIssueCount, issuesSize }); createComponent({ maxIssueCount, itemsSize });
}); });
afterEach(() => { afterEach(() => {
...@@ -46,7 +46,7 @@ describe('IssueCount', () => { ...@@ -46,7 +46,7 @@ describe('IssueCount', () => {
}); });
it('contains issueSize in the template', () => { it('contains issueSize in the template', () => {
expect(vm.find('.js-issue-size').text()).toEqual(String(issuesSize)); expect(vm.find('[data-testid="board-items-count"]').text()).toEqual(String(itemsSize));
}); });
it('contains maxIssueCount in the template', () => { it('contains maxIssueCount in the template', () => {
...@@ -60,10 +60,10 @@ describe('IssueCount', () => { ...@@ -60,10 +60,10 @@ describe('IssueCount', () => {
describe('when issueSize is greater than maxIssueCount', () => { describe('when issueSize is greater than maxIssueCount', () => {
beforeEach(() => { beforeEach(() => {
issuesSize = 3; itemsSize = 3;
maxIssueCount = 2; maxIssueCount = 2;
createComponent({ maxIssueCount, issuesSize }); createComponent({ maxIssueCount, itemsSize });
}); });
afterEach(() => { afterEach(() => {
...@@ -71,7 +71,7 @@ describe('IssueCount', () => { ...@@ -71,7 +71,7 @@ describe('IssueCount', () => {
}); });
it('contains issueSize in the template', () => { it('contains issueSize in the template', () => {
expect(vm.find('.js-issue-size').text()).toEqual(String(issuesSize)); expect(vm.find('[data-testid="board-items-count"]').text()).toEqual(String(itemsSize));
}); });
it('contains maxIssueCount in the template', () => { it('contains maxIssueCount in the template', () => {
...@@ -79,7 +79,7 @@ describe('IssueCount', () => { ...@@ -79,7 +79,7 @@ describe('IssueCount', () => {
}); });
it('has text-danger class', () => { it('has text-danger class', () => {
expect(vm.find('.text-danger').text()).toEqual(String(issuesSize)); expect(vm.find('.text-danger').text()).toEqual(String(itemsSize));
}); });
}); });
}); });
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