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

40 lines
781 B
JavaScript
Raw Normal View History

2019-12-04 20:38:33 +05:30
import axios from '~/lib/utils/axios_utils';
2017-09-10 17:25:29 +05:30
export default class GroupsService {
constructor(endpoint) {
2019-12-04 20:38:33 +05:30
this.endpoint = endpoint;
2017-09-10 17:25:29 +05:30
}
2018-03-17 18:26:18 +05:30
getGroups(parentId, page, filterGroups, sort, archived) {
2019-12-04 20:38:33 +05:30
const params = {};
2017-09-10 17:25:29 +05:30
if (parentId) {
2019-12-04 20:38:33 +05:30
params.parent_id = parentId;
2017-09-10 17:25:29 +05:30
} else {
// Do not send the following param for sub groups
if (page) {
2019-12-04 20:38:33 +05:30
params.page = page;
2017-09-10 17:25:29 +05:30
}
if (filterGroups) {
2019-12-04 20:38:33 +05:30
params.filter = filterGroups;
2017-09-10 17:25:29 +05:30
}
if (sort) {
2019-12-04 20:38:33 +05:30
params.sort = sort;
2017-09-10 17:25:29 +05:30
}
2018-03-17 18:26:18 +05:30
if (archived) {
2019-12-04 20:38:33 +05:30
params.archived = archived;
2018-03-17 18:26:18 +05:30
}
2017-09-10 17:25:29 +05:30
}
2019-12-04 20:38:33 +05:30
return axios.get(this.endpoint, { params });
2017-09-10 17:25:29 +05:30
}
// eslint-disable-next-line class-methods-use-this
leaveGroup(endpoint) {
2019-12-04 20:38:33 +05:30
return axios.delete(endpoint);
2017-09-10 17:25:29 +05:30
}
}