mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
features: support jira self-hosted server
This commit is contained in:
parent
2bed4a6246
commit
e4cc3a4bc9
|
@ -555,7 +555,7 @@ class App {
|
||||||
this.app.get('/rest/node-parameter-options', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<INodePropertyOptions[]> => {
|
this.app.get('/rest/node-parameter-options', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<INodePropertyOptions[]> => {
|
||||||
const nodeType = req.query.nodeType as string;
|
const nodeType = req.query.nodeType as string;
|
||||||
let credentials: INodeCredentials | undefined = undefined;
|
let credentials: INodeCredentials | undefined = undefined;
|
||||||
const currentNodeParameters = req.query.currentNodeParameters as INodeParameters[];
|
const currentNodeParameters = JSON.parse('' + req.query.currentNodeParameters) as INodeParameters;
|
||||||
if (req.query.credentials !== undefined) {
|
if (req.query.credentials !== undefined) {
|
||||||
credentials = JSON.parse(req.query.credentials as string);
|
credentials = JSON.parse(req.query.credentials as string);
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,10 +387,10 @@ export async function executeWorkflow(workflowInfo: IExecuteWorkflowInfo, additi
|
||||||
*
|
*
|
||||||
* @export
|
* @export
|
||||||
* @param {IWorkflowCredentials} credentials
|
* @param {IWorkflowCredentials} credentials
|
||||||
* @param {INodeParameters[]} [currentNodeParameters=[]]
|
* @param {INodeParameters} currentNodeParameters
|
||||||
* @returns {Promise<IWorkflowExecuteAdditionalData>}
|
* @returns {Promise<IWorkflowExecuteAdditionalData>}
|
||||||
*/
|
*/
|
||||||
export async function getBase(credentials: IWorkflowCredentials, currentNodeParameters: INodeParameters[] = []): Promise<IWorkflowExecuteAdditionalData> {
|
export async function getBase(credentials: IWorkflowCredentials, currentNodeParameters?: INodeParameters): Promise<IWorkflowExecuteAdditionalData> {
|
||||||
const urlBaseWebhook = WebhookHelpers.getWebhookBaseUrl();
|
const urlBaseWebhook = WebhookHelpers.getWebhookBaseUrl();
|
||||||
|
|
||||||
const timezone = config.get('generic.timezone') as string;
|
const timezone = config.get('generic.timezone') as string;
|
||||||
|
|
|
@ -152,7 +152,7 @@ export function getCredentials(workflow: Workflow, node: INode, type: string, ad
|
||||||
throw new Error(`Node type "${node.type}" does not have any credentials of type "${type}" defined!`);
|
throw new Error(`Node type "${node.type}" does not have any credentials of type "${type}" defined!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NodeHelpers.displayParameter(node.parameters, nodeCredentialDescription, node.parameters) === false) {
|
if (NodeHelpers.displayParameter(additionalData.currentNodeParameters || node.parameters, nodeCredentialDescription, node.parameters) === false) {
|
||||||
// Credentials should not be displayed so return undefined even if they would be defined
|
// Credentials should not be displayed so return undefined even if they would be defined
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
@ -666,14 +666,14 @@ export function getLoadOptionsFunctions(workflow: Workflow, node: INode, additio
|
||||||
return getCredentials(workflow, node, type, additionalData);
|
return getCredentials(workflow, node, type, additionalData);
|
||||||
},
|
},
|
||||||
getCurrentNodeParameter: (parameterName: string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object | undefined => {
|
getCurrentNodeParameter: (parameterName: string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object | undefined => {
|
||||||
const nodeParameters = JSON.parse('' + additionalData.currentNodeParameters);
|
const nodeParameters = additionalData.currentNodeParameters;
|
||||||
if (nodeParameters && nodeParameters[parameterName]) {
|
if (nodeParameters && nodeParameters[parameterName]) {
|
||||||
return nodeParameters[parameterName];
|
return nodeParameters[parameterName];
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
getCurrentNodeParameters: (): INodeParameters | undefined => {
|
getCurrentNodeParameters: (): INodeParameters | undefined => {
|
||||||
return JSON.parse('' + additionalData.currentNodeParameters);
|
return additionalData.currentNodeParameters;
|
||||||
},
|
},
|
||||||
getNode: () => {
|
getNode: () => {
|
||||||
return getNode(node);
|
return getNode(node);
|
||||||
|
|
|
@ -11,11 +11,17 @@ import {
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
|
ICredentialDataDecryptedObject,
|
||||||
} from 'n8n-workflow';
|
} 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
|
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;
|
let data; let domain;
|
||||||
const jiraCloudCredentials = this.getCredentials('jiraSoftwareCloudApi');
|
let jiraCloudCredentials: ICredentialDataDecryptedObject | undefined;
|
||||||
|
try {
|
||||||
|
jiraCloudCredentials = this.getCredentials('jiraSoftwareCloudApi');
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
}
|
||||||
const jiraServerCredentials = this.getCredentials('jiraSoftwareServerApi');
|
const jiraServerCredentials = this.getCredentials('jiraSoftwareServerApi');
|
||||||
if (jiraCloudCredentials === undefined && jiraServerCredentials === undefined) {
|
if (jiraCloudCredentials === undefined && jiraServerCredentials === undefined) {
|
||||||
throw new Error('No credentials got returned!');
|
throw new Error('No credentials got returned!');
|
||||||
|
|
|
@ -174,6 +174,31 @@ export const issueFields = [
|
||||||
default: [],
|
default: [],
|
||||||
required : false,
|
required : false,
|
||||||
description: 'Labels',
|
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',
|
displayName: 'Parent Issue Key',
|
||||||
|
@ -284,6 +309,31 @@ export const issueFields = [
|
||||||
default: [],
|
default: [],
|
||||||
required : false,
|
required : false,
|
||||||
description: 'Labels',
|
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',
|
displayName: 'Parent Issue Key',
|
||||||
|
|
|
@ -140,7 +140,18 @@ export class JiraSoftwareCloud implements INodeType {
|
||||||
const returnData: INodePropertyOptions[] = [];
|
const returnData: INodePropertyOptions[] = [];
|
||||||
|
|
||||||
const issueTypes = await jiraSoftwareCloudApiRequest.call(this, '/issuetype', 'GET');
|
const issueTypes = await jiraSoftwareCloudApiRequest.call(this, '/issuetype', 'GET');
|
||||||
|
const jiraVersion = this.getCurrentNodeParameter('jiraVersion') as string;
|
||||||
|
if (jiraVersion === "server") {
|
||||||
|
for (const issueType of issueTypes) {
|
||||||
|
const issueTypeName = issueType.name;
|
||||||
|
const issueTypeId = issueType.id;
|
||||||
|
|
||||||
|
returnData.push({
|
||||||
|
name: issueTypeName,
|
||||||
|
value: issueTypeId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (const issueType of issueTypes) {
|
for (const issueType of issueTypes) {
|
||||||
if (issueType.scope.project.id === projectId) {
|
if (issueType.scope.project.id === projectId) {
|
||||||
const issueTypeName = issueType.name;
|
const issueTypeName = issueType.name;
|
||||||
|
@ -152,6 +163,8 @@ export class JiraSoftwareCloud implements INodeType {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return returnData;
|
return returnData;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -197,7 +210,24 @@ export class JiraSoftwareCloud implements INodeType {
|
||||||
// select them easily
|
// select them easily
|
||||||
async getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
async getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
const returnData: 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;
|
||||||
|
|
||||||
|
returnData.push({
|
||||||
|
name: userName,
|
||||||
|
value: userId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
const users = await jiraSoftwareCloudApiRequest.call(this, '/users/search', 'GET');
|
const users = await jiraSoftwareCloudApiRequest.call(this, '/users/search', 'GET');
|
||||||
|
|
||||||
for (const user of users) {
|
for (const user of users) {
|
||||||
|
@ -209,6 +239,8 @@ export class JiraSoftwareCloud implements INodeType {
|
||||||
value: userId,
|
value: userId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return returnData;
|
return returnData;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -283,6 +315,9 @@ export class JiraSoftwareCloud implements INodeType {
|
||||||
if (additionalFields.labels) {
|
if (additionalFields.labels) {
|
||||||
fields.labels = additionalFields.labels as string[];
|
fields.labels = additionalFields.labels as string[];
|
||||||
}
|
}
|
||||||
|
if (additionalFields.serverLabels) {
|
||||||
|
fields.labels = additionalFields.serverLabels as string[];
|
||||||
|
}
|
||||||
if (additionalFields.priority) {
|
if (additionalFields.priority) {
|
||||||
fields.priority = {
|
fields.priority = {
|
||||||
id: additionalFields.priority as string,
|
id: additionalFields.priority as string,
|
||||||
|
@ -342,6 +377,9 @@ export class JiraSoftwareCloud implements INodeType {
|
||||||
if (updateFields.labels) {
|
if (updateFields.labels) {
|
||||||
fields.labels = updateFields.labels as string[];
|
fields.labels = updateFields.labels as string[];
|
||||||
}
|
}
|
||||||
|
if (updateFields.serverLabels) {
|
||||||
|
fields.labels = updateFields.serverLabels as string[];
|
||||||
|
}
|
||||||
if (updateFields.priority) {
|
if (updateFields.priority) {
|
||||||
fields.priority = {
|
fields.priority = {
|
||||||
id: updateFields.priority as string,
|
id: updateFields.priority as string,
|
||||||
|
|
|
@ -680,7 +680,7 @@ export interface IWorkflowExecuteAdditionalData {
|
||||||
timezone: string;
|
timezone: string;
|
||||||
webhookBaseUrl: string;
|
webhookBaseUrl: string;
|
||||||
webhookTestBaseUrl: string;
|
webhookTestBaseUrl: string;
|
||||||
currentNodeParameters? : INodeParameters[];
|
currentNodeParameters? : INodeParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type WorkflowExecuteMode = 'cli' | 'error' | 'integrated' | 'internal' | 'manual' | 'retry' | 'trigger' | 'webhook';
|
export type WorkflowExecuteMode = 'cli' | 'error' | 'integrated' | 'internal' | 'manual' | 'retry' | 'trigger' | 'webhook';
|
||||||
|
|
Loading…
Reference in a new issue