2021-04-17 20:07:23 +05:30
|
|
|
import * as Sentry from '@sentry/browser';
|
2021-09-04 01:27:46 +05:30
|
|
|
import createFlash from '~/flash';
|
2021-03-11 19:13:27 +05:30
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2020-06-23 00:09:42 +05:30
|
|
|
import { joinPaths } from '~/lib/utils/url_utility';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { __ } from '~/locale';
|
|
|
|
import * as types from './mutation_types';
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
setInitialData({ commit }, data) {
|
|
|
|
commit(types.SET_INITIAL_DATA, data);
|
|
|
|
},
|
|
|
|
receiveAuthorsSuccess({ commit }, authors) {
|
|
|
|
commit(types.COMMITS_AUTHORS, authors);
|
|
|
|
},
|
|
|
|
receiveAuthorsError() {
|
2021-09-04 01:27:46 +05:30
|
|
|
createFlash({
|
|
|
|
message: __('An error occurred fetching the project authors.'),
|
|
|
|
});
|
2020-04-22 19:07:51 +05:30
|
|
|
},
|
|
|
|
fetchAuthors({ dispatch, state }, author = null) {
|
|
|
|
const { projectId } = state;
|
|
|
|
return axios
|
2020-07-28 23:09:34 +05:30
|
|
|
.get(joinPaths(gon.relative_url_root || '', '/-/autocomplete/users.json'), {
|
2020-04-22 19:07:51 +05:30
|
|
|
params: {
|
|
|
|
project_id: projectId,
|
|
|
|
active: true,
|
|
|
|
search: author,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(({ data }) => dispatch('receiveAuthorsSuccess', data))
|
2021-03-08 18:12:59 +05:30
|
|
|
.catch((error) => {
|
2020-05-24 23:13:21 +05:30
|
|
|
Sentry.captureException(error);
|
|
|
|
dispatch('receiveAuthorsError');
|
|
|
|
});
|
2020-04-22 19:07:51 +05:30
|
|
|
},
|
|
|
|
};
|