fix(Jira Trigger Node): Update credentials UI (#9198)

This commit is contained in:
Michael Kret 2024-05-01 07:26:09 +03:00 committed by GitHub
parent 741e8299d6
commit ed98ca2fb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 61 additions and 11 deletions

View file

@ -561,6 +561,7 @@ export default defineComponent({
return !KEEP_AUTH_IN_NDV_FOR_NODES.includes(this.node.type || '') && isRequired; return !KEEP_AUTH_IN_NDV_FOR_NODES.includes(this.node.type || '') && isRequired;
}, },
getCredentialsFieldLabel(credentialType: INodeCredentialDescription): string { getCredentialsFieldLabel(credentialType: INodeCredentialDescription): string {
if (credentialType.displayName) return credentialType.displayName;
const credentialTypeName = this.credentialTypeNames[credentialType.name]; const credentialTypeName = this.credentialTypeNames[credentialType.name];
const isCredentialOnlyNode = this.node.type.startsWith(CREDENTIAL_ONLY_NODE_PREFIX); const isCredentialOnlyNode = this.node.type.startsWith(CREDENTIAL_ONLY_NODE_PREFIX);

View file

@ -17,7 +17,7 @@ export class JiraTrigger implements INodeType {
name: 'jiraTrigger', name: 'jiraTrigger',
icon: 'file:jira.svg', icon: 'file:jira.svg',
group: ['trigger'], group: ['trigger'],
version: 1, version: [1, 1.1],
description: 'Starts the workflow when Jira events occur', description: 'Starts the workflow when Jira events occur',
defaults: { defaults: {
name: 'Jira Trigger', name: 'Jira Trigger',
@ -26,6 +26,7 @@ export class JiraTrigger implements INodeType {
outputs: ['main'], outputs: ['main'],
credentials: [ credentials: [
{ {
displayName: 'Credentials to Connect to Jira',
name: 'jiraSoftwareCloudApi', name: 'jiraSoftwareCloudApi',
required: true, required: true,
displayOptions: { displayOptions: {
@ -35,6 +36,7 @@ export class JiraTrigger implements INodeType {
}, },
}, },
{ {
displayName: 'Credentials to Connect to Jira',
name: 'jiraSoftwareServerApi', name: 'jiraSoftwareServerApi',
required: true, required: true,
displayOptions: { displayOptions: {
@ -46,7 +48,17 @@ export class JiraTrigger implements INodeType {
{ {
// eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed // eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed
name: 'httpQueryAuth', name: 'httpQueryAuth',
required: true, displayName: 'Credentials to Authenticate Webhook',
displayOptions: {
show: {
authenticateWebhook: [true],
},
},
},
{
// eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed
name: 'httpQueryAuth',
displayName: 'Credentials to Authenticate Webhook',
displayOptions: { displayOptions: {
show: { show: {
incomingAuthentication: ['queryAuth'], incomingAuthentication: ['queryAuth'],
@ -80,7 +92,20 @@ export class JiraTrigger implements INodeType {
default: 'cloud', default: 'cloud',
}, },
{ {
displayName: 'Incoming Authentication', displayName: 'Authenticate Incoming Webhook',
name: 'authenticateWebhook',
type: 'boolean',
default: false,
description:
'Whether authentication should be activated for the incoming webhooks (makes it more secure)',
displayOptions: {
show: {
'@version': [{ _cnd: { gte: 1.1 } }],
},
},
},
{
displayName: 'Authenticate Webhook With',
name: 'incomingAuthentication', name: 'incomingAuthentication',
type: 'options', type: 'options',
options: [ options: [
@ -95,6 +120,11 @@ export class JiraTrigger implements INodeType {
], ],
default: 'none', default: 'none',
description: 'If authentication should be activated for the webhook (makes it more secure)', description: 'If authentication should be activated for the webhook (makes it more secure)',
displayOptions: {
show: {
'@version': [1],
},
},
}, },
{ {
displayName: 'Events', displayName: 'Events',
@ -382,17 +412,24 @@ export class JiraTrigger implements INodeType {
return false; return false;
}, },
async create(this: IHookFunctions): Promise<boolean> { async create(this: IHookFunctions): Promise<boolean> {
const nodeVersion = this.getNode().typeVersion;
const webhookUrl = this.getNodeWebhookUrl('default') as string; const webhookUrl = this.getNodeWebhookUrl('default') as string;
let events = this.getNodeParameter('events', []) as string[]; let events = this.getNodeParameter('events', []) as string[];
const additionalFields = this.getNodeParameter('additionalFields') as IDataObject; const additionalFields = this.getNodeParameter('additionalFields') as IDataObject;
const endpoint = '/webhooks/1.0/webhook'; const endpoint = '/webhooks/1.0/webhook';
const webhookData = this.getWorkflowStaticData('node'); const webhookData = this.getWorkflowStaticData('node');
const incomingAuthentication = this.getNodeParameter('incomingAuthentication') as string; let authenticateWebhook = false;
if (nodeVersion === 1) {
const incomingAuthentication = this.getNodeParameter('incomingAuthentication') as string;
if (incomingAuthentication === 'queryAuth') {
authenticateWebhook = true;
}
} else {
authenticateWebhook = this.getNodeParameter('authenticateWebhook') as boolean;
}
if (events.includes('*')) { if (events.includes('*')) {
events = allEvents; events = allEvents;
@ -418,7 +455,7 @@ export class JiraTrigger implements INodeType {
const parameters: any = {}; const parameters: any = {};
if (incomingAuthentication === 'queryAuth') { if (authenticateWebhook) {
let httpQueryAuth; let httpQueryAuth;
try { try {
httpQueryAuth = await this.getCredentials('httpQueryAuth'); httpQueryAuth = await this.getCredentials('httpQueryAuth');
@ -477,13 +514,24 @@ export class JiraTrigger implements INodeType {
}; };
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> { async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const nodeVersion = this.getNode().typeVersion;
const bodyData = this.getBodyData(); const bodyData = this.getBodyData();
const queryData = this.getQueryData() as IDataObject; const queryData = this.getQueryData() as IDataObject;
const response = this.getResponseObject(); const response = this.getResponseObject();
const incomingAuthentication = this.getNodeParameter('incomingAuthentication') as string; let authenticateWebhook = false;
if (incomingAuthentication === 'queryAuth') { if (nodeVersion === 1) {
const incomingAuthentication = this.getNodeParameter('incomingAuthentication') as string;
if (incomingAuthentication === 'queryAuth') {
authenticateWebhook = true;
}
} else {
authenticateWebhook = this.getNodeParameter('authenticateWebhook') as boolean;
}
if (authenticateWebhook) {
let httpQueryAuth: ICredentialDataDecryptedObject | undefined; let httpQueryAuth: ICredentialDataDecryptedObject | undefined;
try { try {

View file

@ -1487,6 +1487,7 @@ export interface INodeCredentialTestRequest {
export interface INodeCredentialDescription { export interface INodeCredentialDescription {
name: string; name: string;
required?: boolean; required?: boolean;
displayName?: string;
displayOptions?: ICredentialsDisplayOptions; displayOptions?: ICredentialsDisplayOptions;
testedBy?: ICredentialTestRequest | string; // Name of a function inside `loadOptions.credentialTest` testedBy?: ICredentialTestRequest | string; // Name of a function inside `loadOptions.credentialTest`
} }