summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/projects/pipelines/charts/components/app.vue
blob: 7282ac85c702281f89958273224b4a3c060e93d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<script>
import { GlTabs, GlTab } from '@gitlab/ui';
import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/url_utility';
import PipelineCharts from './pipeline_charts.vue';

const charts = ['pipelines', 'deployments'];

export default {
  components: {
    GlTabs,
    GlTab,
    PipelineCharts,
    DeploymentFrequencyCharts: () =>
      import('ee_component/projects/pipelines/charts/components/deployment_frequency_charts.vue'),
  },
  inject: {
    shouldRenderDeploymentFrequencyCharts: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    const [chart] = getParameterValues('chart') || charts;
    const tab = charts.indexOf(chart);
    return {
      chart,
      selectedTab: tab >= 0 ? tab : 0,
    };
  },
  methods: {
    onTabChange(index) {
      this.selectedTab = index;
      const path = mergeUrlParams({ chart: charts[index] }, window.location.pathname);
      updateHistory({ url: path });
    },
  },
};
</script>
<template>
  <div>
    <gl-tabs v-if="shouldRenderDeploymentFrequencyCharts" :value="selectedTab" @input="onTabChange">
      <gl-tab :title="__('Pipelines')">
        <pipeline-charts />
      </gl-tab>
      <gl-tab :title="__('Deployments')">
        <deployment-frequency-charts />
      </gl-tab>
    </gl-tabs>
    <pipeline-charts v-else />
  </div>
</template>