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';
|
2023-01-13 00:05:48 +05:30
|
|
|
import Tracking from '~/tracking';
|
|
|
|
import { SNOWPLOW_DATA_SOURCE, SNOWPLOW_LABEL, SNOWPLOW_SCHEMA } from '../constants';
|
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'),
|
2022-08-13 15:12:31 +05:30
|
|
|
ChangeFailureRateCharts: () =>
|
|
|
|
import('ee_component/dora/components/change_failure_rate_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',
|
2022-08-13 15:12:31 +05:30
|
|
|
changeFailureRateTabEvent: 'p_analytics_ci_cd_change_failure_rate',
|
2023-01-13 00:05:48 +05:30
|
|
|
mixins: [Tracking.mixin()],
|
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-08-13 15:12:31 +05:30
|
|
|
chartsToShow.push(
|
|
|
|
'deployment-frequency',
|
|
|
|
'lead-time',
|
|
|
|
'time-to-restore-service',
|
|
|
|
'change-failure-rate',
|
|
|
|
);
|
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
|
|
|
},
|
2023-01-13 00:05:48 +05:30
|
|
|
trackTabClick(event, snowplow = false) {
|
|
|
|
API.trackRedisHllUserEvent(event);
|
|
|
|
|
|
|
|
if (snowplow) {
|
|
|
|
this.track('click_tab', {
|
|
|
|
label: SNOWPLOW_LABEL,
|
|
|
|
context: {
|
|
|
|
schema: SNOWPLOW_SCHEMA,
|
|
|
|
data: {
|
|
|
|
event_name: event,
|
|
|
|
data_source: SNOWPLOW_DATA_SOURCE,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2022-01-26 12:08:38 +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">
|
2022-01-26 12:08:38 +05:30
|
|
|
<gl-tab
|
|
|
|
:title="__('Pipelines')"
|
|
|
|
data-testid="pipelines-tab"
|
2023-01-13 00:05:48 +05:30
|
|
|
@click="trackTabClick($options.piplelinesTabEvent, true)"
|
2022-01-26 12:08:38 +05:30
|
|
|
>
|
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"
|
2023-01-13 00:05:48 +05:30
|
|
|
@click="trackTabClick($options.deploymentFrequencyTabEvent, true)"
|
2022-01-26 12:08:38 +05:30
|
|
|
>
|
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"
|
2023-01-13 00:05:48 +05:30
|
|
|
@click="trackTabClick($options.leadTimeTabEvent, true)"
|
2022-01-26 12:08:38 +05:30
|
|
|
>
|
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>
|
2022-08-13 15:12:31 +05:30
|
|
|
<gl-tab
|
|
|
|
:title="s__('DORA4Metrics|Change failure rate')"
|
|
|
|
data-testid="change-failure-rate-tab"
|
|
|
|
@click="trackTabClick($options.changeFailureRateTabEvent)"
|
|
|
|
>
|
|
|
|
<change-failure-rate-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>
|