gitlab-org--gitlab-foss/app/assets/javascripts/notes/services/notes_service.js
Heinrich Lee Yu b689ddd9b6 Do not persist notes filter when auto-switching
Send a `persist_filter: false` param to backend when
opening links to notes and auto-switching to show
all notes
2019-08-07 15:45:23 +00:00

44 lines
1.3 KiB
JavaScript

import Vue from 'vue';
import VueResource from 'vue-resource';
import * as constants from '../constants';
Vue.use(VueResource);
export default {
fetchDiscussions(endpoint, filter, persistFilter = true) {
const config =
filter !== undefined
? { params: { notes_filter: filter, persist_filter: persistFilter } }
: null;
return Vue.http.get(endpoint, config);
},
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 });
},
toggleResolveNote(endpoint, isResolved) {
const { RESOLVE_NOTE_METHOD_NAME, UNRESOLVE_NOTE_METHOD_NAME } = constants;
const method = isResolved ? UNRESOLVE_NOTE_METHOD_NAME : RESOLVE_NOTE_METHOD_NAME;
return Vue.http[method](endpoint);
},
poll(data = {}) {
const endpoint = data.notesData.notesPath;
const { lastFetchedAt } = data;
const options = {
headers: {
'X-Last-Fetched-At': lastFetchedAt ? `${lastFetchedAt}` : undefined,
},
};
return Vue.http.get(endpoint, options);
},
toggleIssueState(endpoint, data) {
return Vue.http.put(endpoint, data);
},
};