summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/error_tracking/components/error_tracking_list.vue
blob: 11dbb030d422a9ee78143c879d94cec77e5e7c26 (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
122
123
124
125
126
127
<script>
import { mapActions, mapState } from 'vuex';
import { GlEmptyState, GlButton, GlLoadingIcon, GlTable } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago';

export default {
  fields: [
    'error',
    'count',
    'user_count',
    { key: 'last_seen', formatter: 'timeFormated' },
  ],
  components: {
    GlEmptyState,
    GlButton,
    GlLoadingIcon,
    GlTable,
    Icon,
  },
  mixins: [
    timeagoMixin,
  ],
  props: {
    indexPath: {
      type: String,
      required: true,
    },
    enableErrorTrackingLink: {
      type: String,
      required: true,
    },
  },
  computed: {
    ...mapState(['errors', 'externalUrl', 'loadingErrors']),
    featureEnabled() {
      return gon.features.errorTracking;
    },
  },
  methods: {
    ...mapActions(['getErrorList']),
  },
  created() {
    this.getErrorList(this.indexPath);
  },
}
</script>

<template>
  <div>
    <div v-if="featureEnabled">
      <div v-if="loadingErrors" class="py-3">
        <gl-loading-icon :size="3" />
      </div>
      <div v-else>
        <div v-if="errors.length === 0">
          <gl-empty-state
            title="No Errors :("
          />
        </div>
        <div v-else>
          <div class="d-flex justify-content-end">
            <gl-button
              class="my-3 ml-auto"
              variant="primary"
              :href="externalUrl"
              target="_blank"
            >
              View in Sentry
              <icon name="external-link" />
            </gl-button>
          </div>
          <gl-table
            :items="errors"
            :fields="$options.fields"
          >
            <template slot="error" slot-scope="errors">
              {{ errors.item.title }} {{ errors.item.culprit }} {{ errors.item.external_url }}
            </template>
          </gl-table>
        </div>
      </div>
    </div>
    <div v-else>
      <gl-empty-state
        title="Get started with error tracking"
        description="Monitor your errors by integrating with Sentry"
        primary-button-text="Enable error tracking"
        :primary-button-link="enableErrorTrackingLink"
        svg-path="https://gitlab.com/gitlab-org/gitlab-svgs/raw/master/illustrations/cluster_popover.svg"
      />
    </div>
  </div>
</template>
<style>
  .sentry-description,
  .sentry-description-header {
    flex: 1 1 0%;
    width: 50%;
    margin: 0 8px;
  }

  .sentry-culprit {
    color: #999;
    font-weight: 400;
  }

  .sentry-events,
  .sentry-events-header,
  .sentry-users,
  .sentry-users-header,
  .sentry-lastseen,
  .sentry-last-seen-header {
    width: 96px;
    margin: 0 8px;
    text-align: right;
    text-overflow: ellipsis;
  }

  .sentry-header-box {
    display: flex;
    margin-right: 10px;
    padding: 10px 10px 10px 16px;
    border-bottom: 1px solid #eee;
  }
</style>