debian-mirror-gitlab/app/assets/javascripts/groups/service/groups_service.js

41 lines
799 B
JavaScript
Raw Normal View History

2017-09-10 17:25:29 +05:30
import Vue from 'vue';
2018-03-17 18:26:18 +05:30
import '../../vue_shared/vue_resource_interceptor';
2017-09-10 17:25:29 +05:30
export default class GroupsService {
constructor(endpoint) {
this.groups = Vue.resource(endpoint);
}
2018-03-17 18:26:18 +05:30
getGroups(parentId, page, filterGroups, sort, archived) {
2017-09-10 17:25:29 +05:30
const data = {};
if (parentId) {
data.parent_id = parentId;
} else {
// Do not send the following param for sub groups
if (page) {
data.page = page;
}
if (filterGroups) {
2018-03-17 18:26:18 +05:30
data.filter = filterGroups;
2017-09-10 17:25:29 +05:30
}
if (sort) {
data.sort = sort;
}
2018-03-17 18:26:18 +05:30
if (archived) {
data.archived = archived;
}
2017-09-10 17:25:29 +05:30
}
return this.groups.get(data);
}
// eslint-disable-next-line class-methods-use-this
leaveGroup(endpoint) {
return Vue.http.delete(endpoint);
}
}