From 1289c2bac08bc0efd3695b97e375cb6048c4cfd9 Mon Sep 17 00:00:00 2001 From: Zack Urben Date: Thu, 3 Oct 2019 19:13:06 +0000 Subject: [PATCH] Addressing PR comments. --- README.md | 2 ++ src/core/index.ts | 1 + src/core/services/GroupLabels.ts | 12 ++++++++++++ src/core/services/Labels.ts | 19 ++++--------------- src/core/services/index.ts | 1 + test/unit/bundles/GroupsBundle.ts | 1 + 6 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 src/core/services/GroupLabels.ts diff --git a/README.md b/README.md index acf7cb0b..95cba50a 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,7 @@ GroupMembers GroupMilestones GroupProjects GroupVariables +GroupLabels Epics EpicIssues EpicNotes @@ -302,6 +303,7 @@ GroupMembers GroupMilestones GroupProjects GroupVariables +GroupLabels Epics EpicIssues EpicNotes diff --git a/src/core/index.ts b/src/core/index.ts index cf50734d..a9fbe2c7 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -20,6 +20,7 @@ export const GroupsBundle = bundler({ GroupMilestones: APIServices.GroupMilestones, GroupProjects: APIServices.GroupProjects, GroupVariables: APIServices.GroupVariables, + GroupLabels: APIServices.GroupLabels, Epics: APIServices.Epics, EpicIssues: APIServices.EpicIssues, EpicNotes: APIServices.EpicNotes, diff --git a/src/core/services/GroupLabels.ts b/src/core/services/GroupLabels.ts new file mode 100644 index 00000000..6778d90b --- /dev/null +++ b/src/core/services/GroupLabels.ts @@ -0,0 +1,12 @@ +import { BaseService, PaginatedRequestOptions, RequestHelper } from '../infrastructure'; +import { GroupProjectId } from './index'; + +class GroupLabels extends BaseService { + all(groupId: GroupProjectId, options?: PaginatedRequestOptions) { + const gId = encodeURIComponent(groupId); + + return RequestHelper.get(this, `groups/${gId}/labels`, options); + } +} + +export default GroupLabels; diff --git a/src/core/services/Labels.ts b/src/core/services/Labels.ts index b03f0aa0..fefc47f1 100644 --- a/src/core/services/Labels.ts +++ b/src/core/services/Labels.ts @@ -5,24 +5,13 @@ import { RequestHelper, Sudo, } from '../infrastructure'; -import { GroupId, ProjectId, LabelId } from '.'; +import { ProjectId, LabelId } from '.'; class Labels extends BaseService { - all({ - projectId, - groupId, - ...options - }: ({ projectId: ProjectId } | { groupId: GroupId } | {}) & PaginatedRequestOptions) { - let url; - - if (projectId) { - url = `projects/${encodeURIComponent(projectId)}/labels`; - } - else if (groupId) { - url = `groups/${encodeURIComponent(groupId)}/labels`; - } + all(projectId: ProjectId, options?: PaginatedRequestOptions) { + const pId = encodeURIComponent(projectId); - return RequestHelper.get(this, url, options); + return RequestHelper.get(this, `projects/${pId}/labels`, options); } create(projectId: ProjectId, labelName: string, color: string, options?: BaseRequestOptions) { diff --git a/src/core/services/index.ts b/src/core/services/index.ts index dee9f732..b6d60189 100644 --- a/src/core/services/index.ts +++ b/src/core/services/index.ts @@ -8,6 +8,7 @@ export { default as GroupMembers } from './GroupMembers'; export { default as GroupMilestones } from './GroupMilestones'; export { default as GroupProjects } from './GroupProjects'; export { default as GroupVariables } from './GroupVariables'; +export { default as GroupLabels } from './GroupLabels'; export { default as Epics } from './Epics'; export { default as EpicIssues } from './EpicIssues'; export { default as EpicNotes } from './EpicNotes'; diff --git a/test/unit/bundles/GroupsBundle.ts b/test/unit/bundles/GroupsBundle.ts index 4aec799b..6032eacb 100644 --- a/test/unit/bundles/GroupsBundle.ts +++ b/test/unit/bundles/GroupsBundle.ts @@ -13,6 +13,7 @@ test('All the correct service keys are included in the groups bundle', async () 'GroupMilestones', 'GroupProjects', 'GroupVariables', + 'GroupLabels', 'Epics', 'EpicIssues', 'EpicNotes',