debian-mirror-gitlab/app/assets/javascripts/notes/services/notes_service.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-12-04 20:38:33 +05:30
import axios from '~/lib/utils/axios_utils';
2018-03-27 19:54:05 +05:30
import * as constants from '../constants';
2018-03-17 18:26:18 +05:30
export default {
2019-10-12 21:52:04 +05:30
fetchDiscussions(endpoint, filter, persistFilter = true) {
const config =
filter !== undefined
? { params: { notes_filter: filter, persist_filter: persistFilter } }
: null;
2019-12-04 20:38:33 +05:30
return axios.get(endpoint, config);
2018-03-17 18:26:18 +05:30
},
replyToDiscussion(endpoint, data) {
2019-12-04 20:38:33 +05:30
return axios.post(endpoint, data);
2018-03-17 18:26:18 +05:30
},
updateNote(endpoint, data) {
2019-12-04 20:38:33 +05:30
return axios.put(endpoint, data);
2018-03-17 18:26:18 +05:30
},
createNewNote(endpoint, data) {
2019-12-04 20:38:33 +05:30
return axios.post(endpoint, data);
2018-03-17 18:26:18 +05:30
},
2018-03-27 19:54:05 +05:30
toggleResolveNote(endpoint, isResolved) {
const { RESOLVE_NOTE_METHOD_NAME, UNRESOLVE_NOTE_METHOD_NAME } = constants;
2018-11-08 19:23:39 +05:30
const method = isResolved ? UNRESOLVE_NOTE_METHOD_NAME : RESOLVE_NOTE_METHOD_NAME;
2018-03-27 19:54:05 +05:30
2019-12-04 20:38:33 +05:30
return axios[method](endpoint);
2018-03-27 19:54:05 +05:30
},
2018-03-17 18:26:18 +05:30
poll(data = {}) {
2018-03-27 19:54:05 +05:30
const endpoint = data.notesData.notesPath;
2018-11-08 19:23:39 +05:30
const { lastFetchedAt } = data;
2018-03-17 18:26:18 +05:30
const options = {
headers: {
2018-03-27 19:54:05 +05:30
'X-Last-Fetched-At': lastFetchedAt ? `${lastFetchedAt}` : undefined,
2018-03-17 18:26:18 +05:30
},
};
2019-12-04 20:38:33 +05:30
return axios.get(endpoint, options);
2018-03-17 18:26:18 +05:30
},
2018-03-27 19:54:05 +05:30
toggleIssueState(endpoint, data) {
2019-12-04 20:38:33 +05:30
return axios.put(endpoint, data);
2018-03-27 19:54:05 +05:30
},
2018-03-17 18:26:18 +05:30
};