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

41 lines
799 B
JavaScript
Raw Normal View History

import Vue from 'vue';
2018-01-23 07:14:29 -05:00
import '../../vue_shared/vue_resource_interceptor';
export default class GroupsService {
constructor(endpoint) {
this.groups = Vue.resource(endpoint);
}
2017-10-13 04:36:25 -04:00
getGroups(parentId, page, filterGroups, sort, archived) {
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 = filterGroups;
}
if (sort) {
data.sort = sort;
}
2017-10-13 04:36:25 -04:00
if (archived) {
data.archived = archived;
}
}
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);
}
}