Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Jira Software Node): Add Wiki Markup support for Jira Cloud comments #8857

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions packages/nodes-base/nodes/Jira/IssueCommentDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const issueCommentFields: INodeProperties[] = [
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Field',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
Expand All @@ -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.',
},
],
},

Expand Down Expand Up @@ -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.',
},
Expand Down Expand Up @@ -384,7 +397,7 @@ export const issueCommentFields: INodeProperties[] = [
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Field',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
Expand All @@ -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.',
},
],
},
];
16 changes: 13 additions & 3 deletions packages/nodes-base/nodes/Jira/Jira.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,14 +1167,19 @@ 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') {
for (let i = 0; i < length; i++) {
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;
Expand All @@ -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, {
Expand Down Expand Up @@ -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, {
Expand Down
Loading