Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pipeline_failed_jobs_widget.vue « failure_widget « pipelines_list « components « pipelines « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c01037e97918b9010904b7fc16dfda2f0343b202 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
<script>
import { GlButton, GlCard, GlIcon, GlLink, GlPopover, GlSprintf } from '@gitlab/ui';
import { __, s__, sprintf } from '~/locale';
import FailedJobsList from './failed_jobs_list.vue';

export default {
  components: {
    GlButton,
    GlCard,
    GlIcon,
    GlLink,
    GlPopover,
    GlSprintf,
    FailedJobsList,
  },
  inject: ['fullPath'],
  props: {
    failedJobsCount: {
      required: true,
      type: Number,
    },
    isPipelineActive: {
      required: true,
      type: Boolean,
    },
    pipelineIid: {
      required: true,
      type: Number,
    },
    pipelinePath: {
      required: true,
      type: String,
    },
    projectPath: {
      required: true,
      type: String,
    },
  },
  data() {
    return {
      currentFailedJobsCount: this.failedJobsCount,
      isActive: false,
      isExpanded: false,
    };
  },
  computed: {
    bodyClasses() {
      return this.isExpanded ? '' : 'gl-display-none';
    },
    failedJobsCountText() {
      return sprintf(this.$options.i18n.failedJobsLabel, { count: this.currentFailedJobsCount });
    },
    iconName() {
      return this.isExpanded ? 'chevron-down' : 'chevron-right';
    },
    popoverId() {
      return `popover-${this.pipelineIid}`;
    },
  },
  watch: {
    failedJobsCount(val) {
      this.currentFailedJobsCount = val;
    },
  },
  methods: {
    setFailedJobsCount(count) {
      this.currentFailedJobsCount = count;
    },
    toggleWidget() {
      this.isExpanded = !this.isExpanded;
    },
  },
  i18n: {
    additionalInfoPopover: s__(
      'Pipelines|You will see a maximum of 100 jobs in this list. To view all failed jobs, %{linkStart}go to the details page%{linkEnd} of this pipeline.',
    ),
    additionalInfoTitle: __('Limitation on this view'),
    failedJobsLabel: __('Failed jobs (%{count})'),
  },
};
</script>
<template>
  <gl-card
    class="gl-new-card"
    :class="{ 'gl-border-white gl-hover-border-gray-100': !isExpanded }"
    header-class="gl-new-card-header gl-px-3 gl-py-3"
    body-class="gl-new-card-body"
    data-testid="failed-jobs-card"
    :aria-expanded="isExpanded.toString()"
  >
    <template #header>
      <gl-button
        variant="link"
        class="gl-text-gray-500! gl-font-weight-semibold"
        @click="toggleWidget"
      >
        <gl-icon :name="iconName" />
        {{ failedJobsCountText }}
        <gl-icon :id="popoverId" name="information-o" class="gl-ml-2" />
        <gl-popover :target="popoverId" placement="top">
          <template #title> {{ $options.i18n.additionalInfoTitle }} </template>
          <slot>
            <gl-sprintf :message="$options.i18n.additionalInfoPopover">
              <template #link="{ content }">
                <gl-link class="gl-font-sm" :href="pipelinePath">{{ content }}</gl-link>
              </template>
            </gl-sprintf>
          </slot>
        </gl-popover>
      </gl-button>
    </template>
    <failed-jobs-list
      v-if="isExpanded"
      :failed-jobs-count="failedJobsCount"
      :is-pipeline-active="isPipelineActive"
      :pipeline-iid="pipelineIid"
      :project-path="projectPath"
      @failed-jobs-count="setFailedJobsCount"
    />
  </gl-card>
</template>