summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipelines/components/jobs/failed_jobs_app.vue
blob: 9e886fd7a48e1fce38b225b571945cd14e7d60d5 (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
<script>
import { GlLoadingIcon } from '@gitlab/ui';
import { s__ } from '~/locale';
import createFlash from '~/flash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import GetFailedJobsQuery from '../../graphql/queries/get_failed_jobs.query.graphql';
import { prepareFailedJobs } from './utils';
import FailedJobsTable from './failed_jobs_table.vue';

export default {
  components: {
    GlLoadingIcon,
    FailedJobsTable,
  },
  inject: {
    fullPath: {
      default: '',
    },
    pipelineIid: {
      default: '',
    },
  },
  props: {
    failedJobsSummary: {
      type: Array,
      required: true,
    },
  },
  apollo: {
    failedJobs: {
      query: GetFailedJobsQuery,
      variables() {
        return {
          fullPath: this.fullPath,
          pipelineIid: this.pipelineIid,
        };
      },
      update({ project }) {
        if (project?.pipeline?.jobs?.nodes) {
          return project.pipeline.jobs.nodes.map((job) => {
            return { normalizedId: getIdFromGraphQLId(job.id), ...job };
          });
        }
        return [];
      },
      result() {
        this.preparedFailedJobs = prepareFailedJobs(this.failedJobs, this.failedJobsSummary);
      },
      error() {
        createFlash({ message: s__('Jobs|There was a problem fetching the failed jobs.') });
      },
    },
  },
  data() {
    return {
      failedJobs: [],
      preparedFailedJobs: [],
    };
  },
  computed: {
    loading() {
      return this.$apollo.queries.failedJobs.loading;
    },
  },
};
</script>

<template>
  <div>
    <gl-loading-icon v-if="loading" size="lg" class="gl-mt-4" />
    <failed-jobs-table v-else :failed-jobs="preparedFailedJobs" />
  </div>
</template>