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

error_tracking_list.vue « components « error_tracking « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5cd686873298cad5d82e849e87bcb041e79bd7e8 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<script>
import { mapActions, mapState } from 'vuex';
import {
  GlEmptyState,
  GlButton,
  GlIcon,
  GlLink,
  GlLoadingIcon,
  GlTable,
  GlFormInput,
  GlDropdown,
  GlDropdownItem,
  GlDropdownDivider,
  GlTooltipDirective,
} from '@gitlab/ui';
import AccessorUtils from '~/lib/utils/accessor';
import Icon from '~/vue_shared/components/icon.vue';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import { __ } from '~/locale';
import TrackEventDirective from '~/vue_shared/directives/track_event';
import { trackViewInSentryOptions } from '../utils';

export default {
  fields: [
    { key: 'error', label: __('Open errors'), thClass: 'w-70p' },
    { key: 'events', label: __('Events') },
    { key: 'users', label: __('Users') },
    { key: 'lastSeen', label: __('Last seen'), thClass: 'w-15p' },
  ],
  components: {
    GlEmptyState,
    GlButton,
    GlDropdown,
    GlDropdownItem,
    GlDropdownDivider,
    GlIcon,
    GlLink,
    GlLoadingIcon,
    GlTable,
    GlFormInput,
    Icon,
    TimeAgo,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
    TrackEvent: TrackEventDirective,
  },
  props: {
    indexPath: {
      type: String,
      required: true,
    },
    enableErrorTrackingLink: {
      type: String,
      required: true,
    },
    errorTrackingEnabled: {
      type: Boolean,
      required: true,
    },
    illustrationPath: {
      type: String,
      required: true,
    },
    userCanEnableErrorTracking: {
      type: Boolean,
      required: true,
    },
  },
  hasLocalStorage: AccessorUtils.isLocalStorageAccessSafe(),
  data() {
    return {
      errorSearchQuery: '',
    };
  },
  computed: {
    ...mapState('list', ['errors', 'externalUrl', 'loading', 'recentSearches']),
  },
  created() {
    if (this.errorTrackingEnabled) {
      this.startPolling(this.indexPath);
    }
  },
  methods: {
    ...mapActions('list', [
      'startPolling',
      'restartPolling',
      'addRecentSearch',
      'clearRecentSearches',
      'loadRecentSearches',
      'setIndexPath',
    ]),
    filterErrors() {
      const searchTerm = this.errorSearchQuery.trim();
      this.addRecentSearch(searchTerm);

      this.startPolling(`${this.indexPath}?search_term=${searchTerm}`);
    },
    setSearchText(text) {
      this.errorSearchQuery = text;
      this.filterErrors();
    },
    trackViewInSentryOptions,
    getDetailsLink(errorId) {
      return `error_tracking/${errorId}/details`;
    },
  },
};
</script>

<template>
  <div>
    <div v-if="errorTrackingEnabled">
      <div class="d-flex flex-row justify-content-around bg-secondary border p-3">
        <div class="filtered-search-box">
          <gl-dropdown
            :text="__('Recent searches')"
            class="filtered-search-history-dropdown-wrapper d-none d-md-block"
            toggle-class="filtered-search-history-dropdown-toggle-button"
            :disabled="loading"
          >
            <div v-if="!$options.hasLocalStorage" class="px-3">
              {{ __('This feature requires local storage to be enabled') }}
            </div>
            <template v-else-if="recentSearches.length > 0">
              <gl-dropdown-item
                v-for="searchQuery in recentSearches"
                :key="searchQuery"
                @click="setSearchText(searchQuery)"
                >{{ searchQuery }}</gl-dropdown-item
              >
              <gl-dropdown-divider />
              <gl-dropdown-item ref="clearRecentSearches" @click="clearRecentSearches">{{
                __('Clear recent searches')
              }}</gl-dropdown-item>
            </template>
            <div v-else class="px-3">{{ __("You don't have any recent searches") }}</div>
          </gl-dropdown>
          <div class="filtered-search-input-container flex-fill">
            <gl-form-input
              v-model="errorSearchQuery"
              class="pl-2 filtered-search"
              :disabled="loading"
              :placeholder="__('Search or filter results…')"
              autofocus
              @keyup.enter.native="filterErrors"
            />
          </div>
          <div class="gl-search-box-by-type-right-icons">
            <gl-button
              v-if="errorSearchQuery.length > 0"
              v-gl-tooltip.hover
              :title="__('Clear')"
              class="clear-search text-secondary"
              name="clear"
              @click="errorSearchQuery = ''"
            >
              <gl-icon name="close" :size="12" />
            </gl-button>
          </div>
        </div>

        <gl-button
          v-track-event="trackViewInSentryOptions(externalUrl)"
          class="ml-3"
          variant="primary"
          :href="externalUrl"
          target="_blank"
        >
          {{ __('View in Sentry') }}
          <icon name="external-link" class="flex-shrink-0" />
        </gl-button>
      </div>

      <div v-if="loading" class="py-3">
        <gl-loading-icon size="md" />
      </div>

      <gl-table
        v-else
        class="mt-3"
        :items="errors"
        :fields="$options.fields"
        :show-empty="true"
        fixed
        stacked="sm"
      >
        <template slot="HEAD_events" slot-scope="data">
          <div class="text-md-right">{{ data.label }}</div>
        </template>
        <template slot="HEAD_users" slot-scope="data">
          <div class="text-md-right">{{ data.label }}</div>
        </template>
        <template slot="error" slot-scope="errors">
          <div class="d-flex flex-column">
            <gl-link class="d-flex text-dark" :href="getDetailsLink(errors.item.id)">
              <strong class="text-truncate">{{ errors.item.title.trim() }}</strong>
            </gl-link>
            <span class="text-secondary text-truncate">
              {{ errors.item.culprit }}
            </span>
          </div>
        </template>

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

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

        <template slot="lastSeen" slot-scope="errors">
          <div class="d-flex align-items-center">
            <time-ago :time="errors.item.lastSeen" class="text-secondary" />
          </div>
        </template>
        <template slot="empty">
          <div ref="empty">
            {{ __('No errors to display.') }}
            <gl-link class="js-try-again" @click="restartPolling">
              {{ __('Check again') }}
            </gl-link>
          </div>
        </template>
      </gl-table>
    </div>
    <div v-else-if="userCanEnableErrorTracking">
      <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 v-else>
      <gl-empty-state :title="__('Get started with error tracking')" :svg-path="illustrationPath">
        <template #description>
          <div>
            <span>{{ __('Monitor your errors by integrating with Sentry.') }}</span>
            <a href="/help/user/project/operations/error_tracking.html">
              {{ __('More information') }}
            </a>
          </div>
        </template>
      </gl-empty-state>
    </div>
  </div>
</template>