Commit 5fd1dc15 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch '56851-error-tracking-page-seems-broken' into 'master'

Resolve "Error tracking page seems broken"

Closes #56851

See merge request gitlab-org/gitlab-ce!24806
parents f8314e01 b93af54c
...@@ -48,7 +48,7 @@ export default { ...@@ -48,7 +48,7 @@ export default {
} }
}, },
methods: { methods: {
...mapActions(['startPolling']), ...mapActions(['startPolling', 'restartPolling']),
}, },
}; };
</script> </script>
...@@ -56,19 +56,17 @@ export default { ...@@ -56,19 +56,17 @@ export default {
<template> <template>
<div> <div>
<div v-if="errorTrackingEnabled"> <div v-if="errorTrackingEnabled">
<div v-if="loading" class="py-3"><gl-loading-icon :size="3" /></div> <div v-if="loading" class="py-3">
<gl-loading-icon :size="3" />
</div>
<div v-else> <div v-else>
<div class="d-flex justify-content-end"> <div class="d-flex justify-content-end">
<gl-button class="my-3 ml-auto" variant="primary" :href="externalUrl" target="_blank" <gl-button class="my-3 ml-auto" variant="primary" :href="externalUrl" target="_blank">
>View in Sentry <icon name="external-link" /> {{ __('View in Sentry') }}
<icon name="external-link" />
</gl-button> </gl-button>
</div> </div>
<gl-table <gl-table :items="errors" :fields="$options.fields" :show-empty="true">
:items="errors"
:fields="$options.fields"
:show-empty="true"
:empty-text="__('No errors to display')"
>
<template slot="HEAD_events" slot-scope="data"> <template slot="HEAD_events" slot-scope="data">
<div class="text-right">{{ data.label }}</div> <div class="text-right">{{ data.label }}</div>
</template> </template>
...@@ -102,6 +100,14 @@ export default { ...@@ -102,6 +100,14 @@ export default {
<time-ago :time="errors.item.lastSeen" class="text-secondary" /> <time-ago :time="errors.item.lastSeen" class="text-secondary" />
</div> </div>
</template> </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> </gl-table>
</div> </div>
</div> </div>
......
...@@ -6,7 +6,7 @@ import { __, sprintf } from '~/locale'; ...@@ -6,7 +6,7 @@ import { __, sprintf } from '~/locale';
let eTagPoll; let eTagPoll;
export function startPolling({ commit }, endpoint) { export function startPolling({ commit, dispatch }, endpoint) {
eTagPoll = new Poll({ eTagPoll = new Poll({
resource: Service, resource: Service,
method: 'getErrorList', method: 'getErrorList',
...@@ -18,6 +18,7 @@ export function startPolling({ commit }, endpoint) { ...@@ -18,6 +18,7 @@ export function startPolling({ commit }, endpoint) {
commit(types.SET_ERRORS, data.errors); commit(types.SET_ERRORS, data.errors);
commit(types.SET_EXTERNAL_URL, data.external_url); commit(types.SET_EXTERNAL_URL, data.external_url);
commit(types.SET_LOADING, false); commit(types.SET_LOADING, false);
dispatch('stopPolling');
}, },
errorCallback: response => { errorCallback: response => {
let errorMessage = ''; let errorMessage = '';
...@@ -36,4 +37,16 @@ export function startPolling({ commit }, endpoint) { ...@@ -36,4 +37,16 @@ export function startPolling({ commit }, endpoint) {
eTagPoll.makeRequest(); eTagPoll.makeRequest();
} }
export const stopPolling = () => {
if (eTagPoll) eTagPoll.stop();
};
export function restartPolling({ commit }) {
commit(types.SET_ERRORS, []);
commit(types.SET_EXTERNAL_URL, '');
commit(types.SET_LOADING, true);
if (eTagPoll) eTagPoll.restart();
}
export default () => {}; export default () => {};
---
title: Fix error tracking list page
merge_request: 24806
author:
type: fixed
...@@ -1389,6 +1389,9 @@ msgstr "" ...@@ -1389,6 +1389,9 @@ msgstr ""
msgid "Chat" msgid "Chat"
msgstr "" msgstr ""
msgid "Check again"
msgstr ""
msgid "Check the %{docs_link_start}documentation%{docs_link_end}." msgid "Check the %{docs_link_start}documentation%{docs_link_end}."
msgstr "" msgstr ""
...@@ -5006,7 +5009,7 @@ msgstr "" ...@@ -5006,7 +5009,7 @@ msgstr ""
msgid "No due date" msgid "No due date"
msgstr "" msgstr ""
msgid "No errors to display" msgid "No errors to display."
msgstr "" msgstr ""
msgid "No estimate or time spent" msgid "No estimate or time spent"
...@@ -8336,6 +8339,9 @@ msgstr "" ...@@ -8336,6 +8339,9 @@ msgstr ""
msgid "View group labels" msgid "View group labels"
msgstr "" msgstr ""
msgid "View in Sentry"
msgstr ""
msgid "View it on GitLab" msgid "View it on GitLab"
msgstr "" msgstr ""
......
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import ErrorTrackingList from '~/error_tracking/components/error_tracking_list.vue'; import ErrorTrackingList from '~/error_tracking/components/error_tracking_list.vue';
import { GlButton, GlEmptyState, GlLoadingIcon, GlTable } from '@gitlab/ui'; import { GlButton, GlEmptyState, GlLoadingIcon, GlTable, GlLink } from '@gitlab/ui';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
...@@ -9,6 +9,7 @@ localVue.use(Vuex); ...@@ -9,6 +9,7 @@ localVue.use(Vuex);
describe('ErrorTrackingList', () => { describe('ErrorTrackingList', () => {
let store; let store;
let wrapper; let wrapper;
let actions;
function mountComponent({ errorTrackingEnabled = true } = {}) { function mountComponent({ errorTrackingEnabled = true } = {}) {
wrapper = shallowMount(ErrorTrackingList, { wrapper = shallowMount(ErrorTrackingList, {
...@@ -20,12 +21,17 @@ describe('ErrorTrackingList', () => { ...@@ -20,12 +21,17 @@ describe('ErrorTrackingList', () => {
errorTrackingEnabled, errorTrackingEnabled,
illustrationPath: 'illustration/path', illustrationPath: 'illustration/path',
}, },
stubs: {
'gl-link': GlLink,
},
}); });
} }
beforeEach(() => { beforeEach(() => {
const actions = { actions = {
getErrorList: () => {}, getErrorList: () => {},
startPolling: () => {},
restartPolling: jasmine.createSpy('restartPolling'),
}; };
const state = { const state = {
...@@ -83,6 +89,18 @@ describe('ErrorTrackingList', () => { ...@@ -83,6 +89,18 @@ describe('ErrorTrackingList', () => {
expect(wrapper.find(GlTable).exists()).toBeTruthy(); expect(wrapper.find(GlTable).exists()).toBeTruthy();
expect(wrapper.find(GlButton).exists()).toBeTruthy(); expect(wrapper.find(GlButton).exists()).toBeTruthy();
}); });
it('shows a message prompting to refresh', () => {
const refreshLink = wrapper.vm.$refs.empty.querySelector('a');
expect(refreshLink.textContent.trim()).toContain('Check again');
});
it('restarts polling', () => {
wrapper.find('.js-try-again').trigger('click');
expect(actions.restartPolling).toHaveBeenCalled();
});
}); });
describe('error tracking feature disabled', () => { describe('error tracking feature disabled', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment