Skip to content

Commit

Permalink
fix(Jira Trigger Node): Update credentials UI (#9198)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency committed May 1, 2024
1 parent 741e829 commit ed98ca2
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/editor-ui/src/components/NodeCredentials.vue
Expand Up @@ -561,6 +561,7 @@ export default defineComponent({
return !KEEP_AUTH_IN_NDV_FOR_NODES.includes(this.node.type || '') && isRequired;
},
getCredentialsFieldLabel(credentialType: INodeCredentialDescription): string {
if (credentialType.displayName) return credentialType.displayName;
const credentialTypeName = this.credentialTypeNames[credentialType.name];
const isCredentialOnlyNode = this.node.type.startsWith(CREDENTIAL_ONLY_NODE_PREFIX);
Expand Down
70 changes: 59 additions & 11 deletions packages/nodes-base/nodes/Jira/JiraTrigger.node.ts
Expand Up @@ -17,7 +17,7 @@ export class JiraTrigger implements INodeType {
name: 'jiraTrigger',
icon: 'file:jira.svg',
group: ['trigger'],
version: 1,
version: [1, 1.1],
description: 'Starts the workflow when Jira events occur',
defaults: {
name: 'Jira Trigger',
Expand All @@ -26,6 +26,7 @@ export class JiraTrigger implements INodeType {
outputs: ['main'],
credentials: [
{
displayName: 'Credentials to Connect to Jira',
name: 'jiraSoftwareCloudApi',
required: true,
displayOptions: {
Expand All @@ -35,6 +36,7 @@ export class JiraTrigger implements INodeType {
},
},
{
displayName: 'Credentials to Connect to Jira',
name: 'jiraSoftwareServerApi',
required: true,
displayOptions: {
Expand All @@ -46,7 +48,17 @@ export class JiraTrigger implements INodeType {
{
// eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed
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: {
show: {
incomingAuthentication: ['queryAuth'],
Expand Down Expand Up @@ -80,7 +92,20 @@ export class JiraTrigger implements INodeType {
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',
type: 'options',
options: [
Expand All @@ -95,6 +120,11 @@ export class JiraTrigger implements INodeType {
],
default: 'none',
description: 'If authentication should be activated for the webhook (makes it more secure)',
displayOptions: {
show: {
'@version': [1],
},
},
},
{
displayName: 'Events',
Expand Down Expand Up @@ -382,17 +412,24 @@ export class JiraTrigger implements INodeType {
return false;
},
async create(this: IHookFunctions): Promise<boolean> {
const nodeVersion = this.getNode().typeVersion;
const webhookUrl = this.getNodeWebhookUrl('default') as string;

let events = this.getNodeParameter('events', []) as string[];

const additionalFields = this.getNodeParameter('additionalFields') as IDataObject;

const endpoint = '/webhooks/1.0/webhook';

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('*')) {
events = allEvents;
Expand All @@ -418,7 +455,7 @@ export class JiraTrigger implements INodeType {

const parameters: any = {};

if (incomingAuthentication === 'queryAuth') {
if (authenticateWebhook) {
let httpQueryAuth;
try {
httpQueryAuth = await this.getCredentials('httpQueryAuth');
Expand Down Expand Up @@ -477,13 +514,24 @@ export class JiraTrigger implements INodeType {
};

async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const nodeVersion = this.getNode().typeVersion;
const bodyData = this.getBodyData();
const queryData = this.getQueryData() as IDataObject;
const response = this.getResponseObject();

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 (incomingAuthentication === 'queryAuth') {
if (authenticateWebhook) {
let httpQueryAuth: ICredentialDataDecryptedObject | undefined;

try {
Expand Down
1 change: 1 addition & 0 deletions packages/workflow/src/Interfaces.ts
Expand Up @@ -1487,6 +1487,7 @@ export interface INodeCredentialTestRequest {
export interface INodeCredentialDescription {
name: string;
required?: boolean;
displayName?: string;
displayOptions?: ICredentialsDisplayOptions;
testedBy?: ICredentialTestRequest | string; // Name of a function inside `loadOptions.credentialTest`
}
Expand Down

0 comments on commit ed98ca2

Please sign in to comment.