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

45 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import Vue from 'vue';
import VueResource from 'vue-resource';
2018-03-27 19:54:05 +05:30
import * as constants from '../constants';
2018-03-17 18:26:18 +05:30
Vue.use(VueResource);
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;
2018-12-13 13:39:08 +05:30
return Vue.http.get(endpoint, config);
2018-03-17 18:26:18 +05:30
},
replyToDiscussion(endpoint, data) {
return Vue.http.post(endpoint, data, { emulateJSON: true });
},
updateNote(endpoint, data) {
return Vue.http.put(endpoint, data, { emulateJSON: true });
},
createNewNote(endpoint, data) {
return Vue.http.post(endpoint, data, { emulateJSON: true });
},
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
return Vue.http[method](endpoint);
},
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
},
};
return Vue.http.get(endpoint, options);
},
2018-03-27 19:54:05 +05:30
toggleIssueState(endpoint, data) {
return Vue.http.put(endpoint, data);
},
2018-03-17 18:26:18 +05:30
};