summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/reports/codequality_report/grouped_codequality_reports_app.vue
blob: e568950380e6658cf6f90d0a13482b10a06ec8b8 (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
<script>
import { mapState, mapActions, mapGetters } from 'vuex';
import { s__, sprintf } from '~/locale';
import { componentNames } from '~/reports/components/issue_body';
import ReportSection from '~/reports/components/report_section.vue';
import createStore from './store';

export default {
  name: 'GroupedCodequalityReportsApp',
  store: createStore(),
  components: {
    ReportSection,
  },
  props: {
    headPath: {
      type: String,
      required: true,
    },
    headBlobPath: {
      type: String,
      required: true,
    },
    basePath: {
      type: String,
      required: false,
      default: null,
    },
    baseBlobPath: {
      type: String,
      required: false,
      default: null,
    },
    codequalityReportsPath: {
      type: String,
      required: false,
      default: '',
    },
    codequalityHelpPath: {
      type: String,
      required: true,
    },
  },
  componentNames,
  computed: {
    ...mapState(['newIssues', 'resolvedIssues', 'hasError', 'statusReason']),
    ...mapGetters([
      'hasCodequalityIssues',
      'codequalityStatus',
      'codequalityText',
      'codequalityPopover',
    ]),
  },
  created() {
    this.setPaths({
      basePath: this.basePath,
      headPath: this.headPath,
      baseBlobPath: this.baseBlobPath,
      headBlobPath: this.headBlobPath,
      reportsPath: this.codequalityReportsPath,
      helpPath: this.codequalityHelpPath,
    });

    this.fetchReports();
  },
  methods: {
    ...mapActions(['fetchReports', 'setPaths']),
  },
  loadingText: sprintf(s__('ciReport|Loading %{reportName} report'), {
    reportName: 'codeclimate',
  }),
  errorText: sprintf(s__('ciReport|Failed to load %{reportName} report'), {
    reportName: 'codeclimate',
  }),
};
</script>
<template>
  <report-section
    :status="codequalityStatus"
    :loading-text="$options.loadingText"
    :error-text="$options.errorText"
    :success-text="codequalityText"
    :unresolved-issues="newIssues"
    :resolved-issues="resolvedIssues"
    :has-issues="hasCodequalityIssues"
    :component="$options.componentNames.CodequalityIssueBody"
    :popover-options="codequalityPopover"
    :show-report-section-status-icon="false"
    track-action="users_expanding_testing_code_quality_report"
    class="js-codequality-widget mr-widget-border-top mr-report"
  >
    <template v-if="hasError" #sub-heading>{{ statusReason }}</template>
  </report-section>
</template>