From 5460b248ee5af3c1edf7871511221a32a035eeca Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Sat, 10 Apr 2021 02:05:21 -0400 Subject: [PATCH] :bug: Fix issue loading issue types with classic projects (#1627) * :bug: Fix issue loading issue types with classic projects * :zap: Minor improvements on Jira-Node Co-authored-by: Jan Oberhauser --- .../nodes-base/nodes/Jira/IssueDescription.ts | 29 +++++++--------- packages/nodes-base/nodes/Jira/Jira.node.ts | 34 +++++-------------- 2 files changed, 21 insertions(+), 42 deletions(-) diff --git a/packages/nodes-base/nodes/Jira/IssueDescription.ts b/packages/nodes-base/nodes/Jira/IssueDescription.ts index 84ee2dae48..9ff54c8218 100644 --- a/packages/nodes-base/nodes/Jira/IssueDescription.ts +++ b/packages/nodes-base/nodes/Jira/IssueDescription.ts @@ -15,15 +15,20 @@ export const issueOperations = [ }, }, options: [ + { + name: 'Changelog', + value: 'changelog', + description: 'Get issue changelog', + }, { name: 'Create', value: 'create', description: 'Create a new issue', }, { - name: 'Update', - value: 'update', - description: 'Update an issue', + name: 'Delete', + value: 'delete', + description: 'Delete an issue', }, { name: 'Get', @@ -35,11 +40,6 @@ export const issueOperations = [ value: 'getAll', description: 'Get all issues', }, - { - name: 'Changelog', - value: 'changelog', - description: 'Get issue changelog', - }, { name: 'Notify', value: 'notify', @@ -51,9 +51,9 @@ export const issueOperations = [ description: `Return either all transitions or a transition that can be performed by the user on an issue, based on the issue's status`, }, { - name: 'Delete', - value: 'delete', - description: 'Delete an issue', + name: 'Update', + value: 'update', + description: 'Update an issue', }, ], default: 'create', @@ -370,10 +370,7 @@ export const issueFields = [ { displayName: 'Issue Type', name: 'issueType', - type: 'options', - typeOptions: { - loadOptionsMethod: 'getIssueTypes', - }, + type: 'string', default: '', description: 'Issue Types', }, @@ -1135,4 +1132,4 @@ export const issueFields = [ }, ], }, -] as INodeProperties[]; \ No newline at end of file +] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Jira/Jira.node.ts b/packages/nodes-base/nodes/Jira/Jira.node.ts index eeb9d7c69d..f11e6abc9a 100644 --- a/packages/nodes-base/nodes/Jira/Jira.node.ts +++ b/packages/nodes-base/nodes/Jira/Jira.node.ts @@ -188,31 +188,14 @@ export class Jira implements INodeType { async getIssueTypes(this: ILoadOptionsFunctions): Promise { const projectId = this.getCurrentNodeParameter('project'); const returnData: INodePropertyOptions[] = []; - - const issueTypes = await jiraSoftwareCloudApiRequest.call(this, '/api/2/issuetype', 'GET'); - const jiraVersion = this.getCurrentNodeParameter('jiraVersion') as string; - if (jiraVersion === 'server') { - for (const issueType of issueTypes) { - const issueTypeName = issueType.name; - const issueTypeId = issueType.id; - - returnData.push({ - name: issueTypeName, - value: issueTypeId, - }); - } - } else { - for (const issueType of issueTypes) { - if (issueType.scope !== undefined && issueType.scope.project.id === projectId) { - const issueTypeName = issueType.name; - const issueTypeId = issueType.id; - - returnData.push({ - name: issueTypeName, - value: issueTypeId, - }); - } - } + const { issueTypes } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/project/${projectId}`, 'GET'); + for (const issueType of issueTypes) { + const issueTypeName = issueType.name; + const issueTypeId = issueType.id; + returnData.push({ + name: issueTypeName, + value: issueTypeId, + }); } returnData.sort((a, b) => { @@ -382,7 +365,6 @@ export class Jira implements INodeType { const { fields: { project: { id } } } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'GET', {}, {}); projectId = id; } - const fields = await jiraSoftwareCloudApiRequest.call(this, `/api/2/field`, 'GET'); for (const field of fields) { if (field.custom === true && field.scope && field.scope.project && field.scope.project.id === projectId) {