diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-01 00:08:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-01 00:08:52 +0300 |
commit | d5d3c03598df712550acf0c6463a61c6e7dcc19e (patch) | |
tree | d0fdf0f9cd6df46aea6ed16b6556f44055efb642 /app/assets/javascripts/error_tracking | |
parent | 0434f38ef1dce4fe640fe1e4542235746ceb943c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/error_tracking')
8 files changed, 70 insertions, 23 deletions
diff --git a/app/assets/javascripts/error_tracking/components/constants.js b/app/assets/javascripts/error_tracking/components/constants.js index 7e3321c91bc..60b217443de 100644 --- a/app/assets/javascripts/error_tracking/components/constants.js +++ b/app/assets/javascripts/error_tracking/components/constants.js @@ -13,3 +13,9 @@ export const severityLevelVariant = { [severityLevel.INFO]: 'info', [severityLevel.DEBUG]: 'light', }; + +export const errorStatus = { + IGNORED: 'ignored', + RESOLVED: 'resolved', + UNRESOLVED: 'unresolved', +}; diff --git a/app/assets/javascripts/error_tracking/components/error_details.vue b/app/assets/javascripts/error_tracking/components/error_details.vue index efc7e3c0809..98fc121d39f 100644 --- a/app/assets/javascripts/error_tracking/components/error_details.vue +++ b/app/assets/javascripts/error_tracking/components/error_details.vue @@ -11,7 +11,7 @@ import Stacktrace from './stacktrace.vue'; import TrackEventDirective from '~/vue_shared/directives/track_event'; import timeagoMixin from '~/vue_shared/mixins/timeago'; import { trackClickErrorLinkToSentryOptions } from '../utils'; -import { severityLevel, severityLevelVariant } from './constants'; +import { severityLevel, severityLevelVariant, errorStatus } from './constants'; import query from '../queries/details.query.graphql'; @@ -32,10 +32,6 @@ export default { }, mixins: [timeagoMixin], props: { - listPath: { - type: String, - required: true, - }, issueUpdatePath: { type: String, required: true, @@ -80,6 +76,7 @@ export default { result(res) { if (res.data.project?.sentryDetailedError) { this.$apollo.queries.GQLerror.stopPolling(); + this.setStatus(this.GQLerror.status); } }, }, @@ -98,6 +95,7 @@ export default { 'stacktraceData', 'updatingResolveStatus', 'updatingIgnoreStatus', + 'errorStatus', ]), ...mapGetters('details', ['stacktrace']), reported() { @@ -153,20 +151,40 @@ export default { severityLevelVariant[this.error.tags.level] || severityLevelVariant[severityLevel.ERROR] ); }, + ignoreBtnLabel() { + return this.errorStatus !== errorStatus.IGNORED ? __('Ignore') : __('Undo ignore'); + }, + resolveBtnLabel() { + return this.errorStatus !== errorStatus.RESOLVED ? __('Resolve') : __('Unresolve'); + }, }, mounted() { this.startPollingDetails(this.issueDetailsPath); this.startPollingStacktrace(this.issueStackTracePath); }, methods: { - ...mapActions('details', ['startPollingDetails', 'startPollingStacktrace', 'updateStatus']), + ...mapActions('details', [ + 'startPollingDetails', + 'startPollingStacktrace', + 'updateStatus', + 'setStatus', + 'updateResolveStatus', + 'updateIgnoreStatus', + ]), trackClickErrorLinkToSentryOptions, createIssue() { this.issueCreationInProgress = true; this.$refs.sentryIssueForm.submit(); }, - updateIssueStatus(status) { - this.updateStatus({ endpoint: this.issueUpdatePath, redirectUrl: this.listPath, status }); + onIgnoreStatusUpdate() { + const status = + this.errorStatus === errorStatus.IGNORED ? errorStatus.UNRESOLVED : errorStatus.IGNORED; + this.updateIgnoreStatus({ endpoint: this.issueUpdatePath, status }); + }, + onResolveStatusUpdate() { + const status = + this.errorStatus === errorStatus.RESOLVED ? errorStatus.UNRESOLVED : errorStatus.RESOLVED; + this.updateResolveStatus({ endpoint: this.issueUpdatePath, status }); }, formatDate(date) { return `${this.timeFormatted(date)} (${dateFormat(date, 'UTC:yyyy-mm-dd h:MM:ssTT Z')})`; @@ -185,15 +203,17 @@ export default { <span v-if="!loadingStacktrace && stacktrace" v-html="reported"></span> <div class="d-inline-flex"> <loading-button - :label="__('Ignore')" + :label="ignoreBtnLabel" :loading="updatingIgnoreStatus" - @click="updateIssueStatus('ignored')" + data-qa-selector="update_ignore_status_button" + @click="onIgnoreStatusUpdate" /> <loading-button class="btn-outline-info ml-2" - :label="__('Resolve')" + :label="resolveBtnLabel" :loading="updatingResolveStatus" - @click="updateIssueStatus('resolved')" + data-qa-selector="update_resolve_status_button" + @click="onResolveStatusUpdate" /> <gl-button v-if="error.gitlab_issue" diff --git a/app/assets/javascripts/error_tracking/details.js b/app/assets/javascripts/error_tracking/details.js index c18298dec4f..a5a7ddc907b 100644 --- a/app/assets/javascripts/error_tracking/details.js +++ b/app/assets/javascripts/error_tracking/details.js @@ -25,7 +25,6 @@ export default () => { const { issueId, projectPath, - listPath, issueUpdatePath, issueDetailsPath, issueStackTracePath, @@ -36,7 +35,6 @@ export default () => { props: { issueId, projectPath, - listPath, issueUpdatePath, issueDetailsPath, issueStackTracePath, diff --git a/app/assets/javascripts/error_tracking/queries/details.query.graphql b/app/assets/javascripts/error_tracking/queries/details.query.graphql index 625ce3030d9..488a3ecc3ab 100644 --- a/app/assets/javascripts/error_tracking/queries/details.query.graphql +++ b/app/assets/javascripts/error_tracking/queries/details.query.graphql @@ -6,6 +6,7 @@ query errorDetails($fullPath: ID!, $errorId: ID!) { title userCount count + status firstSeen lastSeen message diff --git a/app/assets/javascripts/error_tracking/store/actions.js b/app/assets/javascripts/error_tracking/store/actions.js index bb8b039b5df..49fa5f3cec5 100644 --- a/app/assets/javascripts/error_tracking/store/actions.js +++ b/app/assets/javascripts/error_tracking/store/actions.js @@ -4,16 +4,33 @@ import createFlash from '~/flash'; import { visitUrl } from '~/lib/utils/url_utility'; import { __ } from '~/locale'; -export function updateStatus({ commit }, { endpoint, redirectUrl, status }) { - const type = - status === 'resolved' ? types.SET_UPDATING_RESOLVE_STATUS : types.SET_UPDATING_IGNORE_STATUS; - commit(type, true); +export const setStatus = ({ commit }, status) => { + commit(types.SET_ERROR_STATUS, status.toLowerCase()); +}; - return service +export const updateStatus = ({ commit }, { endpoint, redirectUrl, status }) => + service .updateErrorStatus(endpoint, status) - .then(() => visitUrl(redirectUrl)) - .catch(() => createFlash(__('Failed to update issue status'))) - .finally(() => commit(type, false)); -} + .then(() => { + if (redirectUrl) visitUrl(redirectUrl); + commit(types.SET_ERROR_STATUS, status); + }) + .catch(() => createFlash(__('Failed to update issue status'))); + +export const updateResolveStatus = ({ commit, dispatch }, params) => { + commit(types.SET_UPDATING_RESOLVE_STATUS, true); + + return dispatch('updateStatus', params).finally(() => { + commit(types.SET_UPDATING_RESOLVE_STATUS, false); + }); +}; + +export const updateIgnoreStatus = ({ commit, dispatch }, params) => { + commit(types.SET_UPDATING_IGNORE_STATUS, true); + + return dispatch('updateStatus', params).finally(() => { + commit(types.SET_UPDATING_IGNORE_STATUS, false); + }); +}; export default () => {}; diff --git a/app/assets/javascripts/error_tracking/store/details/state.js b/app/assets/javascripts/error_tracking/store/details/state.js index 52b0297607d..f53cbe29c67 100644 --- a/app/assets/javascripts/error_tracking/store/details/state.js +++ b/app/assets/javascripts/error_tracking/store/details/state.js @@ -5,4 +5,5 @@ export default () => ({ loadingStacktrace: true, updatingResolveStatus: false, updatingIgnoreStatus: false, + errorStatus: '', }); diff --git a/app/assets/javascripts/error_tracking/store/mutation_types.js b/app/assets/javascripts/error_tracking/store/mutation_types.js index 30aebacbedd..a7ac6ab2e60 100644 --- a/app/assets/javascripts/error_tracking/store/mutation_types.js +++ b/app/assets/javascripts/error_tracking/store/mutation_types.js @@ -1,2 +1,3 @@ export const SET_UPDATING_RESOLVE_STATUS = 'SET_UPDATING_RESOLVE_STATUS'; export const SET_UPDATING_IGNORE_STATUS = 'SET_UPDATING_IGNORE_STATUS'; +export const SET_ERROR_STATUS = 'SET_ERROR_STATUS'; diff --git a/app/assets/javascripts/error_tracking/store/mutations.js b/app/assets/javascripts/error_tracking/store/mutations.js index c7a7e46df40..8f2d9bcbe85 100644 --- a/app/assets/javascripts/error_tracking/store/mutations.js +++ b/app/assets/javascripts/error_tracking/store/mutations.js @@ -7,4 +7,7 @@ export default { [types.SET_UPDATING_RESOLVE_STATUS](state, updating) { state.updatingResolveStatus = updating; }, + [types.SET_ERROR_STATUS](state, status) { + state.errorStatus = status; + }, }; |