| ... | @@ -5,7 +5,6 @@ import Poll from '~/lib/utils/poll'; |
... | @@ -5,7 +5,6 @@ import Poll from '~/lib/utils/poll'; |
|
|
import createFlash from '~/flash';
|
|
import createFlash from '~/flash';
|
|
|
import { s__, sprintf } from '~/locale';
|
|
import { s__, sprintf } from '~/locale';
|
|
|
import axios from '~/lib/utils/axios_utils';
|
|
import axios from '~/lib/utils/axios_utils';
|
|
|
import { jobsPathWithFilter, reposPathWithFilter } from './getters';
|
|
|
|
|
|
|
|
|
|
let eTagPoll;
|
|
let eTagPoll;
|
|
|
|
|
|
| ... | @@ -20,20 +19,16 @@ export const restartJobsPolling = () => { |
... | @@ -20,20 +19,16 @@ export const restartJobsPolling = () => { |
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export const setInitialData = ({ commit }, data) => commit(types.SET_INITIAL_DATA, data);
|
|
export const setInitialData = ({ commit }, data) => commit(types.SET_INITIAL_DATA, data);
|
|
|
export const setFilter = ({ commit }, filter) => commit(types.SET_FILTER, filter);
|
|
|
|
|
|
|
|
|
|
export const requestRepos = ({ commit }, repos) => commit(types.REQUEST_REPOS, repos);
|
|
export const requestRepos = ({ commit }, repos) => commit(types.REQUEST_REPOS, repos);
|
|
|
export const receiveReposSuccess = ({ commit }, repos) =>
|
|
export const receiveReposSuccess = ({ commit }, repos) =>
|
|
|
commit(types.RECEIVE_REPOS_SUCCESS, repos);
|
|
commit(types.RECEIVE_REPOS_SUCCESS, repos);
|
|
|
export const receiveReposError = ({ commit }) => commit(types.RECEIVE_REPOS_ERROR);
|
|
export const receiveReposError = ({ commit }) => commit(types.RECEIVE_REPOS_ERROR);
|
|
|
export const fetchRepos = ({ state, dispatch }) => {
|
|
export const fetchRepos = ({ state, dispatch }) => {
|
|
|
dispatch('stopJobsPolling');
|
|
|
|
|
dispatch('requestRepos');
|
|
dispatch('requestRepos');
|
|
|
|
|
|
|
|
const { provider } = state;
|
|
|
|
|
|
|
|
|
|
return axios
|
|
return axios
|
|
|
.get(reposPathWithFilter(state))
|
|
.get(state.reposPath)
|
|
|
.then(({ data }) =>
|
|
.then(({ data }) =>
|
|
|
dispatch('receiveReposSuccess', convertObjectPropsToCamelCase(data, { deep: true })),
|
|
dispatch('receiveReposSuccess', convertObjectPropsToCamelCase(data, { deep: true })),
|
|
|
)
|
|
)
|
| ... | @@ -41,7 +36,7 @@ export const fetchRepos = ({ state, dispatch }) => { |
... | @@ -41,7 +36,7 @@ export const fetchRepos = ({ state, dispatch }) => { |
|
|
.catch(() => {
|
|
.catch(() => {
|
|
|
createFlash(
|
|
createFlash(
|
|
|
sprintf(s__('ImportProjects|Requesting your %{provider} repositories failed'), {
|
|
sprintf(s__('ImportProjects|Requesting your %{provider} repositories failed'), {
|
|
|
provider,
|
|
provider: state.provider,
|
|
|
}),
|
|
}),
|
|
|
);
|
|
);
|
|
|
|
|
|
| ... | @@ -82,23 +77,16 @@ export const fetchImport = ({ state, dispatch }, { newName, targetNamespace, rep |
... | @@ -82,23 +77,16 @@ export const fetchImport = ({ state, dispatch }, { newName, targetNamespace, rep |
|
|
export const receiveJobsSuccess = ({ commit }, updatedProjects) =>
|
|
export const receiveJobsSuccess = ({ commit }, updatedProjects) =>
|
|
|
commit(types.RECEIVE_JOBS_SUCCESS, updatedProjects);
|
|
commit(types.RECEIVE_JOBS_SUCCESS, updatedProjects);
|
|
|
export const fetchJobs = ({ state, dispatch }) => {
|
|
export const fetchJobs = ({ state, dispatch }) => {
|
|
|
const { filter } = state;
|
|
if (eTagPoll) return;
|
|
|
|
|
|
|
|
if (eTagPoll) {
|
|
|
|
|
stopJobsPolling();
|
|
|
|
|
clearJobsEtagPoll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eTagPoll = new Poll({
|
|
eTagPoll = new Poll({
|
|
|
resource: {
|
|
resource: {
|
|
|
fetchJobs: () => axios.get(jobsPathWithFilter(state)),
|
|
fetchJobs: () => axios.get(state.jobsPath),
|
|
|
},
|
|
},
|
|
|
method: 'fetchJobs',
|
|
method: 'fetchJobs',
|
|
|
successCallback: ({ data }) =>
|
|
successCallback: ({ data }) =>
|
|
|
dispatch('receiveJobsSuccess', convertObjectPropsToCamelCase(data, { deep: true })),
|
|
dispatch('receiveJobsSuccess', convertObjectPropsToCamelCase(data, { deep: true })),
|
|
|
errorCallback: () =>
|
|
errorCallback: () => createFlash(s__('ImportProjects|Updating the imported projects failed')),
|
|
|
createFlash(s__('ImportProjects|Update of imported projects with realtime changes failed')),
|
|
|
|
|
data: { filter },
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
if (!Visibility.hidden()) {
|
|
if (!Visibility.hidden()) {
|
| ... | |
... | |
| ... | | ... | |