mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 13:27:31 -08:00
🐛 Fix issue loading issue types with classic projects (#1627)
* 🐛 Fix issue loading issue types with classic projects * ⚡ Minor improvements on Jira-Node Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
parent
b6e89df660
commit
5460b248ee
|
@ -15,15 +15,20 @@ export const issueOperations = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Changelog',
|
||||||
|
value: 'changelog',
|
||||||
|
description: 'Get issue changelog',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Create',
|
name: 'Create',
|
||||||
value: 'create',
|
value: 'create',
|
||||||
description: 'Create a new issue',
|
description: 'Create a new issue',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Update',
|
name: 'Delete',
|
||||||
value: 'update',
|
value: 'delete',
|
||||||
description: 'Update an issue',
|
description: 'Delete an issue',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Get',
|
name: 'Get',
|
||||||
|
@ -35,11 +40,6 @@ export const issueOperations = [
|
||||||
value: 'getAll',
|
value: 'getAll',
|
||||||
description: 'Get all issues',
|
description: 'Get all issues',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'Changelog',
|
|
||||||
value: 'changelog',
|
|
||||||
description: 'Get issue changelog',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'Notify',
|
name: 'Notify',
|
||||||
value: '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`,
|
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',
|
name: 'Update',
|
||||||
value: 'delete',
|
value: 'update',
|
||||||
description: 'Delete an issue',
|
description: 'Update an issue',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'create',
|
default: 'create',
|
||||||
|
@ -370,10 +370,7 @@ export const issueFields = [
|
||||||
{
|
{
|
||||||
displayName: 'Issue Type',
|
displayName: 'Issue Type',
|
||||||
name: 'issueType',
|
name: 'issueType',
|
||||||
type: 'options',
|
type: 'string',
|
||||||
typeOptions: {
|
|
||||||
loadOptionsMethod: 'getIssueTypes',
|
|
||||||
},
|
|
||||||
default: '',
|
default: '',
|
||||||
description: 'Issue Types',
|
description: 'Issue Types',
|
||||||
},
|
},
|
||||||
|
|
|
@ -188,32 +188,15 @@ export class Jira implements INodeType {
|
||||||
async getIssueTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
async getIssueTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
const projectId = this.getCurrentNodeParameter('project');
|
const projectId = this.getCurrentNodeParameter('project');
|
||||||
const returnData: INodePropertyOptions[] = [];
|
const returnData: INodePropertyOptions[] = [];
|
||||||
|
const { issueTypes } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/project/${projectId}`, 'GET');
|
||||||
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) {
|
for (const issueType of issueTypes) {
|
||||||
const issueTypeName = issueType.name;
|
const issueTypeName = issueType.name;
|
||||||
const issueTypeId = issueType.id;
|
const issueTypeId = issueType.id;
|
||||||
|
|
||||||
returnData.push({
|
returnData.push({
|
||||||
name: issueTypeName,
|
name: issueTypeName,
|
||||||
value: issueTypeId,
|
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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
returnData.sort((a, b) => {
|
returnData.sort((a, b) => {
|
||||||
if (a.name < b.name) { return -1; }
|
if (a.name < b.name) { return -1; }
|
||||||
|
@ -382,7 +365,6 @@ export class Jira implements INodeType {
|
||||||
const { fields: { project: { id } } } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'GET', {}, {});
|
const { fields: { project: { id } } } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'GET', {}, {});
|
||||||
projectId = id;
|
projectId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fields = await jiraSoftwareCloudApiRequest.call(this, `/api/2/field`, 'GET');
|
const fields = await jiraSoftwareCloudApiRequest.call(this, `/api/2/field`, 'GET');
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
if (field.custom === true && field.scope && field.scope.project && field.scope.project.id === projectId) {
|
if (field.custom === true && field.scope && field.scope.project && field.scope.project.id === projectId) {
|
||||||
|
|
Loading…
Reference in a new issue