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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

116 lines
3.4 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';
2022-01-26 12:08:38 +05:30
import API from '~/api';
2021-03-11 19:13:27 +05:30
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'),
2022-07-23 23:45:48 +05:30
TimeToRestoreServiceCharts: () =>
import('ee_component/dora/components/time_to_restore_service_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
},
2022-01-26 12:08:38 +05:30
piplelinesTabEvent: 'p_analytics_ci_cd_pipelines',
deploymentFrequencyTabEvent: 'p_analytics_ci_cd_deployment_frequency',
leadTimeTabEvent: 'p_analytics_ci_cd_lead_time',
2022-07-23 23:45:48 +05:30
timeToRestoreServiceTabEvent: 'p_analytics_ci_cd_time_to_restore_service',
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) {
2022-07-23 23:45:48 +05:30
chartsToShow.push('deployment-frequency', 'lead-time', 'time-to-restore-service');
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
},
2022-01-26 12:08:38 +05:30
trackTabClick(tab) {
API.trackRedisHllUserEvent(tab);
},
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">
2022-01-26 12:08:38 +05:30
<gl-tab
:title="__('Pipelines')"
data-testid="pipelines-tab"
@click="trackTabClick($options.piplelinesTabEvent)"
>
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">
2022-01-26 12:08:38 +05:30
<gl-tab
:title="__('Deployment frequency')"
data-testid="deployment-frequency-tab"
@click="trackTabClick($options.deploymentFrequencyTabEvent)"
>
2021-04-29 21:17:54 +05:30
<deployment-frequency-charts />
</gl-tab>
2022-01-26 12:08:38 +05:30
<gl-tab
:title="__('Lead time')"
data-testid="lead-time-tab"
@click="trackTabClick($options.leadTimeTabEvent)"
>
2021-04-29 21:17:54 +05:30
<lead-time-charts />
</gl-tab>
2022-07-23 23:45:48 +05:30
<gl-tab
:title="s__('DORA4Metrics|Time to restore service')"
data-testid="time-to-restore-service-tab"
@click="trackTabClick($options.timeToRestoreServiceTabEvent)"
>
<time-to-restore-service-charts />
</gl-tab>
2021-04-29 21:17:54 +05:30
</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>