diff --git a/packages/nodes-base/nodes/Kitemaker/Kitemaker.node.ts b/packages/nodes-base/nodes/Kitemaker/Kitemaker.node.ts index 1c0c0040a7..184a9d6234 100644 --- a/packages/nodes-base/nodes/Kitemaker/Kitemaker.node.ts +++ b/packages/nodes-base/nodes/Kitemaker/Kitemaker.node.ts @@ -118,10 +118,16 @@ export class Kitemaker implements INodeType { }, async getStatuses(this: ILoadOptionsFunctions) { + const spaceId = this.getNodeParameter('spaceId', 0) as string; + if (!spaceId.length) { + throw new Error('Please choose a space to set for the work item to create.'); + } + const responseData = await kitemakerRequest.call(this, { query: getStatuses }); const { data: { organization: { spaces } } } = responseData; + const space = spaces.find((e: { [x: string]: string; }) => e.id == spaceId) - return createLoadOptions(spaces[0].statuses); + return createLoadOptions(space.statuses); }, async getUsers(this: ILoadOptionsFunctions) { diff --git a/packages/nodes-base/nodes/Kitemaker/descriptions/WorkItemDescription.ts b/packages/nodes-base/nodes/Kitemaker/descriptions/WorkItemDescription.ts index 8b8aecab1a..7c643dbb91 100644 --- a/packages/nodes-base/nodes/Kitemaker/descriptions/WorkItemDescription.ts +++ b/packages/nodes-base/nodes/Kitemaker/descriptions/WorkItemDescription.ts @@ -59,11 +59,33 @@ export const workItemFields: INodeProperties[] = [ }, }, }, + { + displayName: 'Space ID', + name: 'spaceId', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getSpaces', + }, + default: [], + required: true, + description: 'ID of the space to retrieve the work items from.', + displayOptions: { + show: { + resource: [ + 'workItem', + ], + operation: [ + 'create', + ], + }, + }, + }, { displayName: 'Status ID', name: 'statusId', type: 'options', typeOptions: { + loadOptionsDependsOn: ['spaceId'], loadOptionsMethod: 'getStatuses', }, default: [], diff --git a/packages/nodes-base/nodes/Kitemaker/queries.ts b/packages/nodes-base/nodes/Kitemaker/queries.ts index 74f584a7c7..ea665d5f9a 100644 --- a/packages/nodes-base/nodes/Kitemaker/queries.ts +++ b/packages/nodes-base/nodes/Kitemaker/queries.ts @@ -84,6 +84,7 @@ export const getStatuses = ` query { organization { spaces { + id statuses { id name