debian-mirror-gitlab/app/assets/javascripts/sidebar/services/sidebar_service.js

43 lines
1 KiB
JavaScript
Raw Normal View History

2019-12-04 20:38:33 +05:30
import axios from '~/lib/utils/axios_utils';
2017-08-17 22:00:37 +05:30
export default class SidebarService {
2018-03-17 18:26:18 +05:30
constructor(endpointMap) {
2017-08-17 22:00:37 +05:30
if (!SidebarService.singleton) {
2018-03-17 18:26:18 +05:30
this.endpoint = endpointMap.endpoint;
this.toggleSubscriptionEndpoint = endpointMap.toggleSubscriptionEndpoint;
this.moveIssueEndpoint = endpointMap.moveIssueEndpoint;
this.projectsAutocompleteEndpoint = endpointMap.projectsAutocompleteEndpoint;
2017-08-17 22:00:37 +05:30
SidebarService.singleton = this;
}
return SidebarService.singleton;
}
get() {
2019-12-04 20:38:33 +05:30
return axios.get(this.endpoint);
2017-08-17 22:00:37 +05:30
}
update(key, data) {
2019-12-04 20:38:33 +05:30
return axios.put(this.endpoint, { [key]: data });
2017-08-17 22:00:37 +05:30
}
2018-03-17 18:26:18 +05:30
getProjectsAutocomplete(searchTerm) {
2019-12-04 20:38:33 +05:30
return axios.get(this.projectsAutocompleteEndpoint, {
2018-03-17 18:26:18 +05:30
params: {
search: searchTerm,
},
});
}
toggleSubscription() {
2019-12-04 20:38:33 +05:30
return axios.post(this.toggleSubscriptionEndpoint);
2018-03-17 18:26:18 +05:30
}
moveIssue(moveToProjectId) {
2019-12-04 20:38:33 +05:30
return axios.post(this.moveIssueEndpoint, {
2018-03-17 18:26:18 +05:30
move_to_project_id: moveToProjectId,
});
}
2017-08-17 22:00:37 +05:30
}