Skip to content
代码片段 群组 项目
未验证 提交 1b3b2b67 编辑于 作者: Alex Pennells's avatar Alex Pennells 提交者: GitLab
浏览文件

Merge branch 'drosse/refactor-contribution-components' into 'master'

Refactor out headers from Contribution components charts

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/179337



Merged-by: default avatarAlex Pennells <apennells@gitlab.com>
Approved-by: default avatarAlex Pennells <apennells@gitlab.com>
Reviewed-by: default avatarAlex Pennells <apennells@gitlab.com>
Co-authored-by: default avatarDaniele Rossetti <drossetti@gitlab.com>
No related branches found
No related tags found
无相关合并请求
显示 57 个添加60 个删除
<script> <script>
import { GlLoadingIcon, GlAlert } from '@gitlab/ui'; import { GlLoadingIcon, GlAlert } from '@gitlab/ui';
import * as Sentry from '~/sentry/sentry_browser_wrapper'; import * as Sentry from '~/sentry/sentry_browser_wrapper';
import { s__ } from '~/locale'; import { s__, __ } from '~/locale';
import { import {
filterIssues, filterIssues,
filterMergeRequests, filterMergeRequests,
...@@ -46,6 +46,10 @@ export default { ...@@ -46,6 +46,10 @@ export default {
i18n: { i18n: {
loading: s__('ContributionAnalytics|Loading contribution stats for group members'), loading: s__('ContributionAnalytics|Loading contribution stats for group members'),
error: s__('ContributionAnalytics|Failed to load the contribution stats'), error: s__('ContributionAnalytics|Failed to load the contribution stats'),
pushesHeader: __('Pushes'),
mergeRequestsHeader: s__('ContributionAnalytics|Merge requests'),
issuesHeader: s__('ContributionAnalytics|Issues'),
contributionsPerMemberHeader: s__('ContributionAnalytics|Contributions per group member'),
}, },
data() { data() {
return { return {
...@@ -121,10 +125,22 @@ export default { ...@@ -121,10 +125,22 @@ export default {
</gl-alert> </gl-alert>
<template v-else> <template v-else>
<pushes-chart :pushes="pushes" /> <div>
<merge-requests-chart :merge-requests="mergeRequests" /> <h3>{{ $options.i18n.pushesHeader }}</h3>
<issues-chart :issues="issues" /> <pushes-chart :pushes="pushes" />
<group-members-table :contributions="contributions" /> </div>
<div>
<h3>{{ $options.i18n.mergeRequestsHeader }}</h3>
<merge-requests-chart :merge-requests="mergeRequests" />
</div>
<div>
<h3>{{ $options.i18n.issuesHeader }}</h3>
<issues-chart :issues="issues" />
</div>
<div>
<h3>{{ $options.i18n.contributionsPerMemberHeader }}</h3>
<group-members-table :contributions="contributions" />
</div>
</template> </template>
</div> </div>
</template> </template>
<script> <script>
import { GlTable, GlLink } from '@gitlab/ui'; import { GlTable, GlLink } from '@gitlab/ui';
import { s__ } from '~/locale';
import { TABLE_COLUMNS } from '../constants'; import { TABLE_COLUMNS } from '../constants';
export default { export default {
...@@ -21,15 +20,11 @@ export default { ...@@ -21,15 +20,11 @@ export default {
sortDesc: false, sortDesc: false,
}; };
}, },
i18n: {
header: s__('ContributionAnalytics|Contributions per group member'),
},
}; };
</script> </script>
<template> <template>
<div> <div>
<h3>{{ $options.i18n.header }}</h3>
<gl-table <gl-table
:items="contributions" :items="contributions"
:fields="$options.columns" :fields="$options.columns"
......
...@@ -11,7 +11,6 @@ export default { ...@@ -11,7 +11,6 @@ export default {
GlSprintf, GlSprintf,
}, },
i18n: { i18n: {
header: s__('ContributionAnalytics|Issues'),
xAxisTitle: __('User'), xAxisTitle: __('User'),
yAxisTitle: __('Issues closed'), yAxisTitle: __('Issues closed'),
emptyDescription: s__('ContributionAnalytics|No issues for the selected time period.'), emptyDescription: s__('ContributionAnalytics|No issues for the selected time period.'),
...@@ -51,19 +50,16 @@ export default { ...@@ -51,19 +50,16 @@ export default {
}; };
</script> </script>
<template> <template>
<div> <div data-testid="issue-content">
<div data-testid="issue-content"> <div data-testid="description">
<h3>{{ $options.i18n.header }}</h3> <gl-sprintf :message="description">
<div data-testid="description"> <template #createdCount>
<gl-sprintf :message="description"> <strong>{{ formatNumber(createdCount) }}</strong>
<template #createdCount> </template>
<strong>{{ formatNumber(createdCount) }}</strong> <template #closedCount>
</template> <strong>{{ formatNumber(closedCount) }}</strong>
<template #closedCount> </template>
<strong>{{ formatNumber(closedCount) }}</strong> </gl-sprintf>
</template>
</gl-sprintf>
</div>
</div> </div>
<column-chart <column-chart
......
...@@ -11,7 +11,6 @@ export default { ...@@ -11,7 +11,6 @@ export default {
GlSprintf, GlSprintf,
}, },
i18n: { i18n: {
header: s__('ContributionAnalytics|Merge requests'),
xAxisTitle: __('User'), xAxisTitle: __('User'),
yAxisTitle: __('Merge Requests created'), yAxisTitle: __('Merge Requests created'),
emptyDescription: s__('ContributionAnalytics|No merge requests for the selected time period.'), emptyDescription: s__('ContributionAnalytics|No merge requests for the selected time period.'),
...@@ -56,22 +55,19 @@ export default { ...@@ -56,22 +55,19 @@ export default {
}; };
</script> </script>
<template> <template>
<div> <div data-testid="merge-request-content">
<div data-testid="merge-request-content"> <div data-testid="description">
<h3>{{ $options.i18n.header }}</h3> <gl-sprintf :message="description">
<div data-testid="description"> <template #createdCount>
<gl-sprintf :message="description"> <strong>{{ formatNumber(createdCount) }}</strong>
<template #createdCount> </template>
<strong>{{ formatNumber(createdCount) }}</strong> <template #mergedCount>
</template> <strong>{{ formatNumber(mergedCount) }}</strong>
<template #mergedCount> </template>
<strong>{{ formatNumber(mergedCount) }}</strong> <template #closedCount>
</template> <strong>{{ formatNumber(closedCount) }}</strong>
<template #closedCount> </template>
<strong>{{ formatNumber(closedCount) }}</strong> </gl-sprintf>
</template>
</gl-sprintf>
</div>
</div> </div>
<column-chart <column-chart
......
...@@ -11,7 +11,6 @@ export default { ...@@ -11,7 +11,6 @@ export default {
GlSprintf, GlSprintf,
}, },
i18n: { i18n: {
header: __('Pushes'),
xAxisTitle: __('User'), xAxisTitle: __('User'),
yAxisTitle: __('Pushes'), yAxisTitle: __('Pushes'),
emptyDescription: s__('ContributionAnalytics|No pushes for the selected time period.'), emptyDescription: s__('ContributionAnalytics|No pushes for the selected time period.'),
...@@ -51,21 +50,16 @@ export default { ...@@ -51,21 +50,16 @@ export default {
}; };
</script> </script>
<template> <template>
<div> <div data-testid="push-content">
<div data-testid="push-content"> <div data-testid="description">
<h3>{{ $options.i18n.header }}</h3> <gl-sprintf :message="description">
<div data-testid="description"> <template #pushCount>
<gl-sprintf :message="description"> <strong>{{ n__('%d push', '%d pushes', formatNumber(pushCount)) }}</strong>
<template #pushCount> </template>
<strong>{{ n__('%d push', '%d pushes', formatNumber(pushCount)) }}</strong> <template #authorCount>
</template> <strong>{{ n__('%d contributor', '%d contributors', formatNumber(authorCount)) }}</strong>
<template #authorCount> </template>
<strong>{{ </gl-sprintf>
n__('%d contributor', '%d contributors', formatNumber(authorCount))
}}</strong>
</template>
</gl-sprintf>
</div>
</div> </div>
<column-chart <column-chart
......
...@@ -23,7 +23,7 @@ describe('Contribution Analytics Issues Chart', () => { ...@@ -23,7 +23,7 @@ describe('Contribution Analytics Issues Chart', () => {
it('renders the empty description when there is no table data', () => { it('renders the empty description when there is no table data', () => {
createWrapper([]); createWrapper([]);
expect(findDescription()).toBe(wrapper.vm.$options.i18n.emptyDescription); expect(findDescription()).toBe('No issues for the selected time period.');
}); });
it('renders the description based on the table data', () => { it('renders the description based on the table data', () => {
......
...@@ -23,7 +23,7 @@ describe('Contribution Analytics Merge Requests Chart', () => { ...@@ -23,7 +23,7 @@ describe('Contribution Analytics Merge Requests Chart', () => {
it('renders the empty description when there is no table data', () => { it('renders the empty description when there is no table data', () => {
createWrapper([]); createWrapper([]);
expect(findDescription()).toBe(wrapper.vm.$options.i18n.emptyDescription); expect(findDescription()).toBe('No merge requests for the selected time period.');
}); });
it('renders the description based on the table data', () => { it('renders the description based on the table data', () => {
......
...@@ -23,7 +23,7 @@ describe('Contribution Analytics Pushes Chart', () => { ...@@ -23,7 +23,7 @@ describe('Contribution Analytics Pushes Chart', () => {
it('renders the empty description when there is no table data', () => { it('renders the empty description when there is no table data', () => {
createWrapper([]); createWrapper([]);
expect(findDescription()).toBe(wrapper.vm.$options.i18n.emptyDescription); expect(findDescription()).toBe('No pushes for the selected time period.');
}); });
it('renders the description based on the table data', () => { it('renders the description based on the table data', () => {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册