gitlab-org--gitlab-foss/app/assets/javascripts/groups/services/groups_service.js

39 lines
742 B
JavaScript
Raw Normal View History

import Vue from 'vue';
import VueResource from 'vue-resource';
Vue.use(VueResource);
export default class GroupsService {
constructor(endpoint) {
this.groups = Vue.resource(endpoint);
}
getGroups(parentId, page, filterGroups, sort) {
2017-05-22 13:47:05 -04:00
const data = {};
if (parentId) {
2017-05-22 13:47:05 -04:00
data.parent_id = parentId;
} else {
// Do not send the following param for sub groups
if (page) {
data.page = page;
}
if (filterGroups) {
data.filter_groups = filterGroups;
}
if (sort) {
data.sort = sort;
}
}
return this.groups.get(data);
}
2017-05-30 04:12:06 -04:00
// eslint-disable-next-line class-methods-use-this
2017-05-30 04:12:06 -04:00
leaveGroup(endpoint) {
return Vue.http.delete(endpoint);
}
}