From 57a2b9cceb52cbed905459e6ae92007e00a335cc Mon Sep 17 00:00:00 2001 From: Jonathan Bennetts Date: Thu, 9 Feb 2023 15:58:52 +0000 Subject: [PATCH] fix(Linear Node): Fix issue with Issue States not loading correctly (#5435) --- .../nodes-base/nodes/Linear/Linear.node.ts | 27 +++++++++++++++++++ packages/nodes-base/nodes/Linear/Queries.ts | 17 +++++++++--- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/packages/nodes-base/nodes/Linear/Linear.node.ts b/packages/nodes-base/nodes/Linear/Linear.node.ts index b5c10b4b22..e04b07aace 100644 --- a/packages/nodes-base/nodes/Linear/Linear.node.ts +++ b/packages/nodes-base/nodes/Linear/Linear.node.ts @@ -134,11 +134,38 @@ export class Linear implements INodeType { return returnData; }, async getStates(this: ILoadOptionsFunctions): Promise { + let teamId = this.getNodeParameter('teamId', null) as string; + // Handle Updates + if (!teamId) { + const updateFields = this.getNodeParameter('updateFields', null) as IDataObject; + // If not updating the team look up the current team + if (!updateFields.teamId) { + const issueId = this.getNodeParameter('issueId'); + const body = { + query: query.getIssueTeam(), + variables: { + issueId, + }, + }; + const responseData = await linearApiRequest.call(this, body); + teamId = responseData?.data?.issue?.team?.id; + } else { + teamId = updateFields.teamId as string; + } + } + const returnData: INodePropertyOptions[] = []; const body = { query: query.getStates(), variables: { $first: 10, + filter: { + team: { + id: { + eq: teamId, + }, + }, + }, }, }; const states = await linearApiRequestAllItems.call(this, 'data.workflowStates', body); diff --git a/packages/nodes-base/nodes/Linear/Queries.ts b/packages/nodes-base/nodes/Linear/Queries.ts index 0bd897a0bd..46a0085aab 100644 --- a/packages/nodes-base/nodes/Linear/Queries.ts +++ b/packages/nodes-base/nodes/Linear/Queries.ts @@ -1,7 +1,7 @@ export const query = { getUsers() { - return `query Users ($first: Int){ - users (first: $first){ + return `query Users ($first: Int, $after: String){ + users (first: $first, after: $after){ nodes { id name @@ -26,8 +26,8 @@ export const query = { }}`; }, getStates() { - return `query States ($first: Int){ - workflowStates (first: $first){ + return `query States ($first: Int, $after: String, $filter: WorkflowStateFilter){ + workflowStates (first: $first, after: $after, filter: $filter){ nodes { id name @@ -121,6 +121,15 @@ export const query = { } }`; }, + getIssueTeam() { + return `query Issue($issueId: String!) { + issue(id: $issueId) { + team { + id + } + } + }`; + }, getIssues() { return `query Issue ($first: Int, $after: String){ issues (first: $first, after: $after){