summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/error_tracking/components/error_tracking_list.vue
blob: a78834a250dfcb3e6f05401b2c2a0e78b523a05c (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
128
129
130
131
132
133
134
135
136
137
<script>
import { mapActions, mapState } from 'vuex';
import { GlEmptyState, GlButton, GlLink, GlLoadingIcon, GlTable } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import { __ } from '~/locale';

export default {
  fields: [
    { key: 'error', label: __('Open errors') },
    { key: 'events', label: __('Events') },
    { key: 'users', label: __('Users') },
    { key: 'lastSeen', label: __('Last seen') },
  ],
  components: {
    GlEmptyState,
    GlButton,
    GlLink,
    GlLoadingIcon,
    GlTable,
    Icon,
    TimeAgo,
  },
  props: {
    indexPath: {
      type: String,
      required: true,
    },
    enableErrorTrackingLink: {
      type: String,
      required: true,
    },
    errorTrackingEnabled: {
      type: Boolean,
      required: true,
    },
    illustrationPath: {
      type: String,
      required: true,
    },
  },
  computed: {
    ...mapState(['errors', 'externalUrl', 'loading']),
  },
  created() {
    if (this.errorTrackingEnabled) {
      this.startPolling(this.indexPath);
    }
  },
  methods: {
    ...mapActions(['startPolling']),
  },
};
</script>

<template>
  <div>
    <div v-if="errorTrackingEnabled">
      <div v-if="loading" class="py-3"><gl-loading-icon :size="3" /></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"
          :show-empty="true"
          :empty-text="__('No errors to display')"
          class="error-tracking-table"
        >
          <template slot="HEAD_events" slot-scope="data">
            <div class="text-right">{{ data.label }}</div>
          </template>
          <template slot="HEAD_users" slot-scope="data">
            <div class="text-right">{{ data.label }}</div>
          </template>
          <template slot="error" slot-scope="errors">
            <div class="d-flex flex-column">
              <div class="d-flex">
                <gl-link :href="errors.item.externalUrl" class="d-flex text-dark" target="_blank">
                  <strong class="text-truncate">{{ errors.item.title.trim() }}</strong>
                  <icon name="external-link" class="ml-1" />
                </gl-link>
                <span class="text-secondary text-truncate ml-2">{{ errors.item.culprit }}</span>
              </div>
              <div class="text-truncate">
                {{ errors.item.message || __('No details available') }}
              </div>
            </div>
          </template>

          <template slot="events" slot-scope="errors">
            <div class="text-right">{{ errors.item.count }}</div>
          </template>

          <template slot="users" slot-scope="errors">
            <div class="text-right">{{ errors.item.userCount }}</div>
          </template>

          <template slot="lastSeen" slot-scope="errors">
            <div class="d-flex align-items-center">
              <icon name="calendar" css-classes="text-secondary mr-1" />
              <time-ago :time="errors.item.lastSeen" class="text-secondary" />
            </div>
          </template>
        </gl-table>
      </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="illustrationPath"
      />
    </div>
  </div>
</template>

<style>
.error-tracking-table th + th,
.error-tracking-table td + td {
  width: 80px;
}

.error-tracking-table th:last-child,
.error-tracking-table td:last-child {
  width: 140px;
}

.error-tracking-table {
  table-layout: fixed;
}
</style>