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

60 lines
1.5 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';
2021-03-11 19:13:27 +05:30
const charts = ['pipelines', 'deployments'];
2021-03-08 18:12:59 +05:30
2020-03-13 15:44:24 +05:30
export default {
components: {
2021-03-08 18:12:59 +05:30
GlTabs,
GlTab,
PipelineCharts,
DeploymentFrequencyCharts: () =>
import('ee_component/projects/pipelines/charts/components/deployment_frequency_charts.vue'),
2020-03-13 15:44:24 +05:30
},
2021-02-22 17:27:13 +05:30
inject: {
2021-03-08 18:12:59 +05:30
shouldRenderDeploymentFrequencyCharts: {
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-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() {
const [chart] = getParameterValues('chart') || charts;
const tab = charts.indexOf(chart);
this.selectedTab = tab >= 0 ? tab : 0;
},
onTabChange(index) {
if (index !== this.selectedTab) {
this.selectedTab = index;
const path = mergeUrlParams({ chart: charts[index] }, window.location.pathname);
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-03-11 19:13:27 +05:30
<gl-tabs v-if="shouldRenderDeploymentFrequencyCharts" :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>
<gl-tab :title="__('Deployments')">
<deployment-frequency-charts />
</gl-tab>
</gl-tabs>
2021-03-11 19:13:27 +05:30
<pipeline-charts v-else />
2020-03-13 15:44:24 +05:30
</div>
</template>