summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_pipelines_index/pipeline_actions.js.es6
blob: b195b0ef3bae8e2a27f9db715872464a6b5d0aef (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* global Vue, Flash, gl */
/* eslint-disable no-param-reassign */

((gl) => {
  gl.VuePipelineActions = Vue.extend({
    props: ['pipeline', 'svgs'],
    computed: {
      actions() {
        return this.pipeline.details.manual_actions.length > 0;
      },
      artifacts() {
        return this.pipeline.details.artifacts.length > 0;
      },
    },
    methods: {
      download(name) {
        return `Download ${name} artifacts`;
      },
    },
    template: `
      <td class="pipeline-actions hidden-xs">
        <div class="controls pull-right">
          <div class="btn-group inline">
            <div class="btn-group">
              <button
                v-if='actions'
                class="dropdown-toggle btn btn-default has-tooltip js-pipeline-dropdown-manual-actions"
                data-toggle="dropdown"
                title="Manual build"
                data-placement="top"
                data-toggle="dropdown"
                aria-label="Manual build"
              >
                <span v-html='svgs.iconPlay' aria-hidden="true"></span>
                <i class="fa fa-caret-down" aria-hidden="true"></i>
              </button>
              <ul class="dropdown-menu dropdown-menu-align-right">
                <li v-for='action in pipeline.details.manual_actions'>
                  <a
                    rel="nofollow"
                    data-method="post"
                    :href='action.path'
                  >
                    <span v-html='svgs.iconPlay' aria-hidden="true"></span>
                    <span>{{action.name}}</span>
                  </a>
                </li>
              </ul>
            </div>
            <div class="btn-group">
              <button
                v-if='artifacts'
                class="dropdown-toggle btn btn-default build-artifacts has-tooltip js-pipeline-dropdown-download"
                data-toggle="dropdown"
                title="Artifacts"
                data-placement="top"
                data-toggle="dropdown"
                aria-label="Artifacts"
              >
                <i class="fa fa-download" aria-hidden="true"></i>
                <i class="fa fa-caret-down" aria-hidden="true"></i>
              </button>
              <ul class="dropdown-menu dropdown-menu-align-right">
                <li v-for='artifact in pipeline.details.artifacts'>
                  <a
                    rel="nofollow"
                    :href='artifact.path'
                  >
                    <i class="fa fa-download" aria-hidden="true"></i>
                    <span>{{download(artifact.name)}}</span>
                  </a>
                </li>
              </ul>
            </div>
          </div>
          <div class="cancel-retry-btns inline">
            <a
              v-if='pipeline.flags.retryable'
              class="btn has-tooltip"
              title="Retry"
              rel="nofollow"
              data-method="post"
              data-placement="top"
              data-toggle="dropdown"
              :href='pipeline.retry_path'
              aria-label="Retry"
            >
              <i class="fa fa-repeat" aria-hidden="true"></i>
            </a>
            <a
              v-if='pipeline.flags.cancelable'
              class="btn btn-remove has-tooltip"
              title="Cancel"
              rel="nofollow"
              data-method="post"
              data-placement="top"
              data-toggle="dropdown"
              :href='pipeline.cancel_path'
              aria-label="Cancel"
            >
              <i class="fa fa-remove" aria-hidden="true"></i>
            </a>
          </div>
        </div>
      </td>
    `,
  });
})(window.gl || (window.gl = {}));