Skip to content

Commit

Permalink
feat(Jira Software Node): Use resource locator component (#5090)
Browse files Browse the repository at this point in the history
* ⚡️Issue -> Create -> parameter Project RLC

* 🔥removed unused loadOptions getProjects

* ⚡️Issue -> Create -> parameter Issue Type RLC

* 🔥removed unused loadOptions getIssueTypes

* ⚡️Issue -> Create/Update -> parameter Assignee RLC

* ⚡️Issue -> Create/Update -> parameter Reporter RLC

* ⚡️Issue -> Create/Update -> parameter Priority RLC

* 🔥removed unused loadOptions getPriorities

* ⚡️Issue -> Update -> parameter Status RLC

* 🔥removed unused loadOptions getTransitions

* 🎨 fix typos

* ⚡️Issue -> Create/Update -> Custom Fields parameter Field RLC

* 🔥removed unused loadOptions getCustomFields

* 🥅 throw custom error for "Field priority cannot be set"

* 🚨 fix linter error

* ⚡ removed ts-ignore

* ⚡ removed ts-ignore

Co-authored-by: Michael Kret <michael.k@radency.com>
  • Loading branch information
maspio and michael-radency authored Jan 24, 2023
1 parent 2b776f3 commit 237b1d8
Show file tree
Hide file tree
Showing 4 changed files with 635 additions and 256 deletions.
39 changes: 34 additions & 5 deletions packages/nodes-base/nodes/Jira/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import {
ILoadOptionsFunctions,
} from 'n8n-core';

import { IDataObject } from 'n8n-workflow';
import { IDataObject, INodeListSearchItems, NodeApiError } from 'n8n-workflow';

export async function jiraSoftwareCloudApiRequest(
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
endpoint: string,
method: string,

body: any = {},
query?: IDataObject,
uri?: string,
Expand Down Expand Up @@ -56,16 +55,27 @@ export async function jiraSoftwareCloudApiRequest(
if (Object.keys(query || {}).length === 0) {
delete options.qs;
}

return this.helpers.requestWithAuthentication.call(this, credentialType, options);
try {
return await this.helpers.requestWithAuthentication.call(this, credentialType, options);
} catch (error) {
if (
error.description?.includes &&
error.description.includes("Field 'priority' cannot be set")
) {
throw new NodeApiError(this.getNode(), error, {
message:
"Field 'priority' cannot be set. You need to add the Priority field to your Jira Project's Issue Types.",
});
}
throw error;
}
}

export async function jiraSoftwareCloudApiRequestAllItems(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
propertyName: string,
endpoint: string,
method: string,

body: any = {},
query: IDataObject = {},
): Promise<any> {
Expand Down Expand Up @@ -198,3 +208,22 @@ export const allEvents = [
'worklog_updated',
'worklog_deleted',
];

export function filterSortSearchListItems(items: INodeListSearchItems[], filter?: string) {
return items
.filter(
(item) =>
!filter ||
item.name.toLowerCase().includes(filter.toLowerCase()) ||
item.value.toString().toLowerCase().includes(filter.toLowerCase()),
)
.sort((a, b) => {
if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {
return -1;
}
if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) {
return 1;
}
return 0;
});
}
Loading

0 comments on commit 237b1d8

Please sign in to comment.