diff options
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/entity_select/utils.js')
-rw-r--r-- | app/assets/javascripts/vue_shared/components/entity_select/utils.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/assets/javascripts/vue_shared/components/entity_select/utils.js b/app/assets/javascripts/vue_shared/components/entity_select/utils.js new file mode 100644 index 00000000000..0a4622269f4 --- /dev/null +++ b/app/assets/javascripts/vue_shared/components/entity_select/utils.js @@ -0,0 +1,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; + } +}; |