Skip to content

Commit

Permalink
⚡ Add components parameter to Jira (#2428)
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoE105 authored Nov 19, 2021
1 parent b31820e commit c574a0d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/nodes-base/nodes/Jira/IssueDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ export const issueFields = [
default: '',
description: 'Description',
},
{
displayName: 'Components',
name: 'componentIds',
type: 'multiOptions',
typeOptions: {
loadOptionsMethod: 'getProjectComponents',
loadOptionsDependsOn: [
'project',
],
},
default: [],
},
{
displayName: 'Custom Fields',
name: 'customFieldsUi',
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Jira/IssueInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface IFields {
project?: IDataObject;
summary?: string;
reporter?: IDataObject;
components?: IDataObject[];
}

export interface IIssue {
Expand Down
27 changes: 27 additions & 0 deletions packages/nodes-base/nodes/Jira/Jira.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,30 @@ export class Jira implements INodeType {
}
return returnData;
},

// Get all the components to display them to user so that he can
// select them easily
async getProjectComponents(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];

const project = this.getCurrentNodeParameter('project');
const { values: components } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/project/${project}/component`, 'GET');

for (const component of components) {
returnData.push({
name: component.name,
value: component.id,
});
}

returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});

return returnData;
},
},
};

Expand Down Expand Up @@ -492,6 +516,9 @@ export class Jira implements INodeType {
if (additionalFields.updateHistory) {
qs.updateHistory = additionalFields.updateHistory as boolean;
}
if (additionalFields.componentIds) {
fields.components = (additionalFields.componentIds as string[]).map(id => ({ id }));
}
if (additionalFields.customFieldsUi) {
const customFields = (additionalFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[];
if (customFields) {
Expand Down

0 comments on commit c574a0d

Please sign in to comment.