mr_widget_pipeline.vue 2.9 KB
Newer Older
1
<script>
F
Filipa Lacerda 已提交
2
  /* eslint-disable vue/require-default-prop */
3 4 5
  import pipelineStage from '~/pipelines/components/stage.vue';
  import ciIcon from '~/vue_shared/components/ci_icon.vue';
  import icon from '~/vue_shared/components/icon.vue';
6 7 8

  export default {
    name: 'MRWidgetPipeline',
F
Filipa Lacerda 已提交
9 10 11 12 13
    components: {
      pipelineStage,
      ciIcon,
      icon,
    },
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
    props: {
      pipeline: {
        type: Object,
        required: true,
      },
      // This prop needs to be camelCase, html attributes are case insensive
      // https://vuejs.org/v2/guide/components.html#camelCase-vs-kebab-case
      hasCi: {
        type: Boolean,
        required: false,
      },
      ciStatus: {
        type: String,
        required: false,
      },
    },
    computed: {
      hasPipeline() {
        return this.pipeline && Object.keys(this.pipeline).length > 0;
      },
      hasCIError() {
F
Filipa Lacerda 已提交
35
        return this.hasCi && !this.ciStatus;
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
      },
      status() {
        return this.pipeline.details &&
          this.pipeline.details.status ? this.pipeline.details.status : {};
      },
      hasStages() {
        return this.pipeline.details &&
          this.pipeline.details.stages &&
          this.pipeline.details.stages.length;
      },
    },
  };
</script>

<template>
  <div
    v-if="hasPipeline || hasCIError"
    class="mr-widget-heading">
    <div class="ci-widget media">
      <template v-if="hasCIError">
        <div class="ci-status-icon ci-status-icon-failed ci-error js-ci-error append-right-10">
          <icon name="status_failed" />
        </div>
        <div class="media-body">
          Could not connect to the CI server. Please check your settings and try again
        </div>
      </template>
      <template v-else-if="hasPipeline">
        <a
          class="append-right-10"
F
Filipa Lacerda 已提交
66 67
          :href="status.details_path"
        >
68 69 70 71 72 73 74
          <ci-icon :status="status" />
        </a>

        <div class="media-body">
          Pipeline
          <a
            :href="pipeline.path"
F
Filipa Lacerda 已提交
75 76 77
            class="pipeline-id"
          >
            #{{ pipeline.id }}
78 79
          </a>

F
Filipa Lacerda 已提交
80
          {{ pipeline.details.status.label }} for
81 82 83

          <a
            :href="pipeline.commit.commit_path"
F
Filipa Lacerda 已提交
84 85 86
            class="commit-sha js-commit-link"
          >
          {{ pipeline.commit.short_id }}</a>.
87 88

          <span class="mr-widget-pipeline-graph">
F
Filipa Lacerda 已提交
89 90 91 92
            <span
              class="stage-cell"
              v-if="hasStages"
            >
93 94 95
              <div
                v-for="(stage, i) in pipeline.details.stages"
                :key="i"
F
Filipa Lacerda 已提交
96 97
                class="stage-container dropdown js-mini-pipeline-graph"
              >
98 99 100 101 102 103
                <pipeline-stage :stage="stage" />
              </div>
            </span>
          </span>

          <template v-if="pipeline.coverage">
F
Filipa Lacerda 已提交
104
            Coverage {{ pipeline.coverage }}%
105 106 107 108 109 110
          </template>
        </div>
      </template>
    </div>
  </div>
</template>