diff options
author | Phil Hughes <me@iamphill.com> | 2018-06-29 17:13:26 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-07-03 16:09:35 +0100 |
commit | b24a55a9f4a60c2e1194b6e3abd71321315ec3e4 (patch) | |
tree | 42aa6089a8a3a39692edab41b8dda799f9cbba74 /app/assets/javascripts/ide/stores/modules/pipelines/actions.js | |
parent | d4a4f1ed63b3ec0579d89a17cccf0c8a54821f16 (diff) | |
download | gitlab-ce-b24a55a9f4a60c2e1194b6e3abd71321315ec3e4.tar.gz |
Improve error message across IDE store modules
Closes #47323
Diffstat (limited to 'app/assets/javascripts/ide/stores/modules/pipelines/actions.js')
-rw-r--r-- | app/assets/javascripts/ide/stores/modules/pipelines/actions.js | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/app/assets/javascripts/ide/stores/modules/pipelines/actions.js b/app/assets/javascripts/ide/stores/modules/pipelines/actions.js index fe1dc9ac8f8..5d5628016ce 100644 --- a/app/assets/javascripts/ide/stores/modules/pipelines/actions.js +++ b/app/assets/javascripts/ide/stores/modules/pipelines/actions.js @@ -18,10 +18,27 @@ export const stopPipelinePolling = () => { export const restartPipelinePolling = () => { if (eTagPoll) eTagPoll.restart(); }; +export const forcePipelineRequest = () => { + if (eTagPoll) eTagPoll.makeRequest(); +}; export const requestLatestPipeline = ({ commit }) => commit(types.REQUEST_LATEST_PIPELINE); -export const receiveLatestPipelineError = ({ commit, dispatch }) => { - flash(__('There was an error loading latest pipeline')); +export const receiveLatestPipelineError = ({ commit, dispatch }, err) => { + if (err.response.status !== 404) { + dispatch( + 'setErrorMessage', + { + text: __('An error occured whilst fetching the latest pipline.'), + action: () => + dispatch('forcePipelineRequest').then(() => + dispatch('setErrorMessage', null, { root: true }), + ), + actionText: __('Please try again'), + actionPayload: null, + }, + { root: true }, + ); + } commit(types.RECEIVE_LASTEST_PIPELINE_ERROR); dispatch('stopPipelinePolling'); }; @@ -46,11 +63,11 @@ export const fetchLatestPipeline = ({ dispatch, rootGetters }) => { method: 'lastCommitPipelines', data: { getters: rootGetters }, successCallback: ({ data }) => dispatch('receiveLatestPipelineSuccess', data), - errorCallback: () => dispatch('receiveLatestPipelineError'), + errorCallback: err => dispatch('receiveLatestPipelineError', err), }); if (!Visibility.hidden()) { - eTagPoll.makeRequest(); + dispatch('forcePipelineRequest'); } Visibility.change(() => { @@ -63,9 +80,19 @@ export const fetchLatestPipeline = ({ dispatch, rootGetters }) => { }; export const requestJobs = ({ commit }, id) => commit(types.REQUEST_JOBS, id); -export const receiveJobsError = ({ commit }, id) => { - flash(__('There was an error loading jobs')); - commit(types.RECEIVE_JOBS_ERROR, id); +export const receiveJobsError = ({ commit, dispatch }, stage) => { + dispatch( + 'setErrorMessage', + { + text: __('An error occured whilst loading the pipelines jobs.'), + action: stage => + dispatch('fetchJobs', stage).then(() => dispatch('setErrorMessage', null, { root: true })), + actionText: __('Please try again'), + actionPayload: stage, + }, + { root: true }, + ); + commit(types.RECEIVE_JOBS_ERROR, stage.id); }; export const receiveJobsSuccess = ({ commit }, { id, data }) => commit(types.RECEIVE_JOBS_SUCCESS, { id, data }); @@ -76,7 +103,7 @@ export const fetchJobs = ({ dispatch }, stage) => { axios .get(stage.dropdownPath) .then(({ data }) => dispatch('receiveJobsSuccess', { id: stage.id, data })) - .catch(() => dispatch('receiveJobsError', stage.id)); + .catch(() => dispatch('receiveJobsError', stage)); }; export const toggleStageCollapsed = ({ commit }, stageId) => @@ -90,8 +117,18 @@ export const setDetailJob = ({ commit, dispatch }, job) => { }; export const requestJobTrace = ({ commit }) => commit(types.REQUEST_JOB_TRACE); -export const receiveJobTraceError = ({ commit }) => { - flash(__('Error fetching job trace')); +export const receiveJobTraceError = ({ commit, dispatch }) => { + dispatch( + 'setErrorMessage', + { + text: __('An error occured whilst fetching the job trace.'), + action: () => + dispatch('fetchJobTrace').then(() => dispatch('setErrorMessage', null, { root: true })), + actionText: __('Please try again'), + actionPayload: null, + }, + { root: true }, + ); commit(types.RECEIVE_JOB_TRACE_ERROR); }; export const receiveJobTraceSuccess = ({ commit }, data) => |