Commit 78e1598c authored by Payton Burdette's avatar Payton Burdette Committed by Peter Hegman

Add link for failed pipelines

On the CI/CD analytics page
add a link to view failed pipelines.

Changelog: changed
parent 437f277f
<script> <script>
import { GlLink } from '@gitlab/ui';
import { SUPPORTED_FORMATS, getFormatter } from '~/lib/utils/unit_format'; import { SUPPORTED_FORMATS, getFormatter } from '~/lib/utils/unit_format';
import { s__, n__ } from '~/locale'; import { s__, n__ } from '~/locale';
const defaultPrecision = 2; const defaultPrecision = 2;
export default { export default {
components: {
GlLink,
},
inject: {
failedPipelinesLink: {
default: '',
},
},
props: { props: {
counts: { counts: {
type: Object, type: Object,
...@@ -27,6 +36,7 @@ export default { ...@@ -27,6 +36,7 @@ export default {
{ {
title: s__('PipelineCharts|Failed:'), title: s__('PipelineCharts|Failed:'),
value: n__('1 pipeline', '%d pipelines', this.counts.failed), value: n__('1 pipeline', '%d pipelines', this.counts.failed),
link: this.failedPipelinesLink,
}, },
{ {
title: s__('PipelineCharts|Success ratio:'), title: s__('PipelineCharts|Success ratio:'),
...@@ -39,10 +49,13 @@ export default { ...@@ -39,10 +49,13 @@ export default {
</script> </script>
<template> <template>
<ul> <ul>
<template v-for="({ title, value }, index) in statistics"> <template v-for="({ title, value, link }, index) in statistics">
<li :key="index"> <li :key="index">
<span>{{ title }}</span> <span>{{ title }}</span>
<strong>{{ value }}</strong> <gl-link v-if="link" :href="link">
{{ value }}
</gl-link>
<strong v-else>{{ value }}</strong>
</li> </li>
</template> </template>
</ul> </ul>
......
...@@ -11,7 +11,7 @@ const apolloProvider = new VueApollo({ ...@@ -11,7 +11,7 @@ const apolloProvider = new VueApollo({
}); });
const mountPipelineChartsApp = (el) => { const mountPipelineChartsApp = (el) => {
const { projectPath } = el.dataset; const { projectPath, failedPipelinesLink } = el.dataset;
const shouldRenderDoraCharts = parseBoolean(el.dataset.shouldRenderDoraCharts); const shouldRenderDoraCharts = parseBoolean(el.dataset.shouldRenderDoraCharts);
const shouldRenderQualitySummary = parseBoolean(el.dataset.shouldRenderQualitySummary); const shouldRenderQualitySummary = parseBoolean(el.dataset.shouldRenderQualitySummary);
...@@ -25,6 +25,7 @@ const mountPipelineChartsApp = (el) => { ...@@ -25,6 +25,7 @@ const mountPipelineChartsApp = (el) => {
apolloProvider, apolloProvider,
provide: { provide: {
projectPath, projectPath,
failedPipelinesLink,
shouldRenderDoraCharts, shouldRenderDoraCharts,
shouldRenderQualitySummary, shouldRenderQualitySummary,
}, },
......
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
#js-project-pipelines-charts-app{ data: { project_path: @project.full_path, #js-project-pipelines-charts-app{ data: { project_path: @project.full_path,
should_render_dora_charts: should_render_dora_charts.to_s, should_render_dora_charts: should_render_dora_charts.to_s,
should_render_quality_summary: should_render_quality_summary.to_s } } should_render_quality_summary: should_render_quality_summary.to_s,
failed_pipelines_link: project_pipelines_path(@project, page: '1', scope: 'all', status: 'failed') } }
...@@ -25,9 +25,13 @@ exports[`StatisticsList displays the counts data with labels 1`] = ` ...@@ -25,9 +25,13 @@ exports[`StatisticsList displays the counts data with labels 1`] = `
Failed: Failed:
</span> </span>
<strong> <gl-link-stub
2 pipelines href="/flightjs/Flight/-/pipelines?page=1&scope=all&status=failed"
</strong> >
2 pipelines
</gl-link-stub>
</li> </li>
<li> <li>
<span> <span>
......
import { GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Component from '~/projects/pipelines/charts/components/statistics_list.vue'; import Component from '~/projects/pipelines/charts/components/statistics_list.vue';
import { counts } from '../mock_data'; import { counts } from '../mock_data';
...@@ -5,8 +6,15 @@ import { counts } from '../mock_data'; ...@@ -5,8 +6,15 @@ import { counts } from '../mock_data';
describe('StatisticsList', () => { describe('StatisticsList', () => {
let wrapper; let wrapper;
const failedPipelinesLink = '/flightjs/Flight/-/pipelines?page=1&scope=all&status=failed';
const findFailedPipelinesLink = () => wrapper.findComponent(GlLink);
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(Component, { wrapper = shallowMount(Component, {
provide: {
failedPipelinesLink,
},
propsData: { propsData: {
counts, counts,
}, },
...@@ -15,10 +23,13 @@ describe('StatisticsList', () => { ...@@ -15,10 +23,13 @@ describe('StatisticsList', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
it('displays the counts data with labels', () => { it('displays the counts data with labels', () => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); });
it('displays failed pipelines link', () => {
expect(findFailedPipelinesLink().attributes('href')).toBe(failedPipelinesLink);
});
}); });
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