summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jobs/components/stages_dropdown.vue
blob: 90482500bbf93d7462bb787d5fc16f3a3c011e99 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
<script>
import _ from 'underscore';
import CiIcon from '~/vue_shared/components/ci_icon.vue';
import Icon from '~/vue_shared/components/icon.vue';

export default {
  components: {
    CiIcon,
    Icon,
  },
  props: {
    pipeline: {
      type: Object,
      required: true,
    },
    stages: {
      type: Array,
      required: true,
    },
    selectedStage: {
      type: String,
      required: true,
    },
  },
  computed: {
    hasRef() {
      return !_.isEmpty(this.pipeline.ref);
    },
  },
  methods: {
    onStageClick(stage) {
      this.$emit('requestSidebarStageDropdown', stage);
    },
  },
};
</script>
<template>
  <div class="block-last dropdown">
    <ci-icon :status="pipeline.details.status" class="vertical-align-middle" />

    {{ __('Pipeline') }}
    <a :href="pipeline.path" class="js-pipeline-path link-commit"> #{{ pipeline.id }} </a>
    <template v-if="hasRef">
      {{ __('from') }}
      <a :href="pipeline.ref.path" class="link-commit ref-name"> {{ pipeline.ref.name }} </a>
    </template>

    <button
      type="button"
      data-toggle="dropdown"
      class="js-selected-stage dropdown-menu-toggle prepend-top-8"
    >
      {{ selectedStage }} <i class="fa fa-chevron-down"></i>
    </button>

    <ul class="dropdown-menu">
      <li v-for="stage in stages" :key="stage.name">
        <button type="button" class="js-stage-item stage-item" @click="onStageClick(stage);">
          {{ stage.name }}
        </button>
      </li>
    </ul>
  </div>
</template>