summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/group_select/utils.js
blob: 0a4622269f45de986459648470173c28702bfbc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import Api from '~/api';

export const groupsPath = (groupsFilter, parentGroupID) => {
  if (groupsFilter !== undefined && parentGroupID === undefined) {
    throw new Error('Cannot use groupsFilter without a parentGroupID');
  }
  switch (groupsFilter) {
    case 'descendant_groups':
      return Api.descendantGroupsPath.replace(':id', parentGroupID);
    case 'subgroups':
      return Api.subgroupsPath.replace(':id', parentGroupID);
    default:
      return Api.groupsPath;
  }
};