diff options
Diffstat (limited to 'app/assets/javascripts/jobs/store/actions.js')
-rw-r--r-- | app/assets/javascripts/jobs/store/actions.js | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/app/assets/javascripts/jobs/store/actions.js b/app/assets/javascripts/jobs/store/actions.js index cac9dc06284..e3ded725168 100644 --- a/app/assets/javascripts/jobs/store/actions.js +++ b/app/assets/javascripts/jobs/store/actions.js @@ -21,7 +21,8 @@ export const init = ({ dispatch }, { endpoint, logState, pagePath }) => { logState, pagePath, }); - dispatch('fetchJob'); + + return Promise.all([dispatch('fetchJob'), dispatch('fetchTrace')]); }; export const setJobEndpoint = ({ commit }, endpoint) => commit(types.SET_JOB_ENDPOINT, endpoint); @@ -39,7 +40,6 @@ export const toggleSidebar = ({ dispatch, state }) => { }; let eTagPoll; -let isTraceReadyForRender; export const clearEtagPoll = () => { eTagPoll = null; @@ -71,14 +71,7 @@ export const fetchJob = ({ state, dispatch }) => { }); if (!Visibility.hidden()) { - // eslint-disable-next-line promise/catch-or-return - eTagPoll.makeRequest().then(() => { - // if a job is canceled we still need to dispatch - // fetchTrace to get the trace so we check for has_trace - if (state.job.started || state.job.has_trace) { - dispatch('fetchTrace'); - } - }); + eTagPoll.makeRequest(); } else { axios .get(state.jobEndpoint) @@ -88,15 +81,9 @@ export const fetchJob = ({ state, dispatch }) => { Visibility.change(() => { if (!Visibility.hidden()) { - // This check is needed to ensure the loading icon - // is not shown for a finished job during a visibility change - if (!isTraceReadyForRender && state.job.started) { - dispatch('startPollingTrace'); - } dispatch('restartPolling'); } else { dispatch('stopPolling'); - dispatch('stopPollingTrace'); } }); }; @@ -177,8 +164,6 @@ export const fetchTrace = ({ dispatch, state }) => params: { state: state.traceState }, }) .then(({ data }) => { - isTraceReadyForRender = data.complete; - dispatch('toggleScrollisInBottom', isScrolledToBottom()); dispatch('receiveTraceSuccess', data); @@ -258,7 +243,7 @@ export const receiveJobsForStageError = ({ commit }) => { flash(__('An error occurred while fetching the jobs.')); }; -export const triggerManualJob = ({ state, dispatch }, variables) => { +export const triggerManualJob = ({ state }, variables) => { const parsedVariables = variables.map(variable => { const copyVar = { ...variable }; delete copyVar.id; @@ -269,6 +254,5 @@ export const triggerManualJob = ({ state, dispatch }, variables) => { .post(state.job.status.action.path, { job_variables_attributes: parsedVariables, }) - .then(() => dispatch('fetchTrace')) .catch(() => flash(__('An error occurred while triggering the job.'))); }; |