From 756012b0524e09601fada80213dd4da3057d329a Mon Sep 17 00:00:00 2001 From: pemontto <939704+pemontto@users.noreply.github.com> Date: Thu, 25 Apr 2024 11:14:31 +0100 Subject: [PATCH] feat(Jira Software Node): Add Wiki Markup support for Jira Cloud comments (#8857) Co-authored-by: Jonathan Bennetts --- .../nodes/Jira/IssueCommentDescription.ts | 36 ++++++++++++++++--- packages/nodes-base/nodes/Jira/Jira.node.ts | 16 +++++++-- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/packages/nodes-base/nodes/Jira/IssueCommentDescription.ts b/packages/nodes-base/nodes/Jira/IssueCommentDescription.ts index e5bbe90891..a6956b2f64 100644 --- a/packages/nodes-base/nodes/Jira/IssueCommentDescription.ts +++ b/packages/nodes-base/nodes/Jira/IssueCommentDescription.ts @@ -111,7 +111,7 @@ export const issueCommentFields: INodeProperties[] = [ displayName: 'Options', name: 'options', type: 'collection', - placeholder: 'Add Field', + placeholder: 'Add Option', default: {}, displayOptions: { show: { @@ -130,10 +130,23 @@ export const issueCommentFields: INodeProperties[] = [ value: 'renderedBody', }, ], - default: '', + default: [], description: 'Use expand to include additional information about comments in the response. This parameter accepts Rendered Body, which returns the comment body rendered in HTML.', }, + { + displayName: 'Use Wiki Markup', + name: 'wikiMarkup', + type: 'boolean', + default: false, + displayOptions: { + show: { + '/jiraVersion': ['cloud'], + }, + }, + description: + 'Whether to enable parsing of wikiformatting for this comment. Default is false.', + }, ], }, @@ -269,7 +282,7 @@ export const issueCommentFields: INodeProperties[] = [ value: 'renderedBody', }, ], - default: '', + default: 'renderedBody', description: 'Use expand to include additional information about comments in the response. This parameter accepts Rendered Body, which returns the comment body rendered in HTML.', }, @@ -384,7 +397,7 @@ export const issueCommentFields: INodeProperties[] = [ displayName: 'Options', name: 'options', type: 'collection', - placeholder: 'Add Field', + placeholder: 'Add Option', default: {}, displayOptions: { show: { @@ -403,10 +416,23 @@ export const issueCommentFields: INodeProperties[] = [ value: 'renderedBody', }, ], - default: '', + default: 'renderedBody', description: 'Use expand to include additional information about comments in the response. This parameter accepts Rendered Body, which returns the comment body rendered in HTML.', }, + { + displayName: 'Use Wiki Markup', + name: 'wikiMarkup', + type: 'boolean', + default: false, + displayOptions: { + show: { + '/jiraVersion': ['cloud'], + }, + }, + description: + 'Whether to enable parsing of wikiformatting for this comment. Default is false.', + }, ], }, ]; diff --git a/packages/nodes-base/nodes/Jira/Jira.node.ts b/packages/nodes-base/nodes/Jira/Jira.node.ts index ed71ec7f9a..c66e194727 100644 --- a/packages/nodes-base/nodes/Jira/Jira.node.ts +++ b/packages/nodes-base/nodes/Jira/Jira.node.ts @@ -1167,7 +1167,7 @@ export class Jira implements INodeType { } if (resource === 'issueComment') { - const apiVersion = jiraVersion === 'server' ? '2' : ('3' as string); + let apiVersion = jiraVersion === 'server' ? '2' : ('3' as string); //https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-post if (operation === 'add') { @@ -1175,6 +1175,11 @@ export class Jira implements INodeType { const jsonParameters = this.getNodeParameter('jsonParameters', 0); const issueKey = this.getNodeParameter('issueKey', i) as string; const options = this.getNodeParameter('options', i); + + if (options.wikiMarkup) { + apiVersion = '2'; + } + const body: IDataObject = {}; if (options.expand) { qs.expand = options.expand as string; @@ -1184,7 +1189,7 @@ export class Jira implements INodeType { Object.assign(body, options); if (!jsonParameters) { const comment = this.getNodeParameter('comment', i) as string; - if (jiraVersion === 'server') { + if (jiraVersion === 'server' || options.wikiMarkup) { Object.assign(body, { body: comment }); } else { Object.assign(body, { @@ -1327,10 +1332,15 @@ export class Jira implements INodeType { qs.expand = options.expand as string; delete options.expand; } + + if (options.wikiMarkup) { + apiVersion = '2'; + } + Object.assign(qs, options); if (!jsonParameters) { const comment = this.getNodeParameter('comment', i) as string; - if (jiraVersion === 'server') { + if (jiraVersion === 'server' || options.wikiMarkup) { Object.assign(body, { body: comment }); } else { Object.assign(body, {