debian-mirror-gitlab/app/assets/javascripts/projects/pipelines/charts/components/app.vue

87 lines
2.3 KiB
Vue
Raw Normal View History

2020-03-13 15:44:24 +05:30
<script>
2021-03-11 19:13:27 +05:30
import { GlTabs, GlTab } from '@gitlab/ui';
import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/url_utility';
2021-03-08 18:12:59 +05:30
import PipelineCharts from './pipeline_charts.vue';
2020-03-13 15:44:24 +05:30
export default {
components: {
2021-03-08 18:12:59 +05:30
GlTabs,
GlTab,
PipelineCharts,
DeploymentFrequencyCharts: () =>
2021-06-08 01:23:25 +05:30
import('ee_component/dora/components/deployment_frequency_charts.vue'),
LeadTimeCharts: () => import('ee_component/dora/components/lead_time_charts.vue'),
2021-12-11 22:18:48 +05:30
ProjectQualitySummary: () => import('ee_component/project_quality_summary/app.vue'),
2020-03-13 15:44:24 +05:30
},
2021-02-22 17:27:13 +05:30
inject: {
2021-04-29 21:17:54 +05:30
shouldRenderDoraCharts: {
2021-03-08 18:12:59 +05:30
type: Boolean,
default: false,
},
2021-12-11 22:18:48 +05:30
shouldRenderQualitySummary: {
type: Boolean,
default: false,
},
2020-03-13 15:44:24 +05:30
},
data() {
return {
2021-03-11 19:13:27 +05:30
selectedTab: 0,
2020-03-13 15:44:24 +05:30
};
},
2021-04-29 21:17:54 +05:30
computed: {
charts() {
const chartsToShow = ['pipelines'];
if (this.shouldRenderDoraCharts) {
2021-06-08 01:23:25 +05:30
chartsToShow.push('deployment-frequency', 'lead-time');
2021-04-29 21:17:54 +05:30
}
2021-12-11 22:18:48 +05:30
if (this.shouldRenderQualitySummary) {
chartsToShow.push('project-quality');
}
2021-04-29 21:17:54 +05:30
return chartsToShow;
},
},
2021-03-11 19:13:27 +05:30
created() {
this.selectTab();
window.addEventListener('popstate', this.selectTab);
2021-03-08 18:12:59 +05:30
},
methods: {
2021-03-11 19:13:27 +05:30
selectTab() {
2021-04-29 21:17:54 +05:30
const [chart] = getParameterValues('chart') || this.charts;
const tab = this.charts.indexOf(chart);
2021-03-11 19:13:27 +05:30
this.selectedTab = tab >= 0 ? tab : 0;
},
onTabChange(index) {
if (index !== this.selectedTab) {
this.selectedTab = index;
2021-04-29 21:17:54 +05:30
const path = mergeUrlParams({ chart: this.charts[index] }, window.location.pathname);
2021-03-11 19:13:27 +05:30
updateHistory({ url: path, title: window.title });
}
2021-02-22 17:27:13 +05:30
},
2020-03-13 15:44:24 +05:30
},
};
</script>
<template>
<div>
2021-04-29 21:17:54 +05:30
<gl-tabs v-if="charts.length > 1" :value="selectedTab" @input="onTabChange">
2021-03-08 18:12:59 +05:30
<gl-tab :title="__('Pipelines')">
2021-03-11 19:13:27 +05:30
<pipeline-charts />
2021-03-08 18:12:59 +05:30
</gl-tab>
2021-04-29 21:17:54 +05:30
<template v-if="shouldRenderDoraCharts">
2021-06-08 01:23:25 +05:30
<gl-tab :title="__('Deployment frequency')">
2021-04-29 21:17:54 +05:30
<deployment-frequency-charts />
</gl-tab>
2021-06-08 01:23:25 +05:30
<gl-tab :title="__('Lead time')">
2021-04-29 21:17:54 +05:30
<lead-time-charts />
</gl-tab>
</template>
2021-12-11 22:18:48 +05:30
<gl-tab v-if="shouldRenderQualitySummary" :title="s__('QualitySummary|Project quality')">
<project-quality-summary />
</gl-tab>
2021-03-08 18:12:59 +05:30
</gl-tabs>
2021-03-11 19:13:27 +05:30
<pipeline-charts v-else />
2020-03-13 15:44:24 +05:30
</div>
</template>