Commit 581e0829 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '235856-display-more-columns-in-merge-request-analytics-data-table-fe-2' into 'master'

Add approved meta to MR Analytics Throughput table

See merge request gitlab-org/gitlab!42216
parents a6037c3f c870af5c
...@@ -12,7 +12,7 @@ import { ...@@ -12,7 +12,7 @@ import {
GlAlert, GlAlert,
GlIcon, GlIcon,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__, n__ } from '~/locale';
import { approximateDuration, differenceInSeconds } from '~/lib/utils/datetime_utility'; import { approximateDuration, differenceInSeconds } from '~/lib/utils/datetime_utility';
import { filterToQueryObject } from '~/vue_shared/components/filtered_search_bar/filtered_search_utils'; import { filterToQueryObject } from '~/vue_shared/components/filtered_search_bar/filtered_search_utils';
import { dateFormats } from '../../shared/constants'; import { dateFormats } from '../../shared/constants';
...@@ -187,6 +187,9 @@ export default { ...@@ -187,6 +187,9 @@ export default {
? PIPELINE_STATUS_ICON_CLASSES.default ? PIPELINE_STATUS_ICON_CLASSES.default
: PIPELINE_STATUS_ICON_CLASSES[value]; : PIPELINE_STATUS_ICON_CLASSES[value];
}, },
formatApprovalText(approvals) {
return n__('%d Approval', '%d Approvals', approvals);
},
}, },
assigneesVisible: ASSIGNEES_VISIBLE, assigneesVisible: ASSIGNEES_VISIBLE,
avatarSize: AVATAR_SIZE, avatarSize: AVATAR_SIZE,
...@@ -236,6 +239,15 @@ export default { ...@@ -236,6 +239,15 @@ export default {
> >
<gl-icon name="comments" class="gl-mr-2" /><span>{{ item.userNotesCount }}</span> <gl-icon name="comments" class="gl-mr-2" /><span>{{ item.userNotesCount }}</span>
</li> </li>
<li
v-if="item.approvedBy.nodes.length"
class="gl-text-green-500"
:data-testid="$options.testIds.APPROVED"
>
<gl-icon name="approval" class="gl-mr-2" /><span>{{
formatApprovalText(item.approvedBy.nodes.length)
}}</span>
</li>
</ul> </ul>
</div> </div>
</div> </div>
......
...@@ -42,6 +42,7 @@ export const THROUGHPUT_TABLE_TEST_IDS = { ...@@ -42,6 +42,7 @@ export const THROUGHPUT_TABLE_TEST_IDS = {
ASSIGNEES: 'assigneesCol', ASSIGNEES: 'assigneesCol',
COMMITS: 'commitsCol', COMMITS: 'commitsCol',
COMMENT_COUNT: 'commentCount', COMMENT_COUNT: 'commentCount',
APPROVED: 'approvedStatus',
}; };
export const PIPELINE_STATUS_ICON_CLASSES = { export const PIPELINE_STATUS_ICON_CLASSES = {
......
...@@ -57,6 +57,11 @@ query( ...@@ -57,6 +57,11 @@ query(
} }
commitCount commitCount
userNotesCount userNotesCount
approvedBy {
nodes {
id
}
}
} }
} }
} }
......
...@@ -228,7 +228,7 @@ describe('ThroughputTable', () => { ...@@ -228,7 +228,7 @@ describe('ThroughputTable', () => {
expect(icon.props('name')).toBe('comments'); expect(icon.props('name')).toBe('comments');
}); });
it('includes a pipeline icon and when available', async () => { it('includes a pipeline icon when available', async () => {
const iconName = 'status_canceled'; const iconName = 'status_canceled';
additionalData({ additionalData({
...@@ -248,6 +248,61 @@ describe('ThroughputTable', () => { ...@@ -248,6 +248,61 @@ describe('ThroughputTable', () => {
expect(icon.find(GlIcon).exists()).toBe(true); expect(icon.find(GlIcon).exists()).toBe(true);
expect(icon.props('name')).toBe(iconName); expect(icon.props('name')).toBe(iconName);
}); });
describe('approval details', () => {
const iconName = 'approval';
it('does not display by default', async () => {
const approved = findColSubItem(TEST_IDS.MERGE_REQUEST_DETAILS, TEST_IDS.APPROVED);
expect(approved.exists()).toBe(false);
});
it('displays the singular when there is a single approval', async () => {
additionalData({
approvedBy: {
nodes: [
{
id: 1,
},
],
},
});
await wrapper.vm.$nextTick();
const approved = findColSubItem(TEST_IDS.MERGE_REQUEST_DETAILS, TEST_IDS.APPROVED);
const icon = approved.find(GlIcon);
expect(approved.text()).toBe('1 Approval');
expect(icon.exists()).toBe(true);
expect(icon.props('name')).toBe(iconName);
});
it('displays the plural when there are multiple approvals', async () => {
additionalData({
approvedBy: {
nodes: [
{
id: 1,
},
{
id: 2,
},
],
},
});
await wrapper.vm.$nextTick();
const approved = findColSubItem(TEST_IDS.MERGE_REQUEST_DETAILS, TEST_IDS.APPROVED);
const icon = approved.find(GlIcon);
expect(approved.text()).toBe('2 Approvals');
expect(icon.exists()).toBe(true);
expect(icon.props('name')).toBe(iconName);
});
});
}); });
it('displays the correct date merged', () => { it('displays the correct date merged', () => {
......
...@@ -84,5 +84,8 @@ export const throughputTableData = [ ...@@ -84,5 +84,8 @@ export const throughputTableData = [
}, },
commitCount: 1, commitCount: 1,
userNotesCount: 0, userNotesCount: 0,
approvedBy: {
nodes: [],
},
}, },
]; ];
...@@ -77,6 +77,11 @@ msgstr "" ...@@ -77,6 +77,11 @@ msgstr ""
msgid "\"el\" parameter is required for createInstance()" msgid "\"el\" parameter is required for createInstance()"
msgstr "" msgstr ""
msgid "%d Approval"
msgid_plural "%d Approvals"
msgstr[0] ""
msgstr[1] ""
msgid "%d Scanned URL" msgid "%d Scanned URL"
msgid_plural "%d Scanned URLs" msgid_plural "%d Scanned URLs"
msgstr[0] "" msgstr[0] ""
......
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