diff options
Diffstat (limited to 'app/assets/javascripts/reports')
4 files changed, 40 insertions, 25 deletions
diff --git a/app/assets/javascripts/reports/components/report_section.vue b/app/assets/javascripts/reports/components/report_section.vue index f245e2bfd2f..0e9975ea81f 100644 --- a/app/assets/javascripts/reports/components/report_section.vue +++ b/app/assets/javascripts/reports/components/report_section.vue @@ -3,7 +3,7 @@ import { __ } from '~/locale'; import StatusIcon from '~/vue_merge_request_widget/components/mr_widget_status_icon.vue'; import Popover from '~/vue_shared/components/help_popover.vue'; import IssuesList from './issues_list.vue'; -import { status } from '../constants'; +import { status, SLOT_SUCCESS, SLOT_LOADING, SLOT_ERROR } from '../constants'; export default { name: 'ReportSection', @@ -152,12 +152,12 @@ export default { }, slotName() { if (this.isSuccess) { - return 'success'; + return SLOT_SUCCESS; } else if (this.isLoading) { - return 'loading'; + return SLOT_LOADING; } - return 'error'; + return SLOT_ERROR; }, }, methods: { diff --git a/app/assets/javascripts/reports/components/test_issue_body.vue b/app/assets/javascripts/reports/components/test_issue_body.vue index 5e9a5b03543..69b0dcf881d 100644 --- a/app/assets/javascripts/reports/components/test_issue_body.vue +++ b/app/assets/javascripts/reports/components/test_issue_body.vue @@ -1,13 +1,13 @@ <script> import { mapActions } from 'vuex'; -import { GlBadge } from '@gitlab/ui'; -import { n__ } from '~/locale'; +import { GlBadge, GlSprintf } from '@gitlab/ui'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; export default { name: 'TestIssueBody', components: { GlBadge, + GlSprintf, }, mixins: [glFeatureFlagsMixin()], props: { @@ -28,18 +28,15 @@ export default { }, computed: { showRecentFailures() { - return this.glFeatures.testFailureHistory && this.issue.recent_failures; + return ( + this.glFeatures.testFailureHistory && + this.issue.recent_failures?.count && + this.issue.recent_failures?.base_branch + ); }, }, methods: { ...mapActions(['openModal']), - recentFailuresText(count) { - return n__( - 'Failed %d time in the last 14 days', - 'Failed %d times in the last 14 days', - count, - ); - }, }, }; </script> @@ -53,7 +50,18 @@ export default { > <gl-badge v-if="isNew" variant="danger" class="gl-mr-2">{{ s__('New') }}</gl-badge> <gl-badge v-if="showRecentFailures" variant="warning" class="gl-mr-2"> - {{ recentFailuresText(issue.recent_failures) }} + <gl-sprintf + :message=" + n__( + 'Reports|Failed %{count} time in %{base_branch} in the last 14 days', + 'Reports|Failed %{count} times in %{base_branch} in the last 14 days', + issue.recent_failures.count, + ) + " + > + <template #count>{{ issue.recent_failures.count }}</template> + <template #base_branch>{{ issue.recent_failures.base_branch }}</template> + </gl-sprintf> </gl-badge> {{ issue.name }} </button> diff --git a/app/assets/javascripts/reports/constants.js b/app/assets/javascripts/reports/constants.js index b3905cbfcfb..9250bfd7678 100644 --- a/app/assets/javascripts/reports/constants.js +++ b/app/assets/javascripts/reports/constants.js @@ -18,10 +18,18 @@ export const ICON_SUCCESS = 'success'; export const ICON_NOTFOUND = 'notfound'; export const status = { - LOADING: 'LOADING', - ERROR: 'ERROR', - SUCCESS: 'SUCCESS', + LOADING, + ERROR, + SUCCESS, }; export const ACCESSIBILITY_ISSUE_ERROR = 'error'; export const ACCESSIBILITY_ISSUE_WARNING = 'warning'; + +/** + * Slot names for the ReportSection component, corresponding to the success, + * loading and error statuses. + */ +export const SLOT_SUCCESS = 'success'; +export const SLOT_LOADING = 'loading'; +export const SLOT_ERROR = 'error'; diff --git a/app/assets/javascripts/reports/store/utils.js b/app/assets/javascripts/reports/store/utils.js index fd6f4933cfa..2d32daee9d0 100644 --- a/app/assets/javascripts/reports/store/utils.js +++ b/app/assets/javascripts/reports/store/utils.js @@ -62,12 +62,8 @@ export const recentFailuresTextBuilder = (summary = {}) => { } return sprintf( n__( - s__( - 'Reports|%{recentlyFailed} out of %{failed} failed tests has failed more than once in the last 14 days', - ), - s__( - 'Reports|%{recentlyFailed} out of %{failed} failed tests have failed more than once in the last 14 days', - ), + 'Reports|%{recentlyFailed} out of %{failed} failed tests has failed more than once in the last 14 days', + 'Reports|%{recentlyFailed} out of %{failed} failed tests have failed more than once in the last 14 days', recentlyFailed, ), { recentlyFailed, failed }, @@ -83,7 +79,10 @@ export const countRecentlyFailedTests = subject => { return ( [report.new_failures, report.existing_failures, report.resolved_failures] // only count tests which have failed more than once - .map(failureArray => failureArray.filter(failure => failure.recent_failures > 1).length) + .map( + failureArray => + failureArray.filter(failure => failure.recent_failures?.count > 1).length, + ) .reduce((total, count) => total + count, 0) ); }) |