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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/jobs/store/actions.js')
-rw-r--r--app/assets/javascripts/jobs/store/actions.js39
1 files changed, 28 insertions, 11 deletions
diff --git a/app/assets/javascripts/jobs/store/actions.js b/app/assets/javascripts/jobs/store/actions.js
index 41cc5a181dc..f4030939f2c 100644
--- a/app/assets/javascripts/jobs/store/actions.js
+++ b/app/assets/javascripts/jobs/store/actions.js
@@ -14,6 +14,16 @@ import {
scrollUp,
} from '~/lib/utils/scroll_utils';
+export const init = ({ dispatch }, { endpoint, logState, pagePath }) => {
+ dispatch('setJobEndpoint', endpoint);
+ dispatch('setTraceOptions', {
+ logState,
+ pagePath,
+ });
+
+ return Promise.all([dispatch('fetchJob'), dispatch('fetchTrace')]);
+};
+
export const setJobEndpoint = ({ commit }, endpoint) => commit(types.SET_JOB_ENDPOINT, endpoint);
export const setTraceOptions = ({ commit }, options) => commit(types.SET_TRACE_OPTIONS, options);
@@ -147,7 +157,6 @@ export const toggleScrollisInBottom = ({ commit }, toggle) => {
export const requestTrace = ({ commit }) => commit(types.REQUEST_TRACE);
-let traceTimeout;
export const fetchTrace = ({ dispatch, state }) =>
axios
.get(`${state.traceEndpoint}/trace.json`, {
@@ -157,24 +166,32 @@ export const fetchTrace = ({ dispatch, state }) =>
dispatch('toggleScrollisInBottom', isScrolledToBottom());
dispatch('receiveTraceSuccess', data);
- if (!data.complete) {
- traceTimeout = setTimeout(() => {
- dispatch('fetchTrace');
- }, 4000);
- } else {
+ if (data.complete) {
dispatch('stopPollingTrace');
+ } else if (!state.traceTimeout) {
+ dispatch('startPollingTrace');
}
})
.catch(() => dispatch('receiveTraceError'));
-export const stopPollingTrace = ({ commit }) => {
+export const startPollingTrace = ({ dispatch, commit }) => {
+ const traceTimeout = setTimeout(() => {
+ commit(types.SET_TRACE_TIMEOUT, 0);
+ dispatch('fetchTrace');
+ }, 4000);
+
+ commit(types.SET_TRACE_TIMEOUT, traceTimeout);
+};
+
+export const stopPollingTrace = ({ state, commit }) => {
+ clearTimeout(state.traceTimeout);
+ commit(types.SET_TRACE_TIMEOUT, 0);
commit(types.STOP_POLLING_TRACE);
- clearTimeout(traceTimeout);
};
+
export const receiveTraceSuccess = ({ commit }, log) => commit(types.RECEIVE_TRACE_SUCCESS, log);
-export const receiveTraceError = ({ commit }) => {
- commit(types.RECEIVE_TRACE_ERROR);
- clearTimeout(traceTimeout);
+export const receiveTraceError = ({ dispatch }) => {
+ dispatch('stopPollingTrace');
flash(__('An error occurred while fetching the job log.'));
};
/**