summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipelines/components/graph/dropdown_job_component.vue
blob: d597af8dfb5f8f4ad9e03b7635a29c7ba97ec5ab (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<script>
  import jobNameComponent from './job_name_component.vue';
  import jobComponent from './job_component.vue';
  import tooltipMixin from '../../../vue_shared/mixins/tooltip';

  /**
   * Renders the dropdown for the pipeline graph.
   *
   * The following object should be provided as `job`:
   *
   * {
   *   "id": 4256,
   *   "name": "test",
   *   "status": {
   *     "icon": "icon_status_success",
   *     "text": "passed",
   *     "label": "passed",
   *     "group": "success",
   *     "details_path": "/root/ci-mock/builds/4256",
   *     "action": {
   *       "icon": "icon_action_retry",
   *       "title": "Retry",
   *       "path": "/root/ci-mock/builds/4256/retry",
   *       "method": "post"
   *     }
   *   }
   * }
   */
  export default {
    props: {
      job: {
        type: Object,
        required: true,
      },
    },

    mixins: [
      tooltipMixin,
    ],

    components: {
      jobComponent,
      jobNameComponent,
    },

    computed: {
      tooltipText() {
        return `${this.job.name} - ${this.job.status.label}`;
      },
    },
  };
</script>
<template>
  <div>
    <button
      type="button"
      data-toggle="dropdown"
      data-container="body"
      class="dropdown-menu-toggle build-content"
      :title="tooltipText"
      ref="tooltip">

      <job-name-component
        :name="job.name"
        :status="job.status" />

      <span class="dropdown-counter-badge">
        {{job.size}}
      </span>
    </button>

    <ul class="dropdown-menu big-pipeline-graph-dropdown-menu js-grouped-pipeline-dropdown">
      <li class="scrollable-menu">
        <ul>
          <li v-for="item in job.jobs">
            <job-component
              :job="item"
              :is-dropdown="true"
              css-class-job-name="mini-pipeline-graph-dropdown-item"
              />
          </li>
        </ul>
      </li>
    </ul>
  </div>
</template>