mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 11:49:59 +00:00
🔀 Merge branch 'MyCupOfTeaOo-master'
This commit is contained in:
@@ -11,22 +11,33 @@ import {
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
ICredentialDataDecryptedObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function jiraSoftwareCloudApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, query?: IDataObject, uri?: string): Promise<any> { // tslint:disable-line:no-any
|
||||
let data; let domain;
|
||||
const jiraCloudCredentials = this.getCredentials('jiraSoftwareCloudApi');
|
||||
const jiraServerCredentials = this.getCredentials('jiraSoftwareServerApi');
|
||||
if (jiraCloudCredentials === undefined && jiraServerCredentials === undefined) {
|
||||
|
||||
const jiraVersion = this.getNodeParameter('jiraVersion', 0) as string;
|
||||
|
||||
let jiraCredentials: ICredentialDataDecryptedObject | undefined;
|
||||
if (jiraVersion === 'server') {
|
||||
jiraCredentials = this.getCredentials('jiraSoftwareServerApi');
|
||||
} else {
|
||||
jiraCredentials = this.getCredentials('jiraSoftwareCloudApi');
|
||||
}
|
||||
|
||||
if (jiraCredentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
}
|
||||
if (jiraCloudCredentials !== undefined) {
|
||||
domain = jiraCloudCredentials!.domain;
|
||||
data = Buffer.from(`${jiraCloudCredentials!.email}:${jiraCloudCredentials!.apiToken}`).toString('base64');
|
||||
|
||||
if (jiraVersion === 'server') {
|
||||
domain = jiraCredentials!.domain;
|
||||
data = Buffer.from(`${jiraCredentials!.email}:${jiraCredentials!.password}`).toString('base64');
|
||||
} else {
|
||||
domain = jiraServerCredentials!.domain;
|
||||
data = Buffer.from(`${jiraServerCredentials!.email}:${jiraServerCredentials!.password}`).toString('base64');
|
||||
domain = jiraCredentials!.domain;
|
||||
data = Buffer.from(`${jiraCredentials!.email}:${jiraCredentials!.apiToken}`).toString('base64');
|
||||
}
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
Authorization: `Basic ${data}`,
|
||||
|
||||
@@ -174,6 +174,31 @@ export const issueFields = [
|
||||
default: [],
|
||||
required : false,
|
||||
description: 'Labels',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/jiraVersion': [
|
||||
'cloud',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Labels',
|
||||
name: 'serverLabels',
|
||||
type: 'string',
|
||||
default: [],
|
||||
required : false,
|
||||
description: 'Labels',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/jiraVersion': [
|
||||
'server',
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Parent Issue Key',
|
||||
@@ -284,6 +309,31 @@ export const issueFields = [
|
||||
default: [],
|
||||
required : false,
|
||||
description: 'Labels',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/jiraVersion': [
|
||||
'cloud',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Labels',
|
||||
name: 'serverLabels',
|
||||
type: 'string',
|
||||
default: [],
|
||||
required : false,
|
||||
description: 'Labels',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/jiraVersion': [
|
||||
'server',
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Parent Issue Key',
|
||||
|
||||
@@ -140,9 +140,9 @@ export class JiraSoftwareCloud implements INodeType {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
|
||||
const issueTypes = await jiraSoftwareCloudApiRequest.call(this, '/issuetype', 'GET');
|
||||
|
||||
for (const issueType of issueTypes) {
|
||||
if (issueType.scope.project.id === projectId) {
|
||||
const jiraVersion = this.getCurrentNodeParameter('jiraVersion') as string;
|
||||
if (jiraVersion === 'server') {
|
||||
for (const issueType of issueTypes) {
|
||||
const issueTypeName = issueType.name;
|
||||
const issueTypeId = issueType.id;
|
||||
|
||||
@@ -151,7 +151,20 @@ export class JiraSoftwareCloud implements INodeType {
|
||||
value: issueTypeId,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
for (const issueType of issueTypes) {
|
||||
if (issueType.scope.project.id === projectId) {
|
||||
const issueTypeName = issueType.name;
|
||||
const issueTypeId = issueType.id;
|
||||
|
||||
returnData.push({
|
||||
name: issueTypeName,
|
||||
value: issueTypeId,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnData;
|
||||
},
|
||||
|
||||
@@ -197,18 +210,37 @@ export class JiraSoftwareCloud implements INodeType {
|
||||
// select them easily
|
||||
async getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const jiraVersion = this.getCurrentNodeParameter('jiraVersion') as string;
|
||||
if (jiraVersion === 'server') {
|
||||
// the interface call must bring username
|
||||
const users = await jiraSoftwareCloudApiRequest.call(this, '/user/search', 'GET', {},
|
||||
{
|
||||
username: "'",
|
||||
}
|
||||
);
|
||||
for (const user of users) {
|
||||
const userName = user.displayName;
|
||||
const userId = user.name;
|
||||
|
||||
const users = await jiraSoftwareCloudApiRequest.call(this, '/users/search', 'GET');
|
||||
returnData.push({
|
||||
name: userName,
|
||||
value: userId,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const users = await jiraSoftwareCloudApiRequest.call(this, '/users/search', 'GET');
|
||||
|
||||
for (const user of users) {
|
||||
const userName = user.displayName;
|
||||
const userId = user.accountId;
|
||||
for (const user of users) {
|
||||
const userName = user.displayName;
|
||||
const userId = user.accountId;
|
||||
|
||||
returnData.push({
|
||||
name: userName,
|
||||
value: userId,
|
||||
});
|
||||
returnData.push({
|
||||
name: userName,
|
||||
value: userId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return returnData;
|
||||
},
|
||||
|
||||
@@ -259,6 +291,8 @@ export class JiraSoftwareCloud implements INodeType {
|
||||
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
const jiraVersion = this.getNodeParameter('jiraVersion', 0) as string;
|
||||
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
if (resource === 'issue') {
|
||||
@@ -281,15 +315,24 @@ export class JiraSoftwareCloud implements INodeType {
|
||||
if (additionalFields.labels) {
|
||||
fields.labels = additionalFields.labels as string[];
|
||||
}
|
||||
if (additionalFields.serverLabels) {
|
||||
fields.labels = additionalFields.serverLabels as string[];
|
||||
}
|
||||
if (additionalFields.priority) {
|
||||
fields.priority = {
|
||||
id: additionalFields.priority as string,
|
||||
};
|
||||
}
|
||||
if (additionalFields.assignee) {
|
||||
fields.assignee = {
|
||||
id: additionalFields.assignee as string,
|
||||
};
|
||||
if (jiraVersion === 'server') {
|
||||
fields.assignee = {
|
||||
name: additionalFields.assignee as string,
|
||||
};
|
||||
} else {
|
||||
fields.assignee = {
|
||||
id: additionalFields.assignee as string,
|
||||
};
|
||||
}
|
||||
}
|
||||
if (additionalFields.description) {
|
||||
fields.description = additionalFields.description as string;
|
||||
@@ -334,15 +377,24 @@ export class JiraSoftwareCloud implements INodeType {
|
||||
if (updateFields.labels) {
|
||||
fields.labels = updateFields.labels as string[];
|
||||
}
|
||||
if (updateFields.serverLabels) {
|
||||
fields.labels = updateFields.serverLabels as string[];
|
||||
}
|
||||
if (updateFields.priority) {
|
||||
fields.priority = {
|
||||
id: updateFields.priority as string,
|
||||
};
|
||||
}
|
||||
if (updateFields.assignee) {
|
||||
fields.assignee = {
|
||||
id: updateFields.assignee as string,
|
||||
};
|
||||
if (jiraVersion === 'server') {
|
||||
fields.assignee = {
|
||||
name: updateFields.assignee as string,
|
||||
};
|
||||
} else {
|
||||
fields.assignee = {
|
||||
id: updateFields.assignee as string,
|
||||
};
|
||||
}
|
||||
}
|
||||
if (updateFields.description) {
|
||||
fields.description = updateFields.description as string;
|
||||
|
||||
Reference in New Issue
Block a user